@@ -136,6 +136,12 @@ void StartPlannerModule::updateData()
136
136
if (has_received_new_route) {
137
137
status_ = PullOutStatus ();
138
138
}
139
+ // check safety status after back finished
140
+ if (parameters_->safety_check_params .enable_safety_check && status_.back_finished ) {
141
+ status_.is_safe_dynamic_objects = isSafePath ();
142
+ } else {
143
+ status_.is_safe_dynamic_objects = true ;
144
+ }
139
145
}
140
146
141
147
bool StartPlannerModule::isExecutionRequested () const
@@ -179,17 +185,19 @@ bool StartPlannerModule::isExecutionRequested() const
179
185
180
186
bool StartPlannerModule::isExecutionReady () const
181
187
{
188
+ // when is_safe_static_objects is false,the path is not generated and approval shouldn't be
189
+ // allowed
182
190
if (!status_.is_safe_static_objects ) {
191
+ RCLCPP_ERROR_THROTTLE (getLogger (), *clock_, 5000 , " Path is not safe against static objects" );
183
192
return false ;
184
193
}
185
194
186
- if (status_.pull_out_path .partial_paths .empty ()) {
187
- return true ;
188
- }
189
-
190
- if (status_.is_safe_static_objects && parameters_->safety_check_params .enable_safety_check ) {
195
+ if (
196
+ parameters_->safety_check_params .enable_safety_check && status_.back_finished &&
197
+ isWaitingApproval ()) {
191
198
if (!isSafePath ()) {
192
199
RCLCPP_ERROR_THROTTLE (getLogger (), *clock_, 5000 , " Path is not safe against dynamic objects" );
200
+ stop_pose_ = planner_data_->self_odometry ->pose .pose ;
193
201
return false ;
194
202
}
195
203
}
@@ -221,6 +229,7 @@ void StartPlannerModule::updateCurrentState()
221
229
if (status_.backward_driving_complete ) {
222
230
current_state_ = ModuleStatus::SUCCESS; // for breaking loop
223
231
}
232
+
224
233
print (magic_enum::enum_name (from), magic_enum::enum_name (current_state_));
225
234
}
226
235
@@ -252,12 +261,42 @@ BehaviorModuleOutput StartPlannerModule::plan()
252
261
}
253
262
254
263
PathWithLaneId path;
264
+
265
+ // Check if backward motion is finished
255
266
if (status_.back_finished ) {
267
+ // Increment path index if the current path is finished
256
268
if (hasFinishedCurrentPath ()) {
257
269
RCLCPP_INFO (getLogger (), " Increment path index" );
258
270
incrementPathIndex ();
259
271
}
260
- path = getCurrentPath ();
272
+
273
+ if (!status_.is_safe_dynamic_objects && !isWaitingApproval () && !status_.has_stop_point ) {
274
+ auto current_path = getCurrentPath ();
275
+ const auto stop_path =
276
+ behavior_path_planner::utils::start_goal_planner_common::generateFeasibleStopPath (
277
+ current_path, planner_data_, *stop_pose_, parameters_->maximum_deceleration_for_stop ,
278
+ parameters_->maximum_jerk_for_stop );
279
+
280
+ // Insert stop point in the path if needed
281
+ if (stop_path) {
282
+ RCLCPP_ERROR_THROTTLE (
283
+ getLogger (), *clock_, 5000 , " Insert stop point in the path because of dynamic objects" );
284
+ path = *stop_path;
285
+ status_.prev_stop_path_after_approval = std::make_shared<PathWithLaneId>(path);
286
+ status_.has_stop_point = true ;
287
+ } else {
288
+ path = current_path;
289
+ }
290
+ } else if (!isWaitingApproval () && status_.has_stop_point ) {
291
+ // Delete stop point if conditions are met
292
+ if (status_.is_safe_dynamic_objects && isStopped ()) {
293
+ status_.has_stop_point = false ;
294
+ path = getCurrentPath ();
295
+ }
296
+ path = *status_.prev_stop_path_after_approval ;
297
+ } else {
298
+ path = getCurrentPath ();
299
+ }
261
300
} else {
262
301
path = status_.backward_path ;
263
302
}
0 commit comments