Skip to content

Commit

Permalink
Add linters to obstacle_avoidance_planner (autowarefoundation#158)
Browse files Browse the repository at this point in the history
* Added linters to obstacle_avoidance_planner

* Fix header issues

* Fix linting issues

* Fix more linting issues

* Fix even more linting issues

* Final linting fixes

* Fix dependencies

* Use ament_cmake_cppcheck and ament_cmake_cpplint
  • Loading branch information
esteve authored Dec 14, 2020
1 parent 0e42a42 commit 341a8c2
Show file tree
Hide file tree
Showing 21 changed files with 465 additions and 431 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ project(obstacle_avoidance_planner)

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(-Wall -Wextra -Wpedantic)
Expand Down Expand Up @@ -37,6 +39,11 @@ target_link_libraries(obstacle_avoidance_planner_node
${OpenCV_LIBRARIES}
)

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

ament_auto_package(
INSTALL_TO_SHARE
launch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,17 @@
// 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 DEBUG_OBSTACLEA_AVOIDANCE_PLANNER_H
#define DEBUG_OBSTACLEA_AVOIDANCE_PLANNER_H
#ifndef OBSTACLE_AVOIDANCE_PLANNER__DEBUG_HPP_
#define OBSTACLE_AVOIDANCE_PLANNER__DEBUG_HPP_

#include <string>
#include <vector>

#include "autoware_perception_msgs/msg/dynamic_object.hpp"
#include "autoware_planning_msgs/msg/trajectory_point.hpp"
#include "nav_msgs/msg/occupancy_grid.hpp"
#include "opencv2/core.hpp"
#include "visualization_msgs/msg/marker_array.hpp"

struct ConstrainRectangle;
struct Bounds;
Expand Down Expand Up @@ -83,4 +92,4 @@ visualization_msgs::msg::MarkerArray getVirtualWallTextMarkerArray(

nav_msgs::msg::OccupancyGrid getDebugCostmap(
const cv::Mat & clearance_map, const nav_msgs::msg::OccupancyGrid & occupancy_grid);
#endif
#endif // OBSTACLE_AVOIDANCE_PLANNER__DEBUG_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,23 @@
// 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 EB_PATH_OPTIMIZER_H
#define EB_PATH_OPTIMIZER_H
#ifndef OBSTACLE_AVOIDANCE_PLANNER__EB_PATH_OPTIMIZER_HPP_
#define OBSTACLE_AVOIDANCE_PLANNER__EB_PATH_OPTIMIZER_HPP_

#include "boost/optional/optional_fwd.hpp"

#include "eigen3/Eigen/Core"

#include "opencv2/core.hpp"
#include <memory>
#include <vector>

#include "rclcpp/clock.hpp"
#include "autoware_perception_msgs/msg/dynamic_object.hpp"
#include "autoware_planning_msgs/msg/path.hpp"
#include "autoware_planning_msgs/msg/path_point.hpp"
#include "autoware_planning_msgs/msg/trajectory.hpp"
#include "geometry_msgs/msg/pose.hpp"
#include "boost/optional/optional_fwd.hpp"
#include "eigen3/Eigen/Core"
#include "geometry_msgs/msg/point.hpp"
#include "geometry_msgs/msg/pose.hpp"
#include "nav_msgs/msg/map_meta_data.hpp"
#include "opencv2/core.hpp"

struct Bounds;
struct MPTParam;
Expand Down Expand Up @@ -276,14 +277,13 @@ class EBPathOptimizer
ConstrainRectangle getConstrainRectangle(
const Anchor & anchor, const int & nearest_idx,
const std::vector<geometry_msgs::msg::Point> & interpolated_points,
const cv::Mat & clearance_map,
const nav_msgs::msg::MapMetaData & map_info) const;
const cv::Mat & clearance_map, const nav_msgs::msg::MapMetaData & map_info) const;

ConstrainRectangle getConstrainRectangle(
const std::vector<std::vector<int>> & occupancy_map,
const std::vector<std::vector<geometry_msgs::msg::Point>> & occupancy_points,
const Anchor & anchor,
const nav_msgs::msg::MapMetaData & map_info, const cv::Mat & only_objects_clearance_map) const;
const Anchor & anchor, const nav_msgs::msg::MapMetaData & map_info,
const cv::Mat & only_objects_clearance_map) const;

ConstrainRectangle getConstrainRectangle(
const std::vector<autoware_planning_msgs::msg::PathPoint> & path_points, const Anchor & anchor,
Expand All @@ -300,9 +300,8 @@ class EBPathOptimizer
OccupancyMaps getOccupancyMaps(
const std::vector<std::vector<geometry_msgs::msg::Point>> & occupancy_points,
const geometry_msgs::msg::Pose & origin_pose,
const geometry_msgs::msg::Point & origin_point_in_image,
const cv::Mat & clearance_map, const cv::Mat & only_objects_clearance_map,
const nav_msgs::msg::MapMetaData & map_info) const;
const geometry_msgs::msg::Point & origin_point_in_image, const cv::Mat & clearance_map,
const cv::Mat & only_objects_clearance_map, const nav_msgs::msg::MapMetaData & map_info) const;

int getStraightLineIdx(
const std::vector<geometry_msgs::msg::Point> & interpolated_points, const int farrest_point_idx,
Expand All @@ -311,23 +310,22 @@ class EBPathOptimizer

int getEndPathIdx(
const std::vector<autoware_planning_msgs::msg::PathPoint> & path_points,
const int begin_path_idx,
const double required_trajectory_length);
const int begin_path_idx, const double required_trajectory_length);

int getEndPathIdxInsideArea(
const geometry_msgs::msg::Pose & ego_pose,
const std::vector<autoware_planning_msgs::msg::PathPoint> & path_points,
const int begin_path_idx,
const cv::Mat & drivable_area, const nav_msgs::msg::MapMetaData & map_info);
const int begin_path_idx, const cv::Mat & drivable_area,
const nav_msgs::msg::MapMetaData & map_info);

