Skip to content

Commit

Permalink
fix(intersection): collision check considering object width (#5265)
Browse files Browse the repository at this point in the history
Signed-off-by: Takayuki Murooka <[email protected]>
  • Loading branch information
takayuki5168 authored Oct 11, 2023
1 parent 671cc96 commit 9fe7626
Showing 1 changed file with 31 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include <tier4_autoware_utils/geometry/geometry.hpp>
#include <tier4_autoware_utils/ros/uuid_helper.hpp>

#include <boost/geometry/algorithms/convex_hull.hpp>
#include <boost/geometry/algorithms/correct.hpp>
#include <boost/geometry/algorithms/intersection.hpp>

Expand All @@ -43,6 +44,32 @@ namespace behavior_velocity_planner
{
namespace bg = boost::geometry;

namespace
{
Polygon2d createOneStepPolygon(
const geometry_msgs::msg::Pose & prev_pose, const geometry_msgs::msg::Pose & next_pose,
const autoware_auto_perception_msgs::msg::Shape & shape)
{
const auto prev_poly = tier4_autoware_utils::toPolygon2d(prev_pose, shape);
const auto next_poly = tier4_autoware_utils::toPolygon2d(next_pose, shape);

Polygon2d one_step_poly;
for (const auto & point : prev_poly.outer()) {
one_step_poly.outer().push_back(point);
}
for (const auto & point : next_poly.outer()) {
one_step_poly.outer().push_back(point);
}

bg::correct(one_step_poly);

Polygon2d convex_one_step_poly;
bg::convex_hull(one_step_poly, convex_one_step_poly);

return convex_one_step_poly;
}
} // namespace

static bool isTargetCollisionVehicleType(
const autoware_auto_perception_msgs::msg::PredictedObject & object)
{
Expand Down Expand Up @@ -1313,14 +1340,14 @@ bool IntersectionModule::checkCollision(
// collision point
const auto first_itr = std::adjacent_find(
predicted_path.path.cbegin(), predicted_path.path.cend(),
[&ego_poly](const auto & a, const auto & b) {
return bg::intersects(ego_poly, LineString2d{to_bg2d(a), to_bg2d(b)});
[&ego_poly, &object](const auto & a, const auto & b) {
return bg::intersects(ego_poly, createOneStepPolygon(a, b, object.shape));
});
if (first_itr == predicted_path.path.cend()) continue;
const auto last_itr = std::adjacent_find(
predicted_path.path.crbegin(), predicted_path.path.crend(),
[&ego_poly](const auto & a, const auto & b) {
return bg::intersects(ego_poly, LineString2d{to_bg2d(a), to_bg2d(b)});
[&ego_poly, &object](const auto & a, const auto & b) {
return bg::intersects(ego_poly, createOneStepPolygon(a, b, object.shape));
});
if (last_itr == predicted_path.path.crend()) continue;

Expand Down

0 comments on commit 9fe7626

Please sign in to comment.