diff --git a/common/tier4_autoware_utils/include/tier4_autoware_utils/geometry/boost_polygon_utils.hpp b/common/tier4_autoware_utils/include/tier4_autoware_utils/geometry/boost_polygon_utils.hpp index 835f0c37d3031..8bbfe681fa3ae 100644 --- a/common/tier4_autoware_utils/include/tier4_autoware_utils/geometry/boost_polygon_utils.hpp +++ b/common/tier4_autoware_utils/include/tier4_autoware_utils/geometry/boost_polygon_utils.hpp @@ -18,7 +18,6 @@ #include "tier4_autoware_utils/geometry/boost_geometry.hpp" #include "autoware_auto_perception_msgs/msg/predicted_object.hpp" -// #include "geometry_msgs/msg/point32.hpp" #include "geometry_msgs/msg/pose.hpp" #include @@ -35,6 +34,7 @@ geometry_msgs::msg::Polygon rotatePolygon( const geometry_msgs::msg::Polygon & polygon, const double & angle); Polygon2d toPolygon2d( const geometry_msgs::msg::Pose & pose, const autoware_auto_perception_msgs::msg::Shape & shape); +Polygon2d toPolygon2d(const autoware_auto_perception_msgs::msg::PredictedObject & object); double getArea(const autoware_auto_perception_msgs::msg::Shape & shape); } // namespace tier4_autoware_utils diff --git a/common/tier4_autoware_utils/src/geometry/boost_polygon_utils.cpp b/common/tier4_autoware_utils/src/geometry/boost_polygon_utils.cpp index f9ba0f537f07f..b54f888ad0ae1 100644 --- a/common/tier4_autoware_utils/src/geometry/boost_polygon_utils.cpp +++ b/common/tier4_autoware_utils/src/geometry/boost_polygon_utils.cpp @@ -167,6 +167,13 @@ Polygon2d toPolygon2d( return isClockwise(polygon) ? polygon : inverseClockwise(polygon); } +tier4_autoware_utils::Polygon2d toPolygon2d( + const autoware_auto_perception_msgs::msg::PredictedObject & object) +{ + return tier4_autoware_utils::toPolygon2d( + object.kinematics.initial_pose_with_covariance.pose, object.shape); +} + double getArea(const autoware_auto_perception_msgs::msg::Shape & shape) { if (shape.type == autoware_auto_perception_msgs::msg::Shape::BOUNDING_BOX) { diff --git a/planning/behavior_velocity_planner/include/scene_module/intersection/scene_intersection.hpp b/planning/behavior_velocity_planner/include/scene_module/intersection/scene_intersection.hpp index bffd25f1f5002..3cb169c981e0f 100644 --- a/planning/behavior_velocity_planner/include/scene_module/intersection/scene_intersection.hpp +++ b/planning/behavior_velocity_planner/include/scene_module/intersection/scene_intersection.hpp @@ -239,24 +239,6 @@ class IntersectionModule : public SceneModuleInterface bool isTargetStuckVehicleType( const autoware_auto_perception_msgs::msg::PredictedObject & object) const; - /** - * @brief convert object to footprint polygon - * @param object detected object - * @return 2d polygon of the object footprint - */ - Polygon2d toFootprintPolygon( - const autoware_auto_perception_msgs::msg::PredictedObject & object) const; - - /** - * @brief convert predicted object to footprint polygon - * @param object detected object - * @param predicted_pose predicted object pose - * @return 2d polygon of the object footprint - */ - Polygon2d toPredictedFootprintPolygon( - const autoware_auto_perception_msgs::msg::PredictedObject & object, - const geometry_msgs::msg::Pose & predicted_pose) const; - /** * @brief Whether target tier4_api_msgs::Intersection::status is valid or not * @param target_status target tier4_api_msgs::Intersection::status diff --git a/planning/behavior_velocity_planner/include/scene_module/run_out/scene.hpp b/planning/behavior_velocity_planner/include/scene_module/run_out/scene.hpp index a6e99c6d503c3..bb6fc7c237418 100644 --- a/planning/behavior_velocity_planner/include/scene_module/run_out/scene.hpp +++ b/planning/behavior_velocity_planner/include/scene_module/run_out/scene.hpp @@ -90,15 +90,15 @@ class RunOutModule : public SceneModuleInterface const float velocity_mps) const; bool checkCollisionWithShape( - const tier4_autoware_utils::Polygon2d & vehicle_polygon, const PoseWithRange pose_with_range, - const Shape & shape, std::vector & collision_points) const; + const Polygon2d & vehicle_polygon, const PoseWithRange pose_with_range, const Shape & shape, + std::vector & collision_points) const; bool checkCollisionWithCylinder( - const tier4_autoware_utils::Polygon2d & vehicle_polygon, const PoseWithRange pose_with_range, - const float radius, std::vector & collision_points) const; + const Polygon2d & vehicle_polygon, const PoseWithRange pose_with_range, const float radius, + std::vector & collision_points) const; bool checkCollisionWithBoundingBox( - const tier4_autoware_utils::Polygon2d & vehicle_polygon, const PoseWithRange pose_with_range, + const Polygon2d & vehicle_polygon, const PoseWithRange pose_with_range, const geometry_msgs::msg::Vector3 & dimension, std::vector & collision_points) const; diff --git a/planning/behavior_velocity_planner/include/utilization/boost_geometry_helper.hpp b/planning/behavior_velocity_planner/include/utilization/boost_geometry_helper.hpp index ffbab904aaf85..51296737ea768 100644 --- a/planning/behavior_velocity_planner/include/utilization/boost_geometry_helper.hpp +++ b/planning/behavior_velocity_planner/include/utilization/boost_geometry_helper.hpp @@ -15,6 +15,8 @@ #ifndef UTILIZATION__BOOST_GEOMETRY_HELPER_HPP_ #define UTILIZATION__BOOST_GEOMETRY_HELPER_HPP_ +#include + #include #include #include @@ -33,7 +35,6 @@ #include #include #include -#include #include #include @@ -60,16 +61,16 @@ BOOST_GEOMETRY_REGISTER_POINT_3D( namespace behavior_velocity_planner { -using Point2d = boost::geometry::model::d2::point_xy; -using Segment2d = boost::geometry::model::segment; -using LineString2d = boost::geometry::model::linestring; -using Polygon2d = - boost::geometry::model::polygon; // counter-clockwise, open +namespace bg = boost::geometry; + +using Point2d = tier4_autoware_utils::Point2d; +using LineString2d = tier4_autoware_utils::LineString2d; +using Polygon2d = tier4_autoware_utils::Polygon2d; template Point2d to_bg2d(const T & p) { - return Point2d(boost::geometry::get<0>(p), boost::geometry::get<1>(p)); + return Point2d(bg::get<0>(p), bg::get<1>(p)); } template @@ -82,17 +83,6 @@ LineString2d to_bg2d(const std::vector & vec) return ps; } -inline Polygon2d linestring2polygon(const LineString2d & line_string) -{ - Polygon2d polygon; - - for (const auto & p : line_string) { - polygon.outer().push_back(p); - } - - return polygon; -} - inline Polygon2d lines2polygon(const LineString2d & left_line, const LineString2d & right_line) { Polygon2d polygon; @@ -107,78 +97,11 @@ inline Polygon2d lines2polygon(const LineString2d & left_line, const LineString2 polygon.outer().push_back(*itr); } + bg::correct(polygon); return polygon; } -inline Polygon2d obj2polygon( - const geometry_msgs::msg::Pose & pose, const geometry_msgs::msg::Vector3 & shape) -{ - // rename - const double x = pose.position.x; - const double y = pose.position.y; - const double h = shape.x; - const double w = shape.y; - const double yaw = tf2::getYaw(pose.orientation); - - // create base polygon - Polygon2d obj_poly; - boost::geometry::exterior_ring(obj_poly) = boost::assign::list_of(h / 2.0, w / 2.0)( - -h / 2.0, w / 2.0)(-h / 2.0, -w / 2.0)(h / 2.0, -w / 2.0)(h / 2.0, w / 2.0); - - // rotate polygon(yaw) - boost::geometry::strategy::transform::rotate_transformer - rotate(-yaw); // anti-clockwise -> :clockwise rotation - Polygon2d rotate_obj_poly; - boost::geometry::transform(obj_poly, rotate_obj_poly, rotate); - - // translate polygon(x, y) - boost::geometry::strategy::transform::translate_transformer translate(x, y); - Polygon2d translate_obj_poly; - boost::geometry::transform(rotate_obj_poly, translate_obj_poly, translate); - return translate_obj_poly; -} - -inline double calcOverlapAreaRate(const Polygon2d & target, const Polygon2d & base) -{ - /* OverlapAreaRate: common area(target && base) / target area */ - - if (boost::geometry::within(target, base)) { - // target is within base, common area = target area - return 1.0; - } - - if (!boost::geometry::intersects(target, base)) { - // target and base has not intersect area - return 0.0; - } - - // calculate intersect polygon - std::vector intersects; - boost::geometry::intersection(target, base, intersects); - - // 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 - const double common_area = target_area - intersect_area; - - return common_area / target_area; -} - -inline std::vector makeSegments(const LineString2d & ls) -{ - std::vector segments; - for (size_t i = 0; i < ls.size(); ++i) { - segments.emplace_back(ls.at(i), ls.at(i + 1)); - } - return segments; -} - -inline geometry_msgs::msg::Polygon toGeomMsg(const Polygon2d & polygon) +inline geometry_msgs::msg::Polygon toGeomPoly(const Polygon2d & polygon) { geometry_msgs::msg::Polygon polygon_msg; geometry_msgs::msg::Point32 point_msg; @@ -189,27 +112,6 @@ inline geometry_msgs::msg::Polygon toGeomMsg(const Polygon2d & polygon) } return polygon_msg; } - -inline Polygon2d toBoostPoly(const geometry_msgs::msg::Polygon & polygon) -{ - Polygon2d boost_poly; - for (const auto & point : polygon.points) { - const Point2d point2d(point.x, point.y); - boost_poly.outer().push_back(point2d); - } - return boost_poly; -} - -inline Polygon2d toBoostPoly(const lanelet::BasicPolygon2d & polygon) -{ - Polygon2d boost_poly; - for (const auto & vec : polygon) { - const Point2d point2d(vec.x(), vec.y()); - boost_poly.outer().push_back(point2d); - } - - return boost_poly; -} } // namespace behavior_velocity_planner #endif // UTILIZATION__BOOST_GEOMETRY_HELPER_HPP_ diff --git a/planning/behavior_velocity_planner/include/utilization/util.hpp b/planning/behavior_velocity_planner/include/utilization/util.hpp index c05a8819e9267..22c75ddeaab50 100644 --- a/planning/behavior_velocity_planner/include/utilization/util.hpp +++ b/planning/behavior_velocity_planner/include/utilization/util.hpp @@ -79,7 +79,6 @@ struct PointWithSearchRangeIndex using geometry_msgs::msg::Pose; using BasicPolygons2d = std::vector; using Polygons2d = std::vector; -using Point2d = boost::geometry::model::d2::point_xy; using autoware_auto_perception_msgs::msg::PredictedObject; using autoware_auto_perception_msgs::msg::PredictedObjects; using autoware_auto_perception_msgs::msg::Shape; @@ -162,7 +161,6 @@ geometry_msgs::msg::Pose transformAbsCoordinate2D( const geometry_msgs::msg::Pose & relative, const geometry_msgs::msg::Pose & origin); SearchRangeIndex getPathIndexRangeIncludeLaneId(const PathWithLaneId & path, const int64_t lane_id); -Polygon2d toFootprintPolygon(const PredictedObject & object); bool isAheadOf(const geometry_msgs::msg::Pose & target, const geometry_msgs::msg::Pose & origin); geometry_msgs::msg::Pose getAheadPose( const size_t start_idx, const double ahead_dist, diff --git a/planning/behavior_velocity_planner/src/scene_module/intersection/scene_intersection.cpp b/planning/behavior_velocity_planner/src/scene_module/intersection/scene_intersection.cpp index fee2eb22b3fef..1e326f4975cd0 100644 --- a/planning/behavior_velocity_planner/src/scene_module/intersection/scene_intersection.cpp +++ b/planning/behavior_velocity_planner/src/scene_module/intersection/scene_intersection.cpp @@ -293,7 +293,7 @@ bool IntersectionModule::checkCollision( ego_lane_with_next_lane, tier4_autoware_utils::getPose(path.points.at(closest_idx).point), &closest_lanelet); - debug_data_.ego_lane_polygon = toGeomMsg(ego_poly); + debug_data_.ego_lane_polygon = toGeomPoly(ego_poly); /* extract target objects */ autoware_auto_perception_msgs::msg::PredictedObjects target_objects; @@ -403,12 +403,14 @@ bool IntersectionModule::checkCollision( polygon.outer().emplace_back(polygon.outer().front()); - debug_data_.candidate_collision_ego_lane_polygon = toGeomMsg(polygon); + bg::correct(polygon); + + debug_data_.candidate_collision_ego_lane_polygon = toGeomPoly(polygon); for (auto itr = first_itr; itr != last_itr.base(); ++itr) { - const auto footprint_polygon = toPredictedFootprintPolygon(object, *itr); + const auto footprint_polygon = tier4_autoware_utils::toPolygon2d(*itr, object.shape); debug_data_.candidate_collision_object_polygons.emplace_back( - toGeomMsg(footprint_polygon)); + toGeomPoly(footprint_polygon)); if (bg::intersects(polygon, footprint_polygon)) { collision_detected = true; break; @@ -464,6 +466,7 @@ Polygon2d IntersectionModule::generateEgoIntersectionLanePolygon( } polygon.outer().emplace_back(polygon.outer().front()); + bg::correct(polygon); return polygon; } @@ -538,7 +541,7 @@ bool IntersectionModule::checkStuckVehicleInIntersection( const autoware_auto_perception_msgs::msg::PredictedObjects::ConstSharedPtr objects_ptr, const Polygon2d & stuck_vehicle_detect_area) const { - debug_data_.stuck_vehicle_detect_area = toGeomMsg(stuck_vehicle_detect_area); + debug_data_.stuck_vehicle_detect_area = toGeomPoly(stuck_vehicle_detect_area); for (const auto & object : objects_ptr->objects) { if (!isTargetStuckVehicleType(object)) { @@ -550,7 +553,7 @@ bool IntersectionModule::checkStuckVehicleInIntersection( } // check if the footprint is in the stuck detect area - const Polygon2d obj_footprint = toFootprintPolygon(object); + const auto obj_footprint = tier4_autoware_utils::toPolygon2d(object); const bool is_in_stuck_area = !bg::disjoint(obj_footprint, stuck_vehicle_detect_area); if (is_in_stuck_area) { RCLCPP_DEBUG(logger_, "stuck vehicle found."); @@ -561,27 +564,6 @@ bool IntersectionModule::checkStuckVehicleInIntersection( return false; } -Polygon2d IntersectionModule::toFootprintPolygon( - const autoware_auto_perception_msgs::msg::PredictedObject & object) const -{ - Polygon2d obj_footprint; - if (object.shape.type == autoware_auto_perception_msgs::msg::Shape::POLYGON) { - obj_footprint = toBoostPoly(object.shape.footprint); - } else { - // cylinder type is treated as square-polygon - obj_footprint = - obj2polygon(object.kinematics.initial_pose_with_covariance.pose, object.shape.dimensions); - } - return obj_footprint; -} - -Polygon2d IntersectionModule::toPredictedFootprintPolygon( - const autoware_auto_perception_msgs::msg::PredictedObject & object, - const geometry_msgs::msg::Pose & predicted_pose) const -{ - return obj2polygon(predicted_pose, object.shape.dimensions); -} - bool IntersectionModule::isTargetCollisionVehicleType( const autoware_auto_perception_msgs::msg::PredictedObject & object) const { @@ -794,7 +776,7 @@ bool IntersectionModule::checkFrontVehicleDeceleration( predicted_object.kinematics.initial_pose_with_covariance.pose.position = stopping_point; predicted_object.kinematics.initial_pose_with_covariance.pose.orientation = tier4_autoware_utils::createQuaternionFromRPY(0, 0, lane_yaw); - Polygon2d predicted_obj_footprint = toFootprintPolygon(predicted_object); + auto predicted_obj_footprint = tier4_autoware_utils::toPolygon2d(predicted_object); const bool is_in_stuck_area = !bg::disjoint(predicted_obj_footprint, stuck_vehicle_detect_area); debug_data_.predicted_obj_pose.position = stopping_point; debug_data_.predicted_obj_pose.orientation = diff --git a/planning/behavior_velocity_planner/src/scene_module/no_stopping_area/scene_no_stopping_area.cpp b/planning/behavior_velocity_planner/src/scene_module/no_stopping_area/scene_no_stopping_area.cpp index b753fd36b8b5d..0472cc4aae720 100644 --- a/planning/behavior_velocity_planner/src/scene_module/no_stopping_area/scene_no_stopping_area.cpp +++ b/planning/behavior_velocity_planner/src/scene_module/no_stopping_area/scene_no_stopping_area.cpp @@ -162,8 +162,8 @@ bool NoStoppingAreaModule::modifyPathVelocity( setSafe(true); return true; } - debug_data_.stuck_vehicle_detect_area = toGeomMsg(stuck_vehicle_detect_area); - debug_data_.stop_line_detect_area = toGeomMsg(stop_line_detect_area); + debug_data_.stuck_vehicle_detect_area = toGeomPoly(stuck_vehicle_detect_area); + debug_data_.stop_line_detect_area = toGeomPoly(stop_line_detect_area); // Find stuck vehicle in no stopping area const bool is_entry_prohibited_by_stuck_vehicle = checkStuckVehiclesInNoStoppingArea(stuck_vehicle_detect_area, predicted_obj_arr_ptr); @@ -230,11 +230,11 @@ bool NoStoppingAreaModule::checkStuckVehiclesInNoStoppingArea( continue; // not stop vehicle } // check if the footprint is in the stuck detect area - const Polygon2d obj_footprint = planning_utils::toFootprintPolygon(object); + const Polygon2d obj_footprint = tier4_autoware_utils::toPolygon2d(object); const bool is_in_stuck_area = !bg::disjoint(obj_footprint, poly); if (is_in_stuck_area) { RCLCPP_DEBUG(logger_, "stuck vehicle found."); - for (const auto p : obj_footprint.outer()) { + for (const auto & p : obj_footprint.outer()) { geometry_msgs::msg::Point point; point.x = p.x(); point.y = p.y(); diff --git a/planning/behavior_velocity_planner/src/scene_module/occlusion_spot/grid_utils.cpp b/planning/behavior_velocity_planner/src/scene_module/occlusion_spot/grid_utils.cpp index fa02d33fa0198..66d82418a0520 100644 --- a/planning/behavior_velocity_planner/src/scene_module/occlusion_spot/grid_utils.cpp +++ b/planning/behavior_velocity_planner/src/scene_module/occlusion_spot/grid_utils.cpp @@ -36,6 +36,8 @@ Polygon2d pointsToPoly(const Point2d p0, const Point2d p1, const double radius) line_poly.outer().emplace_back(p0.x() - r * sin(angle), p0.y() + r * cos(angle)); // std::cout << boost::geometry::wkt(line_poly) << std::endl; // std::cout << boost::geometry::wkt(line) << std::endl; + + bg::correct(line_poly); return line_poly; } @@ -173,6 +175,8 @@ Polygon2d generateOccupancyPolygon(const nav_msgs::msg::MapMetaData & info, cons poly.outer().emplace_back(to_bg2d(calcOffsetPose(info.origin, r, 0, 0).position)); poly.outer().emplace_back(to_bg2d(calcOffsetPose(info.origin, r, r, 0).position)); poly.outer().emplace_back(to_bg2d(calcOffsetPose(info.origin, 0, r, 0).position)); + + bg::correct(poly); return poly; } diff --git a/planning/behavior_velocity_planner/src/scene_module/occlusion_spot/occlusion_spot_utils.cpp b/planning/behavior_velocity_planner/src/scene_module/occlusion_spot/occlusion_spot_utils.cpp index 58cc2d2c6f813..3000fe6d1e042 100644 --- a/planning/behavior_velocity_planner/src/scene_module/occlusion_spot/occlusion_spot_utils.cpp +++ b/planning/behavior_velocity_planner/src/scene_module/occlusion_spot/occlusion_spot_utils.cpp @@ -209,9 +209,9 @@ void categorizeVehicles( stuck_vehicle_foot_prints.clear(); for (const auto & vehicle : vehicles) { if (isMovingVehicle(vehicle, stuck_vehicle_vel)) { - moving_vehicle_foot_prints.emplace_back(planning_utils::toFootprintPolygon(vehicle)); + moving_vehicle_foot_prints.emplace_back(tier4_autoware_utils::toPolygon2d(vehicle)); } else if (isStuckVehicle(vehicle, stuck_vehicle_vel)) { - stuck_vehicle_foot_prints.emplace_back(planning_utils::toFootprintPolygon(vehicle)); + stuck_vehicle_foot_prints.emplace_back(tier4_autoware_utils::toPolygon2d(vehicle)); } } return; @@ -219,7 +219,7 @@ void categorizeVehicles( ArcCoordinates getOcclusionPoint(const PredictedObject & obj, const ConstLineString2d & ll_string) { - Polygon2d poly = planning_utils::toFootprintPolygon(obj); + const auto poly = tier4_autoware_utils::toPolygon2d(obj); std::deque arcs; for (const auto & p : poly.outer()) { lanelet::BasicPoint2d obj_p = {p.x(), p.y()}; @@ -342,7 +342,7 @@ std::vector filterVehiclesByDetectionArea( // stuck points by predicted objects for (const auto & object : objs) { // check if the footprint is in the stuck detect area - const Polygon2d obj_footprint = planning_utils::toFootprintPolygon(object); + const auto obj_footprint = tier4_autoware_utils::toPolygon2d(object); for (const auto & p : polys) { if (!bg::disjoint(obj_footprint, p)) { filtered_obj.emplace_back(object); diff --git a/planning/behavior_velocity_planner/src/scene_module/run_out/scene.cpp b/planning/behavior_velocity_planner/src/scene_module/run_out/scene.cpp index cf8c78d9e8930..9f629927036f8 100644 --- a/planning/behavior_velocity_planner/src/scene_module/run_out/scene.cpp +++ b/planning/behavior_velocity_planner/src/scene_module/run_out/scene.cpp @@ -412,8 +412,8 @@ boost::optional RunOutModule::calcPredictedObstaclePos } bool RunOutModule::checkCollisionWithShape( - const tier4_autoware_utils::Polygon2d & vehicle_polygon, const PoseWithRange pose_with_range, - const Shape & shape, std::vector & collision_points) const + const Polygon2d & vehicle_polygon, const PoseWithRange pose_with_range, const Shape & shape, + std::vector & collision_points) const { bool collision_detected = false; switch (shape.type) { @@ -439,8 +439,8 @@ bool RunOutModule::checkCollisionWithShape( } bool RunOutModule::checkCollisionWithCylinder( - const tier4_autoware_utils::Polygon2d & vehicle_polygon, const PoseWithRange pose_with_range, - const float radius, std::vector & collision_points) const + const Polygon2d & vehicle_polygon, const PoseWithRange pose_with_range, const float radius, + std::vector & collision_points) const { // create bounding box for min and max velocity point const auto bounding_box_for_points = @@ -504,7 +504,7 @@ std::vector RunOutModule::createBoundingBoxForRangedP } bool RunOutModule::checkCollisionWithBoundingBox( - const tier4_autoware_utils::Polygon2d & vehicle_polygon, const PoseWithRange pose_with_range, + const Polygon2d & vehicle_polygon, const PoseWithRange pose_with_range, const geometry_msgs::msg::Vector3 & dimension, std::vector & collision_points) const { diff --git a/planning/behavior_velocity_planner/src/scene_module/run_out/utils.cpp b/planning/behavior_velocity_planner/src/scene_module/run_out/utils.cpp index 2c035705afd05..0f6921691025f 100644 --- a/planning/behavior_velocity_planner/src/scene_module/run_out/utils.cpp +++ b/planning/behavior_velocity_planner/src/scene_module/run_out/utils.cpp @@ -195,6 +195,7 @@ Polygon2d createBoostPolyFromMsg(const std::vector & const auto & first_point = input_poly.front(); bg_poly.outer().emplace_back(bg::make(first_point.x, first_point.y)); + bg::correct(bg_poly); return bg_poly; } diff --git a/planning/behavior_velocity_planner/src/utilization/util.cpp b/planning/behavior_velocity_planner/src/utilization/util.cpp index 1ed17cd4be341..9179a53ab854e 100644 --- a/planning/behavior_velocity_planner/src/utilization/util.cpp +++ b/planning/behavior_velocity_planner/src/utilization/util.cpp @@ -227,19 +227,6 @@ void insertVelocity( setVelocityFromIndex(insert_index, v, &path); } -Polygon2d toFootprintPolygon(const PredictedObject & object) -{ - Polygon2d obj_footprint; - if (object.shape.type == Shape::POLYGON) { - obj_footprint = toBoostPoly(object.shape.footprint); - } else { - // cylinder type is treated as square-polygon - obj_footprint = - obj2polygon(object.kinematics.initial_pose_with_covariance.pose, object.shape.dimensions); - } - return obj_footprint; -} - bool isAheadOf(const geometry_msgs::msg::Pose & target, const geometry_msgs::msg::Pose & origin) { geometry_msgs::msg::Pose p = planning_utils::transformRelCoordinate2D(target, origin); @@ -296,6 +283,8 @@ Polygon2d generatePathPolygon( const double y = path.points.at(i).point.pose.position.y + width * std::cos(yaw); ego_area.outer().push_back(Point2d(x, y)); } + + bg::correct(ego_area); return ego_area; } diff --git a/planning/behavior_velocity_planner/test/src/test_grid_utils.cpp b/planning/behavior_velocity_planner/test/src/test_grid_utils.cpp index 441d6b94bbc03..19e9b5f37b028 100644 --- a/planning/behavior_velocity_planner/test/src/test_grid_utils.cpp +++ b/planning/behavior_velocity_planner/test/src/test_grid_utils.cpp @@ -43,6 +43,7 @@ using behavior_velocity_planner::Point2d; using behavior_velocity_planner::Polygon2d; using behavior_velocity_planner::grid_utils::occlusion_cost_value::OCCUPIED; using behavior_velocity_planner::grid_utils::occlusion_cost_value::UNKNOWN; +namespace bg = boost::geometry; Polygon2d pointsToPoly(const Point2d p0, const Point2d p1, const double radius) { @@ -57,6 +58,8 @@ Polygon2d pointsToPoly(const Point2d p0, const Point2d p1, const double radius) line_poly.outer().emplace_back(p0.x() - r * sin(angle), p0.y() + r * cos(angle)); // std::cout << boost::geometry::wkt(line_poly) << std::endl; // std::cout << boost::geometry::wkt(line) << std::endl; + + bg::correct(line_poly); return line_poly; } diff --git a/planning/behavior_velocity_planner/test/src/test_utilization.cpp b/planning/behavior_velocity_planner/test/src/test_utilization.cpp index 1a9d4cdbf4aed..742cccecb9773 100644 --- a/planning/behavior_velocity_planner/test/src/test_utilization.cpp +++ b/planning/behavior_velocity_planner/test/src/test_utilization.cpp @@ -33,14 +33,6 @@ std::cerr << ss.str() << std::endl; \ } -TEST(to_footprint_polygon, nominal) -{ - using behavior_velocity_planner::planning_utils::toFootprintPolygon; - autoware_auto_perception_msgs::msg::PredictedObject obj = test::generatePredictedObject(0.0); - auto poly = toFootprintPolygon(obj); - EXPECT_TRUE(true); -} - TEST(is_ahead_of, nominal) { using behavior_velocity_planner::planning_utils::isAheadOf;