boost::optional<std::vector<ConstrainRectangle>> getPostProcessedConstrainRectangles(
const bool enable_avoidance, const std::vector<ConstrainRectangle> & object_constrains,
const std::vector<ConstrainRectangle> & road_constrains,
const std::vector<ConstrainRectangle> & only_smooth_constrains,
const std::vector<geometry_msgs::msg::Point> & interpolated_points,
const std::vector<autoware_planning_msgs::msg::PathPoint> & path_points,
const int farrest_point_idx,
const int num_fixed_points, const int straight_idx, DebugData * debug_data) const;
const int farrest_point_idx, const int num_fixed_points, const int straight_idx,
DebugData * debug_data) const;

boost::optional<std::vector<ConstrainRectangle>> getValidConstrainRectangles(
const std::vector<ConstrainRectangle> & constrains,
Expand Down Expand Up @@ -422,8 +420,8 @@ class EBPathOptimizer

std::vector<double> solveQP(const OptMode & opt_mode);

bool isFixingPathPoint(const std::vector<autoware_planning_msgs::msg::PathPoint> & path_points)
const;
bool isFixingPathPoint(
const std::vector<autoware_planning_msgs::msg::PathPoint> & path_points) const;

std::vector<autoware_planning_msgs::msg::TrajectoryPoint> calculateTrajectory(
const std::vector<geometry_msgs::msg::Point> & padded_interpolated_points,
Expand All @@ -450,4 +448,4 @@ class EBPathOptimizer
DebugData * debug_data);
};

#endif
#endif // OBSTACLE_AVOIDANCE_PLANNER__EB_PATH_OPTIMIZER_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
// 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.
#pragma once
#ifndef OBSTACLE_AVOIDANCE_PLANNER__MARKER_HELPER_HPP_
#define OBSTACLE_AVOIDANCE_PLANNER__MARKER_HELPER_HPP_

#include "visualization_msgs/msg/marker_array.hpp"

Expand Down Expand Up @@ -46,3 +47,4 @@ inline void appendMarkerArray(
marker_array->markers.push_back(marker);
}
}
#endif // OBSTACLE_AVOIDANCE_PLANNER__MARKER_HELPER_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,17 @@
* SOFTWARE.
*/

