Skip to content

Commit 4700aa1

Browse files
committed
fix(avoidance): wait with unsafe avoidance path
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
1 parent fb4b21c commit 4700aa1

File tree

4 files changed

+33
-17
lines changed

4 files changed

+33
-17
lines changed

planning/behavior_path_avoidance_module/include/behavior_path_avoidance_module/helper.hpp

+28
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,34 @@ class AvoidanceHelper
289289
});
290290
}
291291

292+
bool isReady(const ObjectDataArray & objects) const
293+
{
294+
if (objects.empty()) {
295+
return true;
296+
}
297+
298+
const auto object = objects.front();
299+
300+
if (!object.is_ambiguous) {
301+
return true;
302+
}
303+
304+
if (!object.avoid_margin.has_value()) {
305+
return true;
306+
}
307+
308+
const auto is_object_on_right = utils::avoidance::isOnRight(object);
309+
const auto desire_shift_length =
310+
getShiftLength(object, is_object_on_right, object.avoid_margin.value());
311+
312+
constexpr double BUFFER = 10.0;
313+
const auto prepare_distance = getMinimumPrepareDistance();
314+
const auto constant_distance = getFrontConstantDistance(object);
315+
const auto avoidance_distance = getMinAvoidanceDistance(desire_shift_length);
316+
317+
return object.longitudinal < prepare_distance + constant_distance + avoidance_distance + BUFFER;
318+
}
319+
292320
bool isReady(const AvoidLineArray & new_shift_lines, const double current_shift_length) const
293321
{
294322
if (std::abs(current_shift_length) < 1e-3) {

planning/behavior_path_avoidance_module/src/scene.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,8 @@ void AvoidanceModule::fillShiftLine(AvoidancePlanningData & data, DebugData & de
522522
*/
523523
data.comfortable = helper_->isComfortable(data.new_shift_line);
524524
data.safe = isSafePath(data.candidate_path, debug);
525-
data.ready = helper_->isReady(data.new_shift_line, path_shifter_.getLastShiftLength());
525+
data.ready = helper_->isReady(data.new_shift_line, path_shifter_.getLastShiftLength()) &&
526+
helper_->isReady(data.target_objects);
526527
}
527528

528529
void AvoidanceModule::fillEgoStatus(

planning/behavior_path_avoidance_module/src/shift_line_generator.cpp

-16
Original file line numberDiff line numberDiff line change
@@ -276,22 +276,6 @@ AvoidOutlines ShiftLineGenerator::generateAvoidOutline(
276276

277277
// calculate feasible shift length based on behavior policy
278278
const auto feasible_shift_profile = get_shift_profile(o, desire_shift_length);
279-
280-
if (o.is_ambiguous) {
281-
const auto prepare_distance = helper_->getMinimumPrepareDistance();
282-
const auto constant_distance = helper_->getFrontConstantDistance(o);
283-
const auto avoidance_distance = helper_->getMinAvoidanceDistance(desire_shift_length);
284-
const auto decelaration_distance =
285-
std::max(10.0, helper_->getFeasibleDecelDistance(0.0, false));
286-
if (
287-
o.longitudinal >
288-
prepare_distance + constant_distance + avoidance_distance + decelaration_distance) {
289-
o.reason = "AmbiguousStoppedVehicle(wait-and-see)";
290-
o.is_avoidable = feasible_shift_profile.has_value();
291-
continue;
292-
}
293-
}
294-
295279
if (!feasible_shift_profile.has_value()) {
296280
if (o.avoid_required && is_forward_object(o)) {
297281
break;

planning/behavior_path_avoidance_module/src/utils.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -874,16 +874,19 @@ bool isSatisfiedWithVehicleCondition(
874874

875875
if (object.is_within_intersection) {
876876
if (object.behavior == ObjectData::Behavior::DEVIATING) {
877+
object.reason = "AmbiguousStoppedVehicle(wait-and-see)";
877878
object.is_ambiguous = true;
878879
return true;
879880
}
880881
} else {
881882
if (object.behavior == ObjectData::Behavior::MERGING) {
883+
object.reason = "AmbiguousStoppedVehicle(wait-and-see)";
882884
object.is_ambiguous = true;
883885
return true;
884886
}
885887

886888
if (object.behavior == ObjectData::Behavior::DEVIATING) {
889+
object.reason = "AmbiguousStoppedVehicle(wait-and-see)";
887890
object.is_ambiguous = true;
888891
return true;
889892
}

0 commit comments

Comments
 (0)