Skip to content

Commit 68a3b99

Browse files
satoshi-otaTomohitoAndo
authored andcommitted
fix(avoidance): unexpected stop decision in avoidance module (autowarefoundation#6320)
Signed-off-by: satoshi-ota <satoshi.ota928@gmail.com>
1 parent e62ca18 commit 68a3b99

File tree

2 files changed

+25
-8
lines changed

2 files changed

+25
-8
lines changed

planning/behavior_path_avoidance_module/include/behavior_path_avoidance_module/helper.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -261,10 +261,11 @@ class AvoidanceHelper
261261

262262
bool isComfortable(const AvoidLineArray & shift_lines) const
263263
{
264+
const auto JERK_BUFFER = 0.1; // [m/sss]
264265
return std::all_of(shift_lines.begin(), shift_lines.end(), [&](const auto & line) {
265266
return PathShifter::calcJerkFromLatLonDistance(
266267
line.getRelativeLength(), line.getRelativeLongitudinal(), getAvoidanceEgoSpeed()) <
267-
getLateralMaxJerkLimit();
268+
getLateralMaxJerkLimit() + JERK_BUFFER;
268269
});
269270
}
270271

planning/behavior_path_avoidance_module/src/shift_line_generator.cpp

+23-7
Original file line numberDiff line numberDiff line change
@@ -183,29 +183,36 @@ AvoidOutlines ShiftLineGenerator::generateAvoidOutline(
183183
}
184184

185185
// prepare distance is not enough. unavoidable.
186-
if (remaining_distance < 1e-3) {
186+
if (avoidance_distance < 1e-3) {
187187
object.reason = AvoidanceDebugFactor::REMAINING_DISTANCE_LESS_THAN_ZERO;
188188
return std::nullopt;
189189
}
190190

191191
// calculate lateral jerk.
192192
const auto required_jerk = PathShifter::calcJerkFromLatLonDistance(
193-
avoiding_shift, remaining_distance, helper_->getAvoidanceEgoSpeed());
193+
avoiding_shift, avoidance_distance, helper_->getAvoidanceEgoSpeed());
194194

195195
// relax lateral jerk limit. avoidable.
196196
if (required_jerk < helper_->getLateralMaxJerkLimit()) {
197197
return std::make_pair(desire_shift_length, avoidance_distance);
198198
}
199199

200+
constexpr double LON_DIST_BUFFER = 1e-3;
201+
200202
// avoidance distance is not enough. unavoidable.
201203
if (!isBestEffort(parameters_->policy_deceleration)) {
202-
object.reason = AvoidanceDebugFactor::TOO_LARGE_JERK;
203-
return std::nullopt;
204+
if (avoidance_distance < helper_->getMinAvoidanceDistance(avoiding_shift) + LON_DIST_BUFFER) {
205+
object.reason = AvoidanceDebugFactor::REMAINING_DISTANCE_LESS_THAN_ZERO;
206+
return std::nullopt;
207+
} else {
208+
object.reason = AvoidanceDebugFactor::TOO_LARGE_JERK;
209+
return std::nullopt;
210+
}
204211
}
205212

206213
// output avoidance path under lateral jerk constraints.
207214
const auto feasible_relative_shift_length = PathShifter::calcLateralDistFromJerk(
208-
remaining_distance, helper_->getLateralMaxJerkLimit(), helper_->getAvoidanceEgoSpeed());
215+
avoidance_distance, helper_->getLateralMaxJerkLimit(), helper_->getAvoidanceEgoSpeed());
209216

210217
if (std::abs(feasible_relative_shift_length) < parameters_->lateral_execution_threshold) {
211218
object.reason = "LessThanExecutionThreshold";
@@ -216,16 +223,25 @@ AvoidOutlines ShiftLineGenerator::generateAvoidOutline(
216223
desire_shift_length > 0.0 ? feasible_relative_shift_length + current_ego_shift
217224
: -1.0 * feasible_relative_shift_length + current_ego_shift;
218225

226+
if (
227+
avoidance_distance <
228+
helper_->getMinAvoidanceDistance(feasible_shift_length) + LON_DIST_BUFFER) {
229+
object.reason = AvoidanceDebugFactor::REMAINING_DISTANCE_LESS_THAN_ZERO;
230+
return std::nullopt;
231+
}
232+
233+
const double LAT_DIST_BUFFER = desire_shift_length > 0.0 ? 1e-3 : -1e-3;
234+
219235
const auto infeasible =
220-
std::abs(feasible_shift_length - object.overhang_dist) <
236+
std::abs(feasible_shift_length - object.overhang_dist) - LAT_DIST_BUFFER <
221237
0.5 * data_->parameters.vehicle_width + object_parameter.safety_buffer_lateral;
222238
if (infeasible) {
223239
RCLCPP_DEBUG(rclcpp::get_logger(""), "feasible shift length is not enough to avoid. ");
224240
object.reason = AvoidanceDebugFactor::TOO_LARGE_JERK;
225241
return std::nullopt;
226242
}
227243

228-
return std::make_pair(feasible_shift_length, avoidance_distance);
244+
return std::make_pair(feasible_shift_length - LAT_DIST_BUFFER, avoidance_distance);
229245
};
230246

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

0 commit comments

Comments
 (0)