#ifndef MPTOPTIMIZER_H
#define MPTOPTIMIZER_H
#ifndef OBSTACLE_AVOIDANCE_PLANNER__MPT_OPTIMIZER_HPP_
#define OBSTACLE_AVOIDANCE_PLANNER__MPT_OPTIMIZER_HPP_

#include <memory>
#include <vector>

#include "autoware_planning_msgs/msg/path_point.hpp"
#include "autoware_planning_msgs/msg/trajectory_point.hpp"
#include "boost/optional/optional_fwd.hpp"
#include "eigen3/Eigen/Core"
#include "nav_msgs/msg/map_meta_data.hpp"

namespace cv
{
Expand Down Expand Up @@ -73,10 +80,10 @@ struct ReferencePoint
double s = 0;
geometry_msgs::msg::Pose top_pose;
geometry_msgs::msg::Pose mid_pose;
double delta_yaw_from_p1;
double delta_yaw_from_p2;
double delta_yaw_from_p1 = 0;
double delta_yaw_from_p2 = 0;
bool is_fix = false;
double fixing_lat;
double fixing_lat = 0;
};

struct Bounds
Expand Down Expand Up @@ -158,8 +165,7 @@ class MPTOptimizer
std::vector<ReferencePoint> convertToReferencePoints(
const std::vector<autoware_planning_msgs::msg::TrajectoryPoint> & points,
const geometry_msgs::msg::Pose & ego_pose,
const std::unique_ptr<Trajectories> & prev_mpt_points,
DebugData * debug_data) const;
const std::unique_ptr<Trajectories> & prev_mpt_points, DebugData * debug_data) const;

std::vector<ReferencePoint> getReferencePoints(
const geometry_msgs::msg::Pose & origin_pose, const geometry_msgs::msg::Pose & ego_pose,
Expand Down Expand Up @@ -222,7 +228,7 @@ class MPTOptimizer
const double initial_value, const CVMaps & maps,
const bool search_expanding_side = false) const;

//TODO: refactor replace all relevant funcs
// TODO(unknown): refactor replace all relevant funcs
double getClearance(
const cv::Mat & clearance_map, const geometry_msgs::msg::Point & map_point,
const nav_msgs::msg::MapMetaData & map_info, const double default_dist = 0.0) const;
Expand Down Expand Up @@ -251,4 +257,4 @@ class MPTOptimizer
const geometry_msgs::msg::Pose & ego_pose, DebugData * debug_data);
};

#endif
#endif // OBSTACLE_AVOIDANCE_PLANNER__MPT_OPTIMIZER_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,28 @@
// 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 NODE_H
#define NODE_H
#ifndef OBSTACLE_AVOIDANCE_PLANNER__NODE_HPP_
#define OBSTACLE_AVOIDANCE_PLANNER__NODE_HPP_

#include "boost/optional/optional_fwd.hpp"
#include <memory>
#include <mutex>
#include <vector>

#include "autoware_perception_msgs/msg/dynamic_object_array.hpp"
#include "autoware_planning_msgs/msg/enable_avoidance.hpp"
#include "autoware_planning_msgs/msg/is_avoidance_possible.hpp"
#include "autoware_planning_msgs/msg/path.hpp"
#include "autoware_planning_msgs/msg/path_point.hpp"
#include "autoware_planning_msgs/msg/trajectory_point.hpp"
#include "autoware_planning_msgs/msg/trajectory.hpp"
#include "autoware_perception_msgs/msg/dynamic_object_array.hpp"
#include "geometry_msgs/msg/pose.hpp"
#include "autoware_planning_msgs/msg/trajectory_point.hpp"
#include "boost/optional/optional_fwd.hpp"
#include "geometry_msgs/msg/point.hpp"
#include "geometry_msgs/msg/twist_stamped.hpp"
#include "geometry_msgs/msg/pose.hpp"
#include "geometry_msgs/msg/twist.hpp"
#include "geometry_msgs/msg/twist_stamped.hpp"
#include "nav_msgs/msg/map_meta_data.hpp"
#include "nav_msgs/msg/occupancy_grid.hpp"
#include "rclcpp/rclcpp.hpp"
#include "visualization_msgs/msg/marker_array.hpp"

