Skip to content

Commit b401eba

Browse files
authored
refactor(goal_planner): use the PullOverPath, PullOverPathCandidates copied from ThreadData to reduce access (autowarefoundation#8994)
Signed-off-by: Mamoru Sobue <mamoru.sobue@tier4.jp>
1 parent 8f09a11 commit b401eba

File tree

3 files changed

+168
-120
lines changed

3 files changed

+168
-120
lines changed

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/include/autoware/behavior_path_goal_planner_module/goal_planner_module.hpp

+21-10
Original file line numberDiff line numberDiff line change
@@ -110,15 +110,22 @@ struct PullOverContextData
110110
PullOverContextData() = delete;
111111
explicit PullOverContextData(
112112
const bool is_stable_safe_path, const PredictedObjects & static_objects,
113-
const PredictedObjects & dynamic_objects)
113+
const PredictedObjects & dynamic_objects, std::optional<PullOverPath> && pull_over_path_opt,
114+
const std::vector<PullOverPath> & pull_over_path_candidates)
114115
: is_stable_safe_path(is_stable_safe_path),
115116
static_target_objects(static_objects),
116-
dynamic_target_objects(dynamic_objects)
117+
dynamic_target_objects(dynamic_objects),
118+
pull_over_path_opt(pull_over_path_opt),
119+
pull_over_path_candidates(pull_over_path_candidates)
117120
{
118121
}
119122
const bool is_stable_safe_path;
120123
const PredictedObjects static_target_objects;
121124
const PredictedObjects dynamic_target_objects;
125+
// TODO(soblin): due to deceleratePath(), this cannot be const member(velocity is modified by it)
126+
std::optional<PullOverPath> pull_over_path_opt;
127+
const std::vector<PullOverPath> pull_over_path_candidates;
128+
// TODO(soblin): goal_candidate_from_thread, modifed_goal_pose_from_thread, closest_start_pose
122129
};
123130

124131
class GoalPlannerModule : public SceneModuleInterface
@@ -354,7 +361,7 @@ class GoalPlannerModule : public SceneModuleInterface
354361
void decelerateForTurnSignal(const Pose & stop_pose, PathWithLaneId & path) const;
355362
void decelerateBeforeSearchStart(
356363
const Pose & search_start_offset_pose, PathWithLaneId & path) const;
357-
PathWithLaneId generateStopPath() const;
364+
PathWithLaneId generateStopPath(const PullOverContextData & context_data) const;
358365
PathWithLaneId generateFeasibleStopPath(const PathWithLaneId & path) const;
359366

360367
void keepStoppedWithCurrentPath(PathWithLaneId & path) const;
@@ -364,7 +371,7 @@ class GoalPlannerModule : public SceneModuleInterface
364371
bool isStopped();
365372
bool isStopped(
366373
std::deque<nav_msgs::msg::Odometry::ConstSharedPtr> & odometry_buffer, const double time);
367-
bool hasFinishedCurrentPath();
374+
bool hasFinishedCurrentPath(const PullOverContextData & ctx_data);
368375
bool isOnModifiedGoal(const Pose & current_pose, const GoalPlannerParameters & parameters) const;
369376
double calcModuleRequestLength() const;
370377
bool needPathUpdate(
@@ -406,16 +413,18 @@ class GoalPlannerModule : public SceneModuleInterface
406413

407414
// lanes and drivable area
408415
std::vector<DrivableLanes> generateDrivableLanes() const;
409-
void setDrivableAreaInfo(BehaviorModuleOutput & output) const;
416+
void setDrivableAreaInfo(
417+
const PullOverContextData & context_data, BehaviorModuleOutput & output) const;
410418

411419
// output setter
412420
void setOutput(const PullOverContextData & context_data, BehaviorModuleOutput & output);
413421

414-
void setModifiedGoal(BehaviorModuleOutput & output) const;
415-
void setTurnSignalInfo(BehaviorModuleOutput & output);
422+
void setModifiedGoal(
423+
const PullOverContextData & context_data, BehaviorModuleOutput & output) const;
424+
void setTurnSignalInfo(const PullOverContextData & context_data, BehaviorModuleOutput & output);
416425

417426
// new turn signal
418-
TurnSignalInfo calcTurnSignalInfo();
427+
TurnSignalInfo calcTurnSignalInfo(const PullOverContextData & context_data);
419428
std::optional<lanelet::Id> ignore_signal_{std::nullopt};
420429

421430
bool hasPreviousModulePathShapeChanged(const BehaviorModuleOutput & previous_module_output) const;
@@ -431,10 +440,12 @@ class GoalPlannerModule : public SceneModuleInterface
431440

432441
// steering factor
433442
void updateSteeringFactor(
434-
const std::array<Pose, 2> & pose, const std::array<double, 2> distance, const uint16_t type);
443+
const PullOverContextData & context_data, const std::array<Pose, 2> & pose,
444+
const std::array<double, 2> distance, const uint16_t type);
435445

436446
// rtc
437-
std::pair<double, double> calcDistanceToPathChange() const;
447+
std::pair<double, double> calcDistanceToPathChange(
448+
const PullOverContextData & context_data) const;
438449

439450
// safety check
440451
void initializeSafetyCheckParameters();

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/include/autoware/behavior_path_goal_planner_module/pull_over_planner/pull_over_planner_base.hpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ struct PullOverPath
4747
const std::vector<std::pair<double, double>> & pairs_terminal_velocity_and_accel);
4848

4949
PullOverPath(const PullOverPath & other);
50+
PullOverPath & operator=(const PullOverPath & other) = default;
5051

5152
PullOverPlannerType type() const { return type_; }
5253
size_t goal_id() const { return goal_id_; }
@@ -58,7 +59,7 @@ struct PullOverPath
5859
const std::vector<PathWithLaneId> & partial_paths() const { return partial_paths_; }
5960

6061
// TODO(soblin): use reference to avoid copy once thread-safe design is finished
61-
PathWithLaneId full_path() const { return full_path_; }
62+
const PathWithLaneId & full_path() const { return full_path_; }
6263
PathWithLaneId parking_path() const { return parking_path_; }
6364
std::vector<double> full_path_curvatures() { return full_path_curvatures_; }
6465
std::vector<double> parking_path_curvatures() const { return parking_path_curvatures_; }

0 commit comments

Comments
 (0)