@@ -183,29 +183,36 @@ AvoidOutlines ShiftLineGenerator::generateAvoidOutline(
183
183
}
184
184
185
185
// prepare distance is not enough. unavoidable.
186
- if (remaining_distance < 1e-3 ) {
186
+ if (avoidance_distance < 1e-3 ) {
187
187
object.reason = AvoidanceDebugFactor::REMAINING_DISTANCE_LESS_THAN_ZERO;
188
188
return std::nullopt;
189
189
}
190
190
191
191
// calculate lateral jerk.
192
192
const auto required_jerk = PathShifter::calcJerkFromLatLonDistance (
193
- avoiding_shift, remaining_distance , helper_->getAvoidanceEgoSpeed ());
193
+ avoiding_shift, avoidance_distance , helper_->getAvoidanceEgoSpeed ());
194
194
195
195
// relax lateral jerk limit. avoidable.
196
196
if (required_jerk < helper_->getLateralMaxJerkLimit ()) {
197
197
return std::make_pair (desire_shift_length, avoidance_distance);
198
198
}
199
199
200
+ constexpr double LON_DIST_BUFFER = 1e-3 ;
201
+
200
202
// avoidance distance is not enough. unavoidable.
201
203
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
+ }
204
211
}
205
212
206
213
// output avoidance path under lateral jerk constraints.
207
214
const auto feasible_relative_shift_length = PathShifter::calcLateralDistFromJerk (
208
- remaining_distance , helper_->getLateralMaxJerkLimit (), helper_->getAvoidanceEgoSpeed ());
215
+ avoidance_distance , helper_->getLateralMaxJerkLimit (), helper_->getAvoidanceEgoSpeed ());
209
216
210
217
if (std::abs (feasible_relative_shift_length) < parameters_->lateral_execution_threshold ) {
211
218
object.reason = " LessThanExecutionThreshold" ;
@@ -216,16 +223,25 @@ AvoidOutlines ShiftLineGenerator::generateAvoidOutline(
216
223
desire_shift_length > 0.0 ? feasible_relative_shift_length + current_ego_shift
217
224
: -1.0 * feasible_relative_shift_length + current_ego_shift;
218
225
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
+
219
235
const auto infeasible =
220
- std::abs (feasible_shift_length - object.overhang_dist ) <
236
+ std::abs (feasible_shift_length - object.overhang_dist ) - LAT_DIST_BUFFER <
221
237
0.5 * data_->parameters .vehicle_width + object_parameter.safety_buffer_lateral ;
222
238
if (infeasible) {
223
239
RCLCPP_DEBUG (rclcpp::get_logger (" " ), " feasible shift length is not enough to avoid. " );
224
240
object.reason = AvoidanceDebugFactor::TOO_LARGE_JERK;
225
241
return std::nullopt;
226
242
}
227
243
228
- return std::make_pair (feasible_shift_length, avoidance_distance);
244
+ return std::make_pair (feasible_shift_length - LAT_DIST_BUFFER , avoidance_distance);
229
245
};
230
246
231
247
const auto is_forward_object = [](const auto & object) { return object.longitudinal > 0.0 ; };
0 commit comments