@@ -91,6 +91,33 @@ public: \
91
91
DEFINE_SETTER_WITH_MUTEX (TYPE, NAME) \
92
92
DEFINE_GETTER_WITH_MUTEX (TYPE, NAME)
93
93
94
+ enum class DecidingPathStatus {
95
+ NOT_DECIDED,
96
+ DECIDING,
97
+ DECIDED,
98
+ };
99
+ using DecidingPathStatusWithStamp = std::pair<DecidingPathStatus, rclcpp::Time>;
100
+
101
+ struct PreviousPullOverData
102
+ {
103
+ struct SafetyStatus
104
+ {
105
+ std::optional<rclcpp::Time> safe_start_time{};
106
+ bool is_safe{false };
107
+ };
108
+
109
+ void reset ()
110
+ {
111
+ found_path = false ;
112
+ safety_status = SafetyStatus{};
113
+ deciding_path_status = DecidingPathStatusWithStamp{};
114
+ }
115
+
116
+ bool found_path{false };
117
+ SafetyStatus safety_status{};
118
+ DecidingPathStatusWithStamp deciding_path_status{};
119
+ };
120
+
94
121
class ThreadSafeData
95
122
{
96
123
public:
@@ -145,6 +172,9 @@ class ThreadSafeData
145
172
void set (const std::shared_ptr<PullOverPath> & arg) { set_pull_over_path (arg); }
146
173
void set (const PullOverPath & arg) { set_pull_over_path (arg); }
147
174
void set (const GoalCandidate & arg) { set_modified_goal_pose (arg); }
175
+ void set (const BehaviorModuleOutput & arg) { set_last_previous_module_output (arg); }
176
+ void set (const PreviousPullOverData & arg) { set_prev_data (arg); }
177
+ void set (const CollisionCheckDebugMap & arg) { set_collision_check (arg); }
148
178
149
179
void clearPullOverPath ()
150
180
{
@@ -182,6 +212,8 @@ class ThreadSafeData
182
212
last_path_update_time_ = std::nullopt;
183
213
last_path_idx_increment_time_ = std::nullopt;
184
214
closest_start_pose_ = std::nullopt;
215
+ last_previous_module_output_ = std::nullopt;
216
+ prev_data_.reset ();
185
217
}
186
218
187
219
DEFINE_GETTER_WITH_MUTEX (std::shared_ptr<PullOverPath>, pull_over_path)
@@ -193,6 +225,9 @@ class ThreadSafeData
193
225
DEFINE_SETTER_GETTER_WITH_MUTEX (GoalCandidates, goal_candidates)
194
226
DEFINE_SETTER_GETTER_WITH_MUTEX (std::optional<GoalCandidate>, modified_goal_pose)
195
227
DEFINE_SETTER_GETTER_WITH_MUTEX (std::optional<Pose>, closest_start_pose)
228
+ DEFINE_SETTER_GETTER_WITH_MUTEX (std::optional<BehaviorModuleOutput>, last_previous_module_output)
229
+ DEFINE_SETTER_GETTER_WITH_MUTEX (PreviousPullOverData, prev_data)
230
+ DEFINE_SETTER_GETTER_WITH_MUTEX (CollisionCheckDebugMap, collision_check)
196
231
197
232
private:
198
233
std::shared_ptr<PullOverPath> pull_over_path_{nullptr };
@@ -203,6 +238,9 @@ class ThreadSafeData
203
238
std::optional<rclcpp::Time> last_path_update_time_;
204
239
std::optional<rclcpp::Time> last_path_idx_increment_time_;
205
240
std::optional<Pose> closest_start_pose_{};
241
+ std::optional<BehaviorModuleOutput> last_previous_module_output_{};
242
+ PreviousPullOverData prev_data_{};
243
+ CollisionCheckDebugMap collision_check_{};
206
244
207
245
std::recursive_mutex & mutex_;
208
246
rclcpp::Clock::SharedPtr clock_;
@@ -234,33 +272,6 @@ struct LastApprovalData
234
272
Pose pose{};
235
273
};
236
274
237
- enum class DecidingPathStatus {
238
- NOT_DECIDED,
239
- DECIDING,
240
- DECIDED,
241
- };
242
- using DecidingPathStatusWithStamp = std::pair<DecidingPathStatus, rclcpp::Time>;
243
-
244
- struct PreviousPullOverData
245
- {
246
- struct SafetyStatus
247
- {
248
- std::optional<rclcpp::Time> safe_start_time{};
249
- bool is_safe{false };
250
- };
251
-
252
- void reset ()
253
- {
254
- found_path = false ;
255
- safety_status = SafetyStatus{};
256
- deciding_path_status = DecidingPathStatusWithStamp{};
257
- }
258
-
259
- bool found_path{false };
260
- SafetyStatus safety_status{};
261
- DecidingPathStatusWithStamp deciding_path_status{};
262
- };
263
-
264
275
// store stop_pose_ pointer with reason string
265
276
struct PoseWithString
266
277
{
@@ -363,6 +374,50 @@ class GoalPlannerModule : public SceneModuleInterface
363
374
CandidateOutput planCandidate () const override { return CandidateOutput{}; }
364
375
365
376
private:
377
+ /* *
378
+ * @brief shared data for onTimer(onTimer/onFreespaceParkingTimer just read this)
379
+ */
380
+ struct GoalPlannerData
381
+ {
382
+ GoalPlannerData (const PlannerData & planner_data, const GoalPlannerParameters & parameters)
383
+ {
384
+ initializeOccupancyGridMap (planner_data, parameters);
385
+ };
386
+ GoalPlannerParameters parameters;
387
+ std::shared_ptr<EgoPredictedPathParams> ego_predicted_path_params;
388
+ std::shared_ptr<ObjectsFilteringParams> objects_filtering_params;
389
+ std::shared_ptr<SafetyCheckParams> safety_check_params;
390
+ tier4_autoware_utils::LinearRing2d vehicle_footprint;
391
+
392
+ PlannerData planner_data;
393
+ ModuleStatus current_status;
394
+ BehaviorModuleOutput previous_module_output;
395
+ // collision detector
396
+ // need to be shared_ptr to be used in planner and goal searcher
397
+ std::shared_ptr<OccupancyGridBasedCollisionDetector> occupancy_grid_map;
398
+ std::shared_ptr<GoalSearcherBase> goal_searcher;
399
+
400
+ const BehaviorModuleOutput & getPreviousModuleOutput () const { return previous_module_output; }
401
+ const ModuleStatus & getCurrentStatus () const { return current_status; }
402
+ void updateOccupancyGrid ();
403
+ GoalPlannerData clone () const ;
404
+ void update (
405
+ const GoalPlannerParameters & parameters,
406
+ const std::shared_ptr<EgoPredictedPathParams> & ego_predicted_path_params_,
407
+ const std::shared_ptr<ObjectsFilteringParams> & objects_filtering_params_,
408
+ const std::shared_ptr<SafetyCheckParams> & safety_check_params_,
409
+ const PlannerData & planner_data, const ModuleStatus & current_status,
410
+ const BehaviorModuleOutput & previous_module_output,
411
+ const std::shared_ptr<GoalSearcherBase> goal_searcher_,
412
+ const tier4_autoware_utils::LinearRing2d & vehicle_footprint);
413
+
414
+ private:
415
+ void initializeOccupancyGridMap (
416
+ const PlannerData & planner_data, const GoalPlannerParameters & parameters);
417
+ };
418
+ std::optional<GoalPlannerData> gp_planner_data_{std::nullopt};
419
+ std::mutex gp_planner_data_mutex_;
420
+
366
421
// Flag class for managing whether a certain callback is running in multi-threading
367
422
class ScopedFlag
368
423
{
@@ -420,9 +475,10 @@ class GoalPlannerModule : public SceneModuleInterface
420
475
// goal searcher
421
476
std::shared_ptr<GoalSearcherBase> goal_searcher_;
422
477
423
- // collision detector
424
- // need to be shared_ptr to be used in planner and goal searcher
425
- std::shared_ptr<OccupancyGridBasedCollisionDetector> occupancy_grid_map_;
478
+ // NOTE: this is latest occupancy_grid_map pointer which the local planner_data on
479
+ // onFreespaceParkingTimer thread storage may point to while calculation.
480
+ // onTimer/onFreespaceParkingTimer and their callees MUST NOT use this
481
+ std::shared_ptr<OccupancyGridBasedCollisionDetector> occupancy_grid_map_{nullptr };
426
482
427
483
// check stopped and stuck state
428
484
std::deque<nav_msgs::msg::Odometry::ConstSharedPtr> odometry_buffer_stopped_;
@@ -431,10 +487,10 @@ class GoalPlannerModule : public SceneModuleInterface
431
487
tier4_autoware_utils::LinearRing2d vehicle_footprint_;
432
488
433
489
std::recursive_mutex mutex_;
434
- ThreadSafeData thread_safe_data_;
490
+ // TODO(Mamoru Sobue): isSafePath() modifies ThreadSafeData::check_collision, avoid this mutable
491
+ mutable ThreadSafeData thread_safe_data_;
435
492
436
493
std::unique_ptr<LastApprovalData> last_approval_data_{nullptr };
437
- PreviousPullOverData prev_data_{};
438
494
439
495
// approximate distance from the start point to the end point of pull_over.
440
496
// this is used as an assumed value to decelerate, etc., before generating the actual path.
@@ -460,11 +516,12 @@ class GoalPlannerModule : public SceneModuleInterface
460
516
mutable PoseWithString debug_stop_pose_with_info_;
461
517
462
518
// collision check
463
- void initializeOccupancyGridMap ();
464
- void updateOccupancyGrid ();
465
- bool checkOccupancyGridCollision ( const PathWithLaneId & path ) const ;
519
+ bool checkOccupancyGridCollision (
520
+ const PathWithLaneId & path,
521
+ const std::shared_ptr<OccupancyGridBasedCollisionDetector> occupancy_grid_map ) const ;
466
522
bool checkObjectsCollision (
467
- const PathWithLaneId & path, const double collision_check_margin,
523
+ const PathWithLaneId & path, const std::shared_ptr<const PlannerData> planner_data,
524
+ const GoalPlannerParameters & parameters, const double collision_check_margin,
468
525
const bool extract_static_objects, const bool update_debug_data = false ) const ;
469
526
470
527
// goal seach
@@ -487,13 +544,39 @@ class GoalPlannerModule : public SceneModuleInterface
487
544
bool isStopped (
488
545
std::deque<nav_msgs::msg::Odometry::ConstSharedPtr> & odometry_buffer, const double time);
489
546
bool hasFinishedCurrentPath ();
490
- bool isOnModifiedGoal () const ;
547
+ bool isOnModifiedGoal (const Pose & current_pose, const GoalPlannerParameters & parameters ) const ;
491
548
double calcModuleRequestLength () const ;
492
- bool needPathUpdate (const double path_update_duration) const ;
493
- bool isStuck ();
494
- bool hasDecidedPath () const ;
495
- bool hasNotDecidedPath () const ;
496
- DecidingPathStatusWithStamp checkDecidingPathStatus () const ;
549
+ bool needPathUpdate (
550
+ const Pose & current_pose, const double path_update_duration,
551
+ const GoalPlannerParameters & parameters) const ;
552
+ bool isStuck (
553
+ const std::shared_ptr<const PlannerData> planner_data,
554
+ const std::shared_ptr<OccupancyGridBasedCollisionDetector> occupancy_grid_map,
555
+ const GoalPlannerParameters & parameters);
556
+ bool hasDecidedPath (
557
+ const std::shared_ptr<const PlannerData> planner_data,
558
+ const std::shared_ptr<OccupancyGridBasedCollisionDetector> occupancy_grid_map,
559
+ const GoalPlannerParameters & parameters,
560
+ const std::shared_ptr<EgoPredictedPathParams> & ego_predicted_path_params,
561
+ const std::shared_ptr<ObjectsFilteringParams> & objects_filtering_params,
562
+ const std::shared_ptr<SafetyCheckParams> & safety_check_params,
563
+ const std::shared_ptr<GoalSearcherBase> goal_searcher) const ;
564
+ bool hasNotDecidedPath (
565
+ const std::shared_ptr<const PlannerData> planner_data,
566
+ const std::shared_ptr<OccupancyGridBasedCollisionDetector> occupancy_grid_map,
567
+ const GoalPlannerParameters & parameters,
568
+ const std::shared_ptr<EgoPredictedPathParams> & ego_predicted_path_params,
569
+ const std::shared_ptr<ObjectsFilteringParams> & objects_filtering_params,
570
+ const std::shared_ptr<SafetyCheckParams> & safety_check_params,
571
+ const std::shared_ptr<GoalSearcherBase> goal_searcher) const ;
572
+ DecidingPathStatusWithStamp checkDecidingPathStatus (
573
+ const std::shared_ptr<const PlannerData> planner_data,
574
+ const std::shared_ptr<OccupancyGridBasedCollisionDetector> occupancy_grid_map,
575
+ const GoalPlannerParameters & parameters,
576
+ const std::shared_ptr<EgoPredictedPathParams> & ego_predicted_path_params,
577
+ const std::shared_ptr<ObjectsFilteringParams> & objects_filtering_params,
578
+ const std::shared_ptr<SafetyCheckParams> & safety_check_params,
579
+ const std::shared_ptr<GoalSearcherBase> goal_searcher) const ;
497
580
void decideVelocity ();
498
581
bool foundPullOverPath () const ;
499
582
void updateStatus (const BehaviorModuleOutput & output);
@@ -508,7 +591,10 @@ class GoalPlannerModule : public SceneModuleInterface
508
591
bool hasEnoughTimePassedSincePathUpdate (const double duration) const ;
509
592
510
593
// freespace parking
511
- bool planFreespacePath ();
594
+ bool planFreespacePath (
595
+ std::shared_ptr<const PlannerData> planner_data,
596
+ const std::shared_ptr<GoalSearcherBase> goal_searcher,
597
+ const std::shared_ptr<OccupancyGridBasedCollisionDetector> occupancy_grid_map);
512
598
bool canReturnToLaneParking ();
513
599
514
600
// plan pull over path
@@ -537,10 +623,12 @@ class GoalPlannerModule : public SceneModuleInterface
537
623
TurnSignalInfo calcTurnSignalInfo ();
538
624
std::optional<lanelet::Id> ignore_signal_{std::nullopt};
539
625
540
- std::optional<BehaviorModuleOutput> last_previous_module_output_{};
541
- bool hasPreviousModulePathShapeChanged () const ;
542
- bool hasDeviatedFromLastPreviousModulePath () const ;
543
- bool hasDeviatedFromCurrentPreviousModulePath () const ;
626
+ bool hasPreviousModulePathShapeChanged (const BehaviorModuleOutput & previous_module_output) const ;
627
+ bool hasDeviatedFromLastPreviousModulePath (
628
+ const std::shared_ptr<const PlannerData> planner_data) const ;
629
+ bool hasDeviatedFromCurrentPreviousModulePath (
630
+ const std::shared_ptr<const PlannerData> planner_data,
631
+ const BehaviorModuleOutput & previous_module_output) const ;
544
632
545
633
// timer for generating pull over path candidates in a separate thread
546
634
void onTimer ();
@@ -556,16 +644,22 @@ class GoalPlannerModule : public SceneModuleInterface
556
644
// safety check
557
645
void initializeSafetyCheckParameters ();
558
646
SafetyCheckParams createSafetyCheckParams () const ;
647
+ /*
559
648
void updateSafetyCheckTargetObjectsData(
560
649
const PredictedObjects & filtered_objects, const TargetObjectsOnLane & target_objects_on_lane,
561
650
const std::vector<PoseWithVelocityStamped> & ego_predicted_path) const;
651
+ */
562
652
/* *
563
653
* @brief Checks if the current path is safe.
564
654
* @return std::pair<bool, bool>
565
655
* first: If the path is safe for a certain period of time, true.
566
656
* second: If the path is safe in the current state, true.
567
657
*/
568
- std::pair<bool , bool > isSafePath () const ;
658
+ std::pair<bool , bool > isSafePath (
659
+ const std::shared_ptr<const PlannerData> planner_data, const GoalPlannerParameters & parameters,
660
+ const std::shared_ptr<EgoPredictedPathParams> & ego_predicted_path_params,
661
+ const std::shared_ptr<ObjectsFilteringParams> & objects_filtering_params,
662
+ const std::shared_ptr<SafetyCheckParams> & safety_check_params) const ;
569
663
570
664
// debug
571
665
void setDebugData ();
0 commit comments