Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(avoidance): improve avoidance judgement logic for pedestrian & bicycle #4016

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
feat(avoidance): don't avoid pedestrian and bicycle on crosswalk
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
  • Loading branch information
satoshi-ota committed Jun 23, 2023
commit b3a3c99eba4122eaa53880b165d565c0c5873ffd
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ using behavior_path_planner::PlannerData;

bool isOnRight(const ObjectData & obj);

bool isVehicleTypeObject(const ObjectData & object);

bool isWithinCrosswalk(
const ObjectData & object,
const std::shared_ptr<const lanelet::routing::RoutingGraphContainer> & overall_graphs);

bool isTargetObjectType(
const PredictedObject & object, const std::shared_ptr<AvoidanceParameters> & parameters);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3178,6 +3178,7 @@ void AvoidanceModule::updateDebugMarker(
add(createOtherObjectsMarkerArray(data.other_objects, AvoidanceDebugFactor::OBJECT_IS_NOT_TYPE));
add(createOtherObjectsMarkerArray(data.other_objects, AvoidanceDebugFactor::NOT_PARKING_OBJECT));
add(createOtherObjectsMarkerArray(data.other_objects, std::string("MovingObject")));
add(createOtherObjectsMarkerArray(data.other_objects, std::string("CrosswalkUser")));
add(createOtherObjectsMarkerArray(data.other_objects, std::string("OutOfTargetArea")));
add(createOtherObjectsMarkerArray(data.other_objects, std::string("NotNeedAvoidance")));
add(createOtherObjectsMarkerArray(data.other_objects, std::string("LessThanExecutionThreshold")));
Expand Down
54 changes: 54 additions & 0 deletions planning/behavior_path_planner/src/utils/avoidance/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,53 @@ bool isTargetObjectType(
return parameters->object_parameters.at(t).enable;
}

bool isVehicleTypeObject(const ObjectData & object)
{
const auto t = utils::getHighestProbLabel(object.object.classification);

if (t == ObjectClassification::UNKNOWN) {
return false;
}

if (t == ObjectClassification::PEDESTRIAN) {
return false;
}

if (t == ObjectClassification::BICYCLE) {
return false;
}

return true;
}

bool isWithinCrosswalk(
const ObjectData & object,
const std::shared_ptr<const lanelet::routing::RoutingGraphContainer> & overall_graphs)
{
using Point = boost::geometry::model::d2::point_xy<double>;
using boost::geometry::correct;
using boost::geometry::within;

const auto & p = object.object.kinematics.initial_pose_with_covariance.pose.position;
const Point p_object{p.x, p.y};

constexpr int PEDESTRIAN_GRAPH_ID = 1;
const auto conflicts =
overall_graphs->conflictingInGraph(object.overhang_lanelet, PEDESTRIAN_GRAPH_ID);

for (const auto & crosswalk : conflicts) {
auto polygon = crosswalk.polygon2d().basicPolygon();

correct(polygon);

if (within(p_object, polygon)) {
return true;
}
}

return false;
}

double calcShiftLength(
const bool & is_object_on_right, const double & overhang_dist, const double & avoid_margin)
{
Expand Down Expand Up @@ -752,6 +799,7 @@ void filterTargetObjects(
const auto object_parameter = parameters->object_parameters.at(t);

if (!isTargetObjectType(o.object, parameters)) {
o.reason = AvoidanceDebugFactor::OBJECT_IS_NOT_TYPE;
data.other_objects.push_back(o);
continue;
}
Expand Down Expand Up @@ -842,6 +890,12 @@ void filterTargetObjects(
}
}

if (!isVehicleTypeObject(o) && isWithinCrosswalk(o, rh->getOverallGraphPtr())) {
o.reason = "CrosswalkUser";
data.other_objects.push_back(o);
continue;
}

// calculate avoid_margin dynamically
// NOTE: This calculation must be after calculating to_road_shoulder_distance.
const double max_avoid_margin = object_parameter.safety_buffer_lateral * o.distance_factor +
Expand Down