Skip to content

Commit

Permalink
feat(avoidance): improve avoidance judgement logic for pedestrian & b…
Browse files Browse the repository at this point in the history
…icycle (autowarefoundation#4016)

* feat(avoidance): don't avoid pedestrian and bicycle on crosswalk

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* feat(avoidance): avoid pedestrian/bicycle near centerline

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* feat(utils): use geometry distance

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

* chore(avoidance): add comment

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>

---------

Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
  • Loading branch information
satoshi-ota committed Jun 23, 2023
1 parent 1a78c47 commit fbb9a20
Show file tree
Hide file tree
Showing 3 changed files with 74 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ struct PolygonPoint

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 @@ -3133,6 +3133,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
67 changes: 67 additions & 0 deletions planning/behavior_path_planner/src/utils/avoidance/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,54 @@ 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>;

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

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

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

boost::geometry::correct(polygon);

// ignore objects around the crosswalk
if (boost::geometry::distance(p_object, polygon) < THRESHOLD) {
return true;
}
}

return false;
}

double calcShiftLength(
const bool & is_object_on_right, const double & overhang_dist, const double & avoid_margin)
{
Expand Down Expand Up @@ -1078,6 +1126,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 @@ -1215,6 +1264,24 @@ void filterTargetObjects(
}
}

// for non vehicle type object
if (!isVehicleTypeObject(o)) {
if (isWithinCrosswalk(o, rh->getOverallGraphPtr())) {
// avoidance module ignore pedestrian and bicycle around crosswalk
o.reason = "CrosswalkUser";
data.other_objects.push_back(o);
} else {
// if there is no crosswalk near the object, avoidance module avoids pedestrian and bicycle
// no matter how it is shifted.
o.last_seen = now;
o.avoid_margin = avoid_margin;
data.target_objects.push_back(o);
}
continue;
}

// from here condition check for vehicle type objects.

// force avoidance for stopped vehicle
{
const auto to_traffic_light =
Expand Down

0 comments on commit fbb9a20

Please sign in to comment.