Skip to content

Commit

Permalink
Enable cppcheck lints in behavior_velocity_planner (autowarefoundatio…
Browse files Browse the repository at this point in the history
…n#159)

* Enable lints in behavior_velocity_planner

* Fix package.xml
  • Loading branch information
nnmm authored Dec 15, 2020
1 parent 2cb51b2 commit 3b6a503
Show file tree
Hide file tree
Showing 34 changed files with 202 additions and 92 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ project(behavior_velocity_planner)
### Compile options
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
endif()
if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wno-unused-parameter -Wall -Wextra -Wpedantic)
Expand Down Expand Up @@ -211,6 +213,12 @@ target_link_libraries(behavior_velocity_planner_node
)

ament_export_dependencies(${BEHAVIOR_VELOCITY_PLANNER_DEPENDENCIES})

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
endif()

ament_auto_package(INSTALL_TO_SHARE
launch
config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <memory>
#include <set>
#include <string>

#include "autoware_planning_msgs/msg/path.hpp"
#include "autoware_planning_msgs/msg/path_with_lane_id.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

#include <memory>
#include <string>
#include <tuple>
#include <vector>

#include "boost/assert.hpp"
#include "boost/geometry.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.
#pragma once

#include <algorithm>
#include <vector>

#include "boost/assign/list_of.hpp"
Expand Down Expand Up @@ -43,11 +44,11 @@ using LineString2d = boost::geometry::model::linestring<Point2d>;
using Polygon2d =
boost::geometry::model::polygon<Point2d, false, false>; // counter-clockwise, open

// cppcheck-suppress unknownMacro
BOOST_GEOMETRY_REGISTER_POINT_3D(geometry_msgs::msg::Point, double, cs::cartesian, x, y, z)
BOOST_GEOMETRY_REGISTER_POINT_3D(
geometry_msgs::msg::PoseWithCovarianceStamped, double, cs::cartesian, pose.pose.position.x,
pose.pose.position.y, pose.pose.position.z)

BOOST_GEOMETRY_REGISTER_POINT_3D(
autoware_planning_msgs::msg::PathPoint, double, cs::cartesian, pose.position.x, pose.position.y,
pose.position.z)
Expand Down Expand Up @@ -105,7 +106,7 @@ inline Polygon2d lines2polygon(const LineString2d & left_line, const LineString2
inline Polygon2d obj2polygon(
const geometry_msgs::msg::Pose & pose, const geometry_msgs::msg::Vector3 & shape)
{
//rename
// rename
const double x = pose.position.x;
const double y = pose.position.y;
const double h = shape.x;
Expand Down Expand Up @@ -135,27 +136,27 @@ inline double calcOverlapAreaRate(const Polygon2d & target, const Polygon2d & ba
/* OverlapAreaRate: common area(target && base) / target area */

if (boost::geometry::within(target, base)) {
//target is within base, common area = target area
// target is within base, common area = target area
return 1.0;
}

if (!boost::geometry::intersects(target, base)) {
//target and base has not intersect area
// target and base has not intersect area
return 0.0;
}

//calculate intersect polygon
// calculate intersect polygon
std::vector<Polygon2d> intersects;
boost::geometry::intersection(target, base, intersects);

//calculate area of polygon
// calculate area of polygon
double intersect_area = 0.0;
for (const auto intersect : intersects) {
intersect_area += boost::geometry::area(intersect);
}
const double target_area = boost::geometry::area(target);
//specification of boost1.65
//common area is not intersect area
// specification of boost1.65
// common area is not intersect area
const double common_area = target_area - intersect_area;

return common_area / target_area;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

#ifndef BEHAVIOR_VELOCITY_PLANNER_UTILIZATION_INTERPOLATE_H_
#define BEHAVIOR_VELOCITY_PLANNER_UTILIZATION_INTERPOLATE_H_

#include <cmath>
#include <vector>

Expand All @@ -37,7 +38,7 @@ class LinearInterpolate
bool isIncrease(const std::vector<double> & x);
bool isValidInput(
const std::vector<double> & base_index, const std::vector<double> & base_value,
const std::vector<double> & return_index, std::vector<double> & return_value);
const std::vector<double> & return_index);
std::vector<double> calcEuclidDist(const std::vector<double> & x, const std::vector<double> & y);

} // namespace interpolation
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
/*
* MIT License
*
* Copyright (c) 2018 Forrest
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
// Copyright 2018 Forrest
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

#ifndef CUBIC_SPLINE_H
#define CUBIC_SPLINE_H

Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,21 @@
/*
* Copyright 2015-2019 Autoware Foundation. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
// Copyright 2015-2019 Autoware Foundation
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef COMMON_MATH_PLANNING_UTILS_H
#define COMMON_MATH_PLANNING_UTILS_H

#include <string>
#include <vector>

#include "pcl/point_types.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@
<depend>vehicle_info_util</depend>
<depend>visualization_msgs</depend>

<test_depend>ament_lint_auto</test_depend>
<test_depend>ament_cmake_cppcheck</test_depend>

<export>
<build_type>ament_cmake</build_type>
</export>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include "rclcpp/rclcpp.hpp"

#include <memory>

#include "behavior_velocity_planner/node.hpp"

int main(int argc, char ** argv)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

#include <functional>

#include <memory>

#include "behavior_velocity_planner/node.hpp"

#include "pcl/common/transforms.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
// limitations under the License.

#include "behavior_velocity_planner/planner_manager.hpp"

#include <string>
#include <memory>
#include "boost/format.hpp"

namespace
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <string>

#include "scene_module/blind_spot/scene.hpp"

#include "utilization/marker_helper.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "scene_module/blind_spot/manager.hpp"

#include <vector>
#include <set>
#include <string>
#include <memory>

#include "lanelet2_core/primitives/BasicRegulatoryElements.h"

#include "utilization/boost_geometry_helper.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,26 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "scene_module/blind_spot/scene.hpp"
#include "boost/geometry/algorithms/distance.hpp"

#include "lanelet2_core/geometry/Polygon.h"
#include "lanelet2_core/primitives/BasicRegulatoryElements.h"
#include "lanelet2_extension/regulatory_elements/road_marking.hpp"
#include "lanelet2_extension/utility/query.hpp"
#include "lanelet2_extension/utility/utilities.hpp"
#include <memory>
#include <string>
#include <algorithm>
#include <vector>

#include "scene_module/intersection/util.hpp"
#include "utilization/boost_geometry_helper.hpp"
#include "utilization/interpolate.hpp"
#include "utilization/util.hpp"

#include "lanelet2_core/geometry/Polygon.h"
#include "lanelet2_core/primitives/BasicRegulatoryElements.h"
#include "lanelet2_extension/regulatory_elements/road_marking.hpp"
#include "lanelet2_extension/utility/query.hpp"
#include "lanelet2_extension/utility/utilities.hpp"
#include "boost/geometry/algorithms/distance.hpp"

namespace bg = boost::geometry;

BlindSpotModule::BlindSpotModule(
Expand Down Expand Up @@ -331,7 +337,7 @@ lanelet::ConstLanelet BlindSpotModule::generateHalfLanelet(
auto half_lanelet = lanelet::Lanelet(lanelet::InvalId, left_bound, right_bound);
const auto centerline = lanelet::utils::generateFineCenterline(half_lanelet, 5.0);
half_lanelet.setCenterline(centerline);
return half_lanelet;
return std::move(half_lanelet);
}

BlindSpotPolygons BlindSpotModule::generateBlindSpotPolygons(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include <vector>

#include "scene_module/crosswalk/scene_crosswalk.hpp"
#include "scene_module/crosswalk/scene_walkway.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,14 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "scene_module/crosswalk/manager.hpp"

#include <vector>
#include <memory>
#include <set>
#include <string>

namespace
{
std::vector<lanelet::ConstLanelet> getCrosswalksOnPath(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "scene_module/crosswalk/scene_crosswalk.hpp"

#include <vector>
#include "utilization/util.hpp"

#include <cmath>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "scene_module/crosswalk/scene_walkway.hpp"
#include "utilization/util.hpp"

#include <cmath>

#include "utilization/util.hpp"

namespace bg = boost::geometry;
using Point = bg::model::d2::point_xy<double>;
using Polygon = bg::model::polygon<Point, false>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,16 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "scene_module/crosswalk/util.hpp"
#include "utilization/util.hpp"

#include <algorithm>
#include <cmath>
#include <string>
#include <vector>

#include "utilization/util.hpp"

#include "boost/assert.hpp"
#include "boost/assign/list_of.hpp"
#include "boost/geometry.hpp"
Expand Down Expand Up @@ -116,8 +119,8 @@ bool insertTargetVelocityPoint(
target_point_with_lane_id.point.pose.position.x = target_point.x();
target_point_with_lane_id.point.pose.position.y = target_point.y();
if (insert_target_point_idx > 0) {
//calculate z-position of the target point (Internal division point of point1/point2)
//if insert_target_point_idx is zero, use z-position of target_velocity_point_idx
// calculate z-position of the target point (Internal division point of point1/point2)
// if insert_target_point_idx is zero, use z-position of target_velocity_point_idx
const double internal_div_ratio =
(point1 - target_point).norm() /
((point1 - target_point).norm() + (point2 - target_point).norm());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "scene_module/detection_area/scene.hpp"

#include "tf2_geometry_msgs/tf2_geometry_msgs.h"
Expand Down
Loading

0 comments on commit 3b6a503

Please sign in to comment.