Skip to content

Commit

Permalink
ci(pre-commit): autofix
Browse files Browse the repository at this point in the history
  • Loading branch information
pre-commit-ci[bot] committed Sep 30, 2022
1 parent b6f1108 commit 5201e9d
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 37 deletions.
3 changes: 1 addition & 2 deletions planning/obstacle_avoidance_planner/src/node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -961,8 +961,7 @@ std::vector<TrajectoryPoint> ObstacleAvoidancePlanner::generateOptimizedTrajecto

// insert 0 velocity when trajectory is over drivable area
if (is_stopping_if_outside_drivable_area_) {
insertZeroVelocityOutsideDrivableArea(
planner_data, optimal_trajs.model_predictive_trajectory);
insertZeroVelocityOutsideDrivableArea(planner_data, optimal_trajs.model_predictive_trajectory);
}

publishDebugDataInOptimization(planner_data, optimal_trajs.model_predictive_trajectory);
Expand Down
73 changes: 38 additions & 35 deletions planning/obstacle_avoidance_planner/src/utils/cv_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,22 +18,22 @@
#include "tf2/utils.h"
#include "tier4_autoware_utils/system/stop_watch.hpp"

#include <grid_map_cv/GridMapCvConverter.hpp>
#include <grid_map_ros/GridMapRosConverter.hpp>

#include "autoware_auto_perception_msgs/msg/predicted_object.hpp"
#include "nav_msgs/msg/occupancy_grid.hpp"

#include "boost/optional.hpp"
#include <deque>

#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>

#include <algorithm>
#include <deque>
#include <limits>
#include <vector>

#include <grid_map_cv/GridMapCvConverter.hpp>
#include <grid_map_ros/GridMapRosConverter.hpp>

namespace bg = boost::geometry;
using point = bg::model::d2::point_xy<double>;
using polygon = bg::model::polygon<point>;
Expand Down Expand Up @@ -436,40 +436,43 @@ bool isOutsideDrivableAreaFromRectangleFootprint(
footprint.outer().push_back(fp);
const auto top_right_pos =
tier4_autoware_utils::calcOffsetPose(traj_point.pose, base_to_front, half_width, 0.0).position;
fp = {top_right_pos.x, top_right_pos.y};
footprint.outer().push_back(fp);
fp = {top_right_pos.x, top_right_pos.y};
footprint.outer().push_back(fp);
const auto bottom_right_pos =
tier4_autoware_utils::calcOffsetPose(traj_point.pose, -base_to_rear, half_width, 0.0).position;
fp = {bottom_right_pos.x, bottom_right_pos.y};
footprint.outer().push_back(fp);
fp = {bottom_right_pos.x, bottom_right_pos.y};
footprint.outer().push_back(fp);
const auto bottom_left_pos =
tier4_autoware_utils::calcOffsetPose(traj_point.pose, -base_to_rear, -half_width, 0.0).position;
fp = {bottom_left_pos.x, bottom_left_pos.y};

footprint.outer().push_back(fp);

std::vector<point> result;
cv::Mat cv_image;
grid_map::GridMap grid_map;
grid_map::GridMapRosConverter::fromOccupancyGrid(drivable_area, "layer", grid_map);
grid_map::GridMapCvConverter::toImage<unsigned char, 1>(grid_map, "layer", CV_8UC1, 0, 100, cv_image);
cv::dilate(cv_image, cv_image, cv::Mat(), cv::Point(-1, -1), 2);
cv::erode(cv_image, cv_image, cv::Mat(), cv::Point(-1, -1), 2);
std::vector<std::vector<cv::Point>> contours;
cv::findContours(cv_image, contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
const auto & info = drivable_area.info;
for (const auto & contour : contours) {
point p;
for (const auto & point : contour) {
p = {(info.width - 1.0 - point.y) * info.resolution + info.origin.position.x, (info.height - 1.0 - point.x) * info.resolution + info.origin.position.y};
}
drivable_area_polygon.outer().push_back(p);
}
bg::intersection(footprint, drivable_area_polygon, result);

if (result.size == 1) {
return true;
}
fp = {bottom_left_pos.x, bottom_left_pos.y};

footprint.outer().push_back(fp);

std::vector<point> result;
cv::Mat cv_image;
grid_map::GridMap grid_map;
grid_map::GridMapRosConverter::fromOccupancyGrid(drivable_area, "layer", grid_map);
grid_map::GridMapCvConverter::toImage<unsigned char, 1>(
grid_map, "layer", CV_8UC1, 0, 100, cv_image);
cv::dilate(cv_image, cv_image, cv::Mat(), cv::Point(-1, -1), 2);
cv::erode(cv_image, cv_image, cv::Mat(), cv::Point(-1, -1), 2);
std::vector<std::vector<cv::Point>> contours;
cv::findContours(cv_image, contours, CV_RETR_LIST, CV_CHAIN_APPROX_SIMPLE);
const auto & info = drivable_area.info;
for (const auto & contour : contours) {
point p;
for (const auto & point : contour) {
p = {
(info.width - 1.0 - point.y) * info.resolution + info.origin.position.x,
(info.height - 1.0 - point.x) * info.resolution + info.origin.position.y};
}
drivable_area_polygon.outer().push_back(p);
}
bg::intersection(footprint, drivable_area_polygon, result);

if (result.size == 1) {
return true;
}

return false;
}
Expand Down

0 comments on commit 5201e9d

Please sign in to comment.