Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit f195ba4

Browse files
committedFeb 23, 2024
feat(avoidance): consider objects on shift side lane (autowarefoundation#6252)
* fix(avoidance): check safety for only moving objects Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com> * feat(avoidance): consider ignore object in avoid margin calculation Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com> * fix(avoidance): use nearest overhang point Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com> --------- Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
1 parent 62593b1 commit f195ba4

File tree

8 files changed

+138
-119
lines changed

8 files changed

+138
-119
lines changed
 

‎planning/behavior_path_avoidance_by_lane_change_module/src/scene.cpp

+6-16
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,6 @@
3737

3838
namespace behavior_path_planner
3939
{
40-
namespace
41-
{
42-
lanelet::BasicLineString3d toLineString3d(const std::vector<Point> & bound)
43-
{
44-
lanelet::BasicLineString3d ret{};
45-
std::for_each(
46-
bound.begin(), bound.end(), [&](const auto & p) { ret.emplace_back(p.x, p.y, p.z); });
47-
return ret;
48-
}
49-
} // namespace
5040
AvoidanceByLaneChange::AvoidanceByLaneChange(
5141
const std::shared_ptr<LaneChangeParameters> & parameters,
5242
std::shared_ptr<AvoidanceByLCParameters> avoidance_parameters)
@@ -237,10 +227,10 @@ AvoidancePlanningData AvoidanceByLaneChange::calcAvoidancePlanningData(
237227
// calc drivable bound
238228
const auto shorten_lanes =
239229
utils::cutOverlappedLanes(data.reference_path_rough, data.drivable_lanes);
240-
data.left_bound = toLineString3d(utils::calcBound(
241-
data.reference_path_rough, planner_data_, shorten_lanes, false, false, false, true));
242-
data.right_bound = toLineString3d(utils::calcBound(
243-
data.reference_path_rough, planner_data_, shorten_lanes, false, false, false, false));
230+
data.left_bound = utils::calcBound(
231+
data.reference_path_rough, planner_data_, shorten_lanes, false, false, false, true);
232+
data.right_bound = utils::calcBound(
233+
data.reference_path_rough, planner_data_, shorten_lanes, false, false, false, false);
244234

245235
// get related objects from dynamic_objects, and then separates them as target objects and non
246236
// target objects
@@ -340,8 +330,8 @@ ObjectData AvoidanceByLaneChange::createObjectData(
340330
: Direction::RIGHT;
341331

342332
// Find the footprint point closest to the path, set to object_data.overhang_distance.
343-
object_data.overhang_dist = utils::avoidance::calcEnvelopeOverhangDistance(
344-
object_data, data.reference_path, object_data.overhang_pose.position);
333+
object_data.overhang_points =
334+
utils::avoidance::calcEnvelopeOverhangDistance(object_data, data.reference_path);
345335

346336
// Check whether the the ego should avoid the object.
347337
const auto & vehicle_width = planner_data_->parameters.vehicle_width;

‎planning/behavior_path_avoidance_module/include/behavior_path_avoidance_module/data_structs.hpp

+8-15
Original file line numberDiff line numberDiff line change
@@ -336,12 +336,8 @@ struct ObjectData // avoidance target
336336
{
337337
ObjectData() = default;
338338

339-
ObjectData(PredictedObject obj, double lat, double lon, double len, double overhang)
340-
: object(std::move(obj)),
341-
to_centerline(lat),
342-
longitudinal(lon),
343-
length(len),
344-
overhang_dist(overhang)
339+
ObjectData(PredictedObject obj, double lat, double lon, double len)
340+
: object(std::move(obj)), to_centerline(lat), longitudinal(lon), length(len)
345341
{
346342
}
347343

@@ -365,9 +361,6 @@ struct ObjectData // avoidance target
365361
// longitudinal length of vehicle, in Frenet coordinate
366362
double length{0.0};
367363

368-
// lateral distance to the closest footprint, in Frenet coordinate
369-
double overhang_dist{0.0};
370-
371364
// lateral shiftable ratio
372365
double shiftable_ratio{0.0};
373366

@@ -392,9 +385,6 @@ struct ObjectData // avoidance target
392385
// the position at the detected moment
393386
Pose init_pose;
394387

395-
// the position of the overhang
396-
Pose overhang_pose;
397-
398388
// envelope polygon
399389
Polygon2d envelope_poly{};
400390

@@ -425,14 +415,17 @@ struct ObjectData // avoidance target
425415
// object direction.
426416
Direction direction{Direction::NONE};
427417

418+
// overhang points (sort by distance)
419+
std::vector<std::pair<double, Point>> overhang_points{};
420+
428421
// unavoidable reason
429422
std::string reason{};
430423

431424
// lateral avoid margin
432425
std::optional<double> avoid_margin{std::nullopt};
433426

434427
// the nearest bound point (use in road shoulder distance calculation)
435-
std::optional<Point> nearest_bound_point{std::nullopt};
428+
std::optional<std::pair<Point, Point>> narrowest_place{std::nullopt};
436429
};
437430
using ObjectDataArray = std::vector<ObjectData>;
438431

@@ -541,9 +534,9 @@ struct AvoidancePlanningData
541534

542535
std::vector<DrivableLanes> drivable_lanes{};
543536

544-
lanelet::BasicLineString3d right_bound{};
537+
std::vector<Point> right_bound{};
545538

546-
lanelet::BasicLineString3d left_bound{};
539+
std::vector<Point> left_bound{};
547540

548541
bool safe{false};
549542

‎planning/behavior_path_avoidance_module/include/behavior_path_avoidance_module/helper.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ class AvoidanceHelper
176176
{
177177
using utils::avoidance::calcShiftLength;
178178

179-
const auto shift_length = calcShiftLength(is_on_right, object.overhang_dist, margin);
179+
const auto shift_length =
180+
calcShiftLength(is_on_right, object.overhang_points.front().first, margin);
180181
return is_on_right ? std::min(shift_length, getLeftShiftBound())
181182
: std::max(shift_length, getRightShiftBound());
182183
}

‎planning/behavior_path_avoidance_module/include/behavior_path_avoidance_module/utils.hpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ double lerpShiftLengthOnArc(double arc, const AvoidLine & al);
5656
void fillLongitudinalAndLengthByClosestEnvelopeFootprint(
5757
const PathWithLaneId & path, const Point & ego_pos, ObjectData & obj);
5858

59-
double calcEnvelopeOverhangDistance(
60-
const ObjectData & object_data, const PathWithLaneId & path, Point & overhang_pose);
59+
std::vector<std::pair<double, Point>> calcEnvelopeOverhangDistance(
60+
const ObjectData & object_data, const PathWithLaneId & path);
6161

6262
void setEndData(
6363
AvoidLine & al, const double length, const geometry_msgs::msg::Pose & end, const size_t end_idx,
@@ -127,6 +127,10 @@ void filterTargetObjects(
127127
const std::shared_ptr<const PlannerData> & planner_data,
128128
const std::shared_ptr<AvoidanceParameters> & parameters);
129129

130+
void updateRoadShoulderDistance(
131+
AvoidancePlanningData & data, const std::shared_ptr<const PlannerData> & planner_data,
132+
const std::shared_ptr<AvoidanceParameters> & parameters);
133+
130134
void fillAdditionalInfoFromPoint(const AvoidancePlanningData & data, AvoidLineArray & lines);
131135

132136
void fillAdditionalInfoFromLongitudinal(const AvoidancePlanningData & data, AvoidLine & line);

‎planning/behavior_path_avoidance_module/src/debug.cpp

+6-6
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ MarkerArray createToDrivableBoundDistance(const ObjectDataArray & objects, std::
113113
MarkerArray msg;
114114

115115
for (const auto & object : objects) {
116-
if (!object.nearest_bound_point.has_value()) {
116+
if (!object.narrowest_place.has_value()) {
117117
continue;
118118
}
119119

@@ -122,8 +122,8 @@ MarkerArray createToDrivableBoundDistance(const ObjectDataArray & objects, std::
122122
"map", rclcpp::Clock{RCL_ROS_TIME}.now(), ns, 0L, Marker::LINE_STRIP,
123123
createMarkerScale(0.1, 0.0, 0.0), createMarkerColor(1.0, 0.0, 0.42, 0.999));
124124

125-
marker.points.push_back(object.overhang_pose.position);
126-
marker.points.push_back(object.nearest_bound_point.value());
125+
marker.points.push_back(object.narrowest_place.value().first);
126+
marker.points.push_back(object.narrowest_place.value().second);
127127
marker.id = uuidToInt32(object.object.object_id);
128128
msg.markers.push_back(marker);
129129
}
@@ -133,7 +133,7 @@ MarkerArray createToDrivableBoundDistance(const ObjectDataArray & objects, std::
133133
"map", rclcpp::Clock{RCL_ROS_TIME}.now(), ns, 0L, Marker::TEXT_VIEW_FACING,
134134
createMarkerScale(0.5, 0.5, 0.5), createMarkerColor(1.0, 1.0, 0.0, 1.0));
135135

136-
marker.pose.position = object.nearest_bound_point.value();
136+
marker.pose.position = object.narrowest_place.value().second;
137137
std::ostringstream string_stream;
138138
string_stream << object.to_road_shoulder_distance << "[m]";
139139
marker.text = string_stream.str();
@@ -469,7 +469,7 @@ MarkerArray createDrivableBounds(
469469
createMarkerColor(r, g, b, 0.999));
470470

471471
for (const auto & p : data.right_bound) {
472-
marker.points.push_back(createPoint(p.x(), p.y(), p.z()));
472+
marker.points.push_back(p);
473473
}
474474

475475
msg.markers.push_back(marker);
@@ -482,7 +482,7 @@ MarkerArray createDrivableBounds(
482482
createMarkerColor(r, g, b, 0.999));
483483

484484
for (const auto & p : data.left_bound) {
485-
marker.points.push_back(createPoint(p.x(), p.y(), p.z()));
485+
marker.points.push_back(p);
486486
}
487487

488488
msg.markers.push_back(marker);

‎planning/behavior_path_avoidance_module/src/scene.cpp

+23-10
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,14 @@ void AvoidanceModule::fillFundamentalData(AvoidancePlanningData & data, DebugDat
234234
// calc drivable bound
235235
auto tmp_path = getPreviousModuleOutput().path;
236236
const auto shorten_lanes = utils::cutOverlappedLanes(tmp_path, data.drivable_lanes);
237-
data.left_bound = toLineString3d(utils::calcBound(
237+
data.left_bound = utils::calcBound(
238238
getPreviousModuleOutput().path, planner_data_, shorten_lanes,
239239
parameters_->use_hatched_road_markings, parameters_->use_intersection_areas,
240-
parameters_->use_freespace_areas, true));
241-
data.right_bound = toLineString3d(utils::calcBound(
240+
parameters_->use_freespace_areas, true);
241+
data.right_bound = utils::calcBound(
242242
getPreviousModuleOutput().path, planner_data_, shorten_lanes,
243243
parameters_->use_hatched_road_markings, parameters_->use_intersection_areas,
244-
parameters_->use_freespace_areas, false));
244+
parameters_->use_freespace_areas, false);
245245

246246
// reference path
247247
if (isDrivingSameLane(helper_->getPreviousDrivingLanes(), data.current_lanelets)) {
@@ -294,6 +294,7 @@ void AvoidanceModule::fillAvoidanceTargetObjects(
294294
using utils::avoidance::filterTargetObjects;
295295
using utils::avoidance::getTargetLanelets;
296296
using utils::avoidance::separateObjectsByPath;
297+
using utils::avoidance::updateRoadShoulderDistance;
297298

298299
// Separate dynamic objects based on whether they are inside or outside of the expanded lanelets.
299300
constexpr double MARGIN = 10.0;
@@ -315,6 +316,7 @@ void AvoidanceModule::fillAvoidanceTargetObjects(
315316

316317
// Filter out the objects to determine the ones to be avoided.
317318
filterTargetObjects(objects, data, forward_detection_range, planner_data_, parameters_);
319+
updateRoadShoulderDistance(data, planner_data_, parameters_);
318320

319321
// Calculate the distance needed to safely decelerate the ego vehicle to a stop line.
320322
const auto & vehicle_width = planner_data_->parameters.vehicle_width;
@@ -929,10 +931,6 @@ BehaviorModuleOutput AvoidanceModule::plan()
929931
DrivableAreaInfo current_drivable_area_info;
930932
// generate drivable lanes
931933
current_drivable_area_info.drivable_lanes = avoid_data_.drivable_lanes;
932-
// generate obstacle polygons
933-
current_drivable_area_info.obstacles =
934-
utils::avoidance::generateObstaclePolygonsForDrivableArea(
935-
avoid_data_.target_objects, parameters_, planner_data_->parameters.vehicle_width / 2.0);
936934
// expand hatched road markings
937935
current_drivable_area_info.enable_expanding_hatched_road_markings =
938936
parameters_->use_hatched_road_markings;
@@ -941,6 +939,21 @@ BehaviorModuleOutput AvoidanceModule::plan()
941939
parameters_->use_intersection_areas;
942940
// expand freespace areas
943941
current_drivable_area_info.enable_expanding_freespace_areas = parameters_->use_freespace_areas;
942+
// generate obstacle polygons
943+
if (parameters_->enable_bound_clipping) {
944+
ObjectDataArray clip_objects;
945+
// If avoidance is executed by both behavior and motion, only non-avoidable object will be
946+
// extracted from the drivable area.
947+
std::for_each(
948+
data.target_objects.begin(), data.target_objects.end(), [&](const auto & object) {
949+
if (!object.is_avoidable) clip_objects.push_back(object);
950+
});
951+
current_drivable_area_info.obstacles =
952+
utils::avoidance::generateObstaclePolygonsForDrivableArea(
953+
clip_objects, parameters_, planner_data_->parameters.vehicle_width / 2.0);
954+
} else {
955+
current_drivable_area_info.obstacles.clear();
956+
}
944957

945958
output.drivable_area_info = utils::combineDrivableAreaInfo(
946959
current_drivable_area_info, getPreviousModuleOutput().drivable_area_info);
@@ -1150,8 +1163,8 @@ bool AvoidanceModule::isValidShiftLine(
11501163
const size_t end_idx = shift_lines.back().end_idx;
11511164

11521165
const auto path = shifter_for_validate.getReferencePath();
1153-
const auto left_bound = lanelet::utils::to2D(avoid_data_.left_bound);
1154-
const auto right_bound = lanelet::utils::to2D(avoid_data_.right_bound);
1166+
const auto left_bound = lanelet::utils::to2D(toLineString3d(avoid_data_.left_bound));
1167+
const auto right_bound = lanelet::utils::to2D(toLineString3d(avoid_data_.right_bound));
11551168
for (size_t i = start_idx; i <= end_idx; ++i) {
11561169
const auto p = getPoint(path.points.at(i));
11571170
lanelet::BasicPoint2d basic_point{p.x, p.y};

‎planning/behavior_path_avoidance_module/src/shift_line_generator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ AvoidOutlines ShiftLineGenerator::generateAvoidOutline(
235235
const double LAT_DIST_BUFFER = desire_shift_length > 0.0 ? 1e-3 : -1e-3;
236236

237237
const auto infeasible =
238-
std::abs(feasible_shift_length - object.overhang_dist) - LAT_DIST_BUFFER <
238+
std::abs(feasible_shift_length - object.overhang_points.front().first) - LAT_DIST_BUFFER <
239239
0.5 * data_->parameters.vehicle_width + object_parameter.safety_buffer_lateral;
240240
if (infeasible) {
241241
RCLCPP_DEBUG(rclcpp::get_logger(""), "feasible shift length is not enough to avoid. ");

‎planning/behavior_path_avoidance_module/src/utils.cpp

+86-68
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include "behavior_path_avoidance_module/data_structs.hpp"
1818
#include "behavior_path_avoidance_module/utils.hpp"
19+
#include "behavior_path_planner_common/utils/drivable_area_expansion/static_drivable_area.hpp"
1920
#include "behavior_path_planner_common/utils/path_safety_checker/objects_filtering.hpp"
2021
#include "behavior_path_planner_common/utils/path_utils.hpp"
2122
#include "behavior_path_planner_common/utils/traffic_light_utils.hpp"
@@ -818,8 +819,8 @@ bool isNoNeedAvoidanceBehavior(
818819
return false;
819820
}
820821

821-
const auto shift_length =
822-
calcShiftLength(isOnRight(object), object.overhang_dist, object.avoid_margin.value());
822+
const auto shift_length = calcShiftLength(
823+
isOnRight(object), object.overhang_points.front().first, object.avoid_margin.value());
823824
if (!isShiftNecessary(isOnRight(object), shift_length)) {
824825
object.reason = "NotNeedAvoidance";
825826
return true;
@@ -880,45 +881,41 @@ double getRoadShoulderDistance(
880881
return 0.0;
881882
}
882883

883-
const auto centerline_pose =
884-
lanelet::utils::getClosestCenterPose(object.overhang_lanelet, object_pose.position);
885-
const auto & p1_object = object.overhang_pose.position;
886-
const auto p_tmp =
887-
geometry_msgs::build<Pose>().position(p1_object).orientation(centerline_pose.orientation);
888-
const auto p2_object =
889-
calcOffsetPose(p_tmp, 0.0, (isOnRight(object) ? 100.0 : -100.0), 0.0).position;
890-
891-
// TODO(Satoshi OTA): check if the basic point is on right or left of bound.
892-
const auto bound = isOnRight(object) ? data.left_bound : data.right_bound;
893-
894-
std::vector<Point> intersects;
895-
for (size_t i = 1; i < bound.size(); i++) {
896-
const auto p1_bound =
897-
geometry_msgs::build<Point>().x(bound[i - 1].x()).y(bound[i - 1].y()).z(bound[i - 1].z());
898-
const auto p2_bound =
899-
geometry_msgs::build<Point>().x(bound[i].x()).y(bound[i].y()).z(bound[i].z());
900-
901-
const auto opt_intersect =
902-
tier4_autoware_utils::intersect(p1_object, p2_object, p1_bound, p2_bound);
903-
904-
if (!opt_intersect) {
905-
continue;
906-
}
884+
std::vector<std::pair<Point, Point>> intersects;
885+
for (const auto & p1 : object.overhang_points) {
886+
const auto centerline_pose =
887+
lanelet::utils::getClosestCenterPose(object.overhang_lanelet, object_pose.position);
888+
const auto p_tmp =
889+
geometry_msgs::build<Pose>().position(p1.second).orientation(centerline_pose.orientation);
890+
const auto p2 = calcOffsetPose(p_tmp, 0.0, (isOnRight(object) ? 100.0 : -100.0), 0.0).position;
891+
892+
// TODO(Satoshi OTA): check if the basic point is on right or left of bound.
893+
const auto bound = isOnRight(object) ? data.left_bound : data.right_bound;
907894

908-
intersects.push_back(opt_intersect.value());
895+
for (size_t i = 1; i < bound.size(); i++) {
896+
const auto opt_intersect =
897+
tier4_autoware_utils::intersect(p1.second, p2, bound.at(i - 1), bound.at(i));
898+
899+
if (!opt_intersect) {
900+
continue;
901+
}
902+
903+
intersects.emplace_back(p1.second, opt_intersect.value());
904+
}
909905
}
910906

907+
std::sort(intersects.begin(), intersects.end(), [](const auto & a, const auto & b) {
908+
return calcDistance2d(a.first, a.second) < calcDistance2d(b.first, b.second);
909+
});
910+
911911
if (intersects.empty()) {
912912
return 0.0;
913913
}
914914

915-
std::sort(intersects.begin(), intersects.end(), [&p1_object](const auto & a, const auto & b) {
916-
return calcDistance2d(p1_object, a) < calcDistance2d(p1_object, b);
917-
});
918-
919-
object.nearest_bound_point = intersects.front();
915+
object.narrowest_place = intersects.front();
920916

921-
return calcDistance2d(p1_object, object.nearest_bound_point.value());
917+
return calcDistance2d(
918+
object.narrowest_place.value().first, object.narrowest_place.value().second);
922919
}
923920
} // namespace filtering_utils
924921

@@ -1074,34 +1071,22 @@ void fillLongitudinalAndLengthByClosestEnvelopeFootprint(
10741071
return;
10751072
}
10761073

1077-
double calcEnvelopeOverhangDistance(
1078-
const ObjectData & object_data, const PathWithLaneId & path, Point & overhang_pose)
1074+
std::vector<std::pair<double, Point>> calcEnvelopeOverhangDistance(
1075+
const ObjectData & object_data, const PathWithLaneId & path)
10791076
{
1080-
double largest_overhang = isOnRight(object_data) ? -100.0 : 100.0; // large number
1077+
std::vector<std::pair<double, Point>> overhang_points{};
10811078

10821079
for (const auto & p : object_data.envelope_poly.outer()) {
10831080
const auto point = tier4_autoware_utils::createPoint(p.x(), p.y(), 0.0);
10841081
// TODO(someone): search around first position where the ego should avoid the object.
10851082
const auto idx = findNearestIndex(path.points, point);
10861083
const auto lateral = calcLateralDeviation(getPose(path.points.at(idx)), point);
1087-
1088-
const auto & overhang_pose_on_right = [&overhang_pose, &largest_overhang, &point, &lateral]() {
1089-
if (lateral > largest_overhang) {
1090-
overhang_pose = point;
1091-
}
1092-
return std::max(largest_overhang, lateral);
1093-
};
1094-
1095-
const auto & overhang_pose_on_left = [&overhang_pose, &largest_overhang, &point, &lateral]() {
1096-
if (lateral < largest_overhang) {
1097-
overhang_pose = point;
1098-
}
1099-
return std::min(largest_overhang, lateral);
1100-
};
1101-
1102-
largest_overhang = isOnRight(object_data) ? overhang_pose_on_right() : overhang_pose_on_left();
1084+
overhang_points.emplace_back(lateral, point);
11031085
}
1104-
return largest_overhang;
1086+
std::sort(overhang_points.begin(), overhang_points.end(), [&](const auto & a, const auto & b) {
1087+
return isOnRight(object_data) ? b.first < a.first : a.first < b.first;
1088+
});
1089+
return overhang_points;
11051090
}
11061091

11071092
void setEndData(
@@ -1184,24 +1169,21 @@ std::vector<DrivableAreaInfo::Obstacle> generateObstaclePolygonsForDrivableArea(
11841169
{
11851170
std::vector<DrivableAreaInfo::Obstacle> obstacles_for_drivable_area;
11861171

1187-
if (objects.empty() || !parameters->enable_bound_clipping) {
1172+
if (objects.empty()) {
11881173
return obstacles_for_drivable_area;
11891174
}
11901175

11911176
for (const auto & object : objects) {
1192-
// If avoidance is executed by both behavior and motion, only non-avoidable object will be
1193-
// extracted from the drivable area.
1194-
if (!parameters->disable_path_update) {
1195-
if (object.is_avoidable) {
1196-
continue;
1197-
}
1198-
}
1199-
12001177
// check if avoid marin is calculated
12011178
if (!object.avoid_margin.has_value()) {
12021179
continue;
12031180
}
12041181

1182+
// check original polygon
1183+
if (object.envelope_poly.outer().empty()) {
1184+
continue;
1185+
}
1186+
12051187
const auto object_type = utils::getHighestProbLabel(object.object.classification);
12061188
const auto object_parameter = parameters->object_parameters.at(object_type);
12071189

@@ -1449,10 +1431,10 @@ void fillAvoidanceNecessity(
14491431
0.5 * vehicle_width + object_parameter.safety_buffer_lateral * object_data.distance_factor;
14501432

14511433
const auto check_necessity = [&](const auto hysteresis_factor) {
1452-
return (isOnRight(object_data) &&
1453-
std::abs(object_data.overhang_dist) < safety_margin * hysteresis_factor) ||
1434+
return (isOnRight(object_data) && std::abs(object_data.overhang_points.front().first) <
1435+
safety_margin * hysteresis_factor) ||
14541436
(!isOnRight(object_data) &&
1455-
object_data.overhang_dist < safety_margin * hysteresis_factor);
1437+
object_data.overhang_points.front().first < safety_margin * hysteresis_factor);
14561438
};
14571439

14581440
const auto id = object_data.object.object_id;
@@ -1615,6 +1597,40 @@ void compensateDetectionLost(
16151597
}
16161598
}
16171599

1600+
void updateRoadShoulderDistance(
1601+
AvoidancePlanningData & data, const std::shared_ptr<const PlannerData> & planner_data,
1602+
const std::shared_ptr<AvoidanceParameters> & parameters)
1603+
{
1604+
ObjectDataArray clip_objects;
1605+
std::for_each(data.other_objects.begin(), data.other_objects.end(), [&](const auto & object) {
1606+
if (!filtering_utils::isMovingObject(object, parameters)) {
1607+
clip_objects.push_back(object);
1608+
}
1609+
});
1610+
for (auto & o : clip_objects) {
1611+
const auto & vehicle_width = planner_data->parameters.vehicle_width;
1612+
const auto object_type = utils::getHighestProbLabel(o.object.classification);
1613+
const auto object_parameter = parameters->object_parameters.at(object_type);
1614+
1615+
o.avoid_margin = object_parameter.safety_buffer_lateral + 0.5 * vehicle_width;
1616+
}
1617+
const auto extract_obstacles = generateObstaclePolygonsForDrivableArea(
1618+
clip_objects, parameters, planner_data->parameters.vehicle_width / 2.0);
1619+
1620+
auto tmp_path = data.reference_path;
1621+
tmp_path.left_bound = data.left_bound;
1622+
tmp_path.right_bound = data.right_bound;
1623+
utils::extractObstaclesFromDrivableArea(tmp_path, extract_obstacles);
1624+
1625+
data.left_bound = tmp_path.left_bound;
1626+
data.right_bound = tmp_path.right_bound;
1627+
1628+
for (auto & o : data.target_objects) {
1629+
o.to_road_shoulder_distance = filtering_utils::getRoadShoulderDistance(o, data, planner_data);
1630+
o.avoid_margin = filtering_utils::getAvoidMargin(o, planner_data, parameters);
1631+
}
1632+
}
1633+
16181634
void filterTargetObjects(
16191635
ObjectDataArray & objects, AvoidancePlanningData & data, const double forward_detection_range,
16201636
const std::shared_ptr<const PlannerData> & planner_data,
@@ -1638,8 +1654,7 @@ void filterTargetObjects(
16381654
}
16391655

16401656
// Find the footprint point closest to the path, set to object_data.overhang_distance.
1641-
o.overhang_dist =
1642-
calcEnvelopeOverhangDistance(o, data.reference_path, o.overhang_pose.position);
1657+
o.overhang_points = utils::avoidance::calcEnvelopeOverhangDistance(o, data.reference_path);
16431658
o.to_road_shoulder_distance = filtering_utils::getRoadShoulderDistance(o, data, planner_data);
16441659
o.avoid_margin = filtering_utils::getAvoidMargin(o, planner_data, parameters);
16451660

@@ -1846,7 +1861,10 @@ std::vector<ExtendedPredictedObject> getSafetyCheckTargetObjects(
18461861
PredictedObjects ret{};
18471862
std::for_each(objects.begin(), objects.end(), [&p, &ret, &parameters](const auto & object) {
18481863
if (filtering_utils::isSafetyCheckTargetObjectType(object.object, parameters)) {
1849-
ret.objects.push_back(object.object);
1864+
// check only moving objects
1865+
if (filtering_utils::isMovingObject(object, parameters)) {
1866+
ret.objects.push_back(object.object);
1867+
}
18501868
}
18511869
});
18521870
return ret;

0 commit comments

Comments
 (0)
Please sign in to comment.