Skip to content

Commit 63e20f3

Browse files
satoshi-otachtseng
authored and
chtseng
committed
fix(static_obstacle_avoidance): avoid object behind unavoidance object if unavoidable is not on the path (autowarefoundation#8066)
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com> Signed-off-by: chtseng <chtseng@itri.org.tw>
1 parent e18d463 commit 63e20f3

File tree

1 file changed

+27
-7
lines changed

1 file changed

+27
-7
lines changed

planning/behavior_path_planner/autoware_behavior_path_static_obstacle_avoidance_module/src/shift_line_generator.cpp

+27-7
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,18 @@ AvoidOutlines ShiftLineGenerator::generateAvoidOutline(
239239

240240
const auto is_forward_object = [](const auto & object) { return object.longitudinal > 0.0; };
241241

242+
const auto is_on_path = [this](const auto & object) {
243+
const auto [overhang, point] = object.overhang_points.front();
244+
return std::abs(overhang) < 0.5 * data_->parameters.vehicle_width;
245+
};
246+
242247
const auto is_valid_shift_line = [](const auto & s) {
243248
return s.start_longitudinal > 0.0 && s.start_longitudinal < s.end_longitudinal;
244249
};
245250

251+
ObjectDataArray unavoidable_objects;
252+
253+
// target objects are sorted by longitudinal distance.
246254
AvoidOutlines outlines;
247255
for (auto & o : data.target_objects) {
248256
if (!o.avoid_margin.has_value()) {
@@ -253,36 +261,48 @@ AvoidOutlines ShiftLineGenerator::generateAvoidOutline(
253261
} else {
254262
o.info = ObjectInfo::INSUFFICIENT_DRIVABLE_SPACE;
255263
}
256-
if (o.avoid_required && is_forward_object(o)) {
264+
if (o.avoid_required && is_forward_object(o) && is_on_path(o)) {
257265
break;
258266
} else {
267+
unavoidable_objects.push_back(o);
259268
continue;
260269
}
261270
}
262271

263-
const auto is_object_on_right = utils::static_obstacle_avoidance::isOnRight(o);
264272
const auto desire_shift_length =
265-
helper_->getShiftLength(o, is_object_on_right, o.avoid_margin.value());
266-
if (utils::static_obstacle_avoidance::isSameDirectionShift(
267-
is_object_on_right, desire_shift_length)) {
273+
helper_->getShiftLength(o, isOnRight(o), o.avoid_margin.value());
274+
if (utils::static_obstacle_avoidance::isSameDirectionShift(isOnRight(o), desire_shift_length)) {
268275
o.info = ObjectInfo::SAME_DIRECTION_SHIFT;
269-
if (o.avoid_required && is_forward_object(o)) {
276+
if (o.avoid_required && is_forward_object(o) && is_on_path(o)) {
270277
break;
271278
} else {
279+
unavoidable_objects.push_back(o);
272280
continue;
273281
}
274282
}
275283

276284
// calculate feasible shift length based on behavior policy
277285
const auto feasible_shift_profile = get_shift_profile(o, desire_shift_length);
278286
if (!feasible_shift_profile.has_value()) {
279-
if (o.avoid_required && is_forward_object(o)) {
287+
if (o.avoid_required && is_forward_object(o) && is_on_path(o)) {
280288
break;
281289
} else {
290+
unavoidable_objects.push_back(o);
282291
continue;
283292
}
284293
}
285294

295+
// If there is an object that cannot be avoided, this module only avoids object on the same side
296+
// as unavoidable object.
297+
if (!unavoidable_objects.empty()) {
298+
if (isOnRight(unavoidable_objects.front()) && !isOnRight(o)) {
299+
break;
300+
}
301+
if (!isOnRight(unavoidable_objects.front()) && isOnRight(o)) {
302+
break;
303+
}
304+
}
305+
286306
// use absolute dist for return-to-center, relative dist from current for avoiding.
287307
const auto feasible_return_distance =
288308
helper_->getMaxAvoidanceDistance(feasible_shift_profile.value().first);

0 commit comments

Comments
 (0)