namespace ros
Expand Down Expand Up @@ -123,11 +126,12 @@ class ObstacleAvoidancePlanner : public rclcpp::Node

void initialize();

//generate fine trajectory
// generate fine trajectory
std::vector<autoware_planning_msgs::msg::TrajectoryPoint> generatePostProcessedTrajectory(
const geometry_msgs::msg::Pose & ego_pose,
const std::vector<autoware_planning_msgs::msg::PathPoint> & path_points,
const std::vector<autoware_planning_msgs::msg::TrajectoryPoint> & merged_optimized_points) const;
const std::vector<autoware_planning_msgs::msg::TrajectoryPoint> & merged_optimized_points)
const;

bool needReplan(
const geometry_msgs::msg::Pose & ego_pose,
Expand Down Expand Up @@ -192,9 +196,8 @@ class ObstacleAvoidancePlanner : public rclcpp::Node

boost::optional<int> getStopIdx(
const std::vector<autoware_planning_msgs::msg::PathPoint> & path_points,
const Trajectories & trajs,
const nav_msgs::msg::MapMetaData & map_info, const cv::Mat & road_clearance_map,
DebugData * debug_data) const;
const Trajectories & trajs, const nav_msgs::msg::MapMetaData & map_info,
const cv::Mat & road_clearance_map, DebugData * debug_data) const;

void declareObstacleAvoidancePlannerParameters();

Expand All @@ -206,4 +209,4 @@ class ObstacleAvoidancePlanner : public rclcpp::Node
~ObstacleAvoidancePlanner();
};

#endif
#endif // OBSTACLE_AVOIDANCE_PLANNER__NODE_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,17 @@
// 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 PROCESS_CV_H
#define PROCESS_CV_H
#ifndef OBSTACLE_AVOIDANCE_PLANNER__PROCESS_CV_HPP_
#define OBSTACLE_AVOIDANCE_PLANNER__PROCESS_CV_HPP_

#include <vector>

#include "autoware_perception_msgs/msg/dynamic_object.hpp"
#include "autoware_planning_msgs/msg/path.hpp"
#include "geometry_msgs/msg/point32.hpp"
#include "boost/optional/optional_fwd.hpp"
#include "geometry_msgs/msg/point32.hpp"
#include "obstacle_avoidance_planner/eb_path_optimizer.hpp"
#include "opencv2/core.hpp"

namespace util
{
Expand Down Expand Up @@ -84,8 +89,7 @@ bool isAvoidingObject(
std::vector<cv::Point> getCVPolygon(
const autoware_perception_msgs::msg::DynamicObject & object, const PolygonPoints & polygon_points,
const std::vector<autoware_planning_msgs::msg::PathPoint> & path_points,
const cv::Mat & clearance_map,
const nav_msgs::msg::MapMetaData & map_info);
const cv::Mat & clearance_map, const nav_msgs::msg::MapMetaData & map_info);

std::vector<cv::Point> getDefaultCVPolygon(
const std::vector<geometry_msgs::msg::Point> & points_in_image);
Expand Down Expand Up @@ -119,13 +123,13 @@ double getDistance(

boost::optional<int> getStopIdx(
const std::vector<util::Footprint> & vehicle_footprints,
const geometry_msgs::msg::Pose & ego_pose,
const cv::Mat & road_clearance_map, const nav_msgs::msg::MapMetaData & map_info);
const geometry_msgs::msg::Pose & ego_pose, const cv::Mat & road_clearance_map,
const nav_msgs::msg::MapMetaData & map_info);

CVMaps getMaps(
const autoware_planning_msgs::msg::Path & path,
const std::vector<autoware_perception_msgs::msg::DynamicObject> & objects,
const double max_avoiding_objects_velocity_ms, const double center_line_width,
DebugData * debug_data);
} // namespace process_cv
#endif
#endif // OBSTACLE_AVOIDANCE_PLANNER__PROCESS_CV_HPP_
Loading

0 comments on commit 341a8c2

Please sign in to comment.