Skip to content

Commit 6e6cb40

Browse files
kosuke55kyoichi-sugaharapre-commit-ci[bot]
authored
refactor(goal_planner): add updateStatus and reduce variables (#5546)
* refactor(goal_planner): add updateStatus and reduce variables Signed-off-by: kosuke55 <kosuke.tnp@gmail.com> refactor Signed-off-by: kosuke55 <kosuke.tnp@gmail.com> refactor Signed-off-by: kosuke55 <kosuke.tnp@gmail.com> * move to updatedata Signed-off-by: kosuke55 <kosuke.tnp@gmail.com> * Update planning/behavior_path_planner/src/scene_module/goal_planner/goal_planner_module.cpp Co-authored-by: Kyoichi Sugahara <kyoichi.sugahara@tier4.jp> * style(pre-commit): autofix --------- Signed-off-by: kosuke55 <kosuke.tnp@gmail.com> Co-authored-by: Kyoichi Sugahara <kyoichi.sugahara@tier4.jp> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent ef0569f commit 6e6cb40

File tree

3 files changed

+152
-177
lines changed

3 files changed

+152
-177
lines changed

planning/behavior_path_planner/include/behavior_path_planner/scene_module/goal_planner/goal_planner_module.hpp

+19-37
Original file line numberDiff line numberDiff line change
@@ -93,50 +93,30 @@ class PullOverStatus
9393
void reset()
9494
{
9595
lane_parking_pull_over_path_ = nullptr;
96-
current_path_idx_ = 0;
97-
require_increment_ = true;
9896
prev_stop_path_ = nullptr;
9997
prev_stop_path_after_approval_ = nullptr;
100-
current_lanes_.clear();
101-
pull_over_lanes_.clear();
102-
lanes_.clear();
103-
has_decided_path_ = false;
104-
is_safe_dynamic_objects_ = false;
98+
99+
is_safe_ = false;
105100
prev_found_path_ = false;
106-
prev_is_safe_dynamic_objects_ = false;
107-
has_decided_velocity_ = false;
101+
prev_is_safe_ = false;
108102
}
109103

110104
DEFINE_SETTER_GETTER(std::shared_ptr<PullOverPath>, lane_parking_pull_over_path)
111-
DEFINE_SETTER_GETTER(size_t, current_path_idx)
112-
DEFINE_SETTER_GETTER(bool, require_increment)
113105
DEFINE_SETTER_GETTER(std::shared_ptr<PathWithLaneId>, prev_stop_path)
114106
DEFINE_SETTER_GETTER(std::shared_ptr<PathWithLaneId>, prev_stop_path_after_approval)
115-
DEFINE_SETTER_GETTER(lanelet::ConstLanelets, current_lanes)
116-
DEFINE_SETTER_GETTER(lanelet::ConstLanelets, pull_over_lanes)
117-
DEFINE_SETTER_GETTER(std::vector<DrivableLanes>, lanes)
118-
DEFINE_SETTER_GETTER(bool, has_decided_path)
119-
DEFINE_SETTER_GETTER(bool, is_safe_dynamic_objects)
107+
DEFINE_SETTER_GETTER(bool, is_safe)
120108
DEFINE_SETTER_GETTER(bool, prev_found_path)
121-
DEFINE_SETTER_GETTER(bool, prev_is_safe_dynamic_objects)
122-
DEFINE_SETTER_GETTER(bool, has_decided_velocity)
109+
DEFINE_SETTER_GETTER(bool, prev_is_safe)
123110
DEFINE_SETTER_GETTER(Pose, refined_goal_pose)
124111
DEFINE_SETTER_GETTER(Pose, closest_goal_candidate_pose)
125112

126113
private:
127114
std::shared_ptr<PullOverPath> lane_parking_pull_over_path_{nullptr};
128-
size_t current_path_idx_{0};
129-
bool require_increment_{true};
130115
std::shared_ptr<PathWithLaneId> prev_stop_path_{nullptr};
131116
std::shared_ptr<PathWithLaneId> prev_stop_path_after_approval_{nullptr};
132-
lanelet::ConstLanelets current_lanes_{};
133-
lanelet::ConstLanelets pull_over_lanes_{};
134-
std::vector<DrivableLanes> lanes_{};
135-
bool has_decided_path_{false};
136-
bool is_safe_dynamic_objects_{false};
117+
bool is_safe_{false};
137118
bool prev_found_path_{false};
138-
bool prev_is_safe_dynamic_objects_{false};
139-
bool has_decided_velocity_{false};
119+
bool prev_is_safe_{false};
140120

141121
Pose refined_goal_pose_{};
142122
Pose closest_goal_candidate_pose_{};
@@ -177,6 +157,10 @@ class ThreadSafeData
177157
bool incrementPathIndex()
178158
{
179159
const std::lock_guard<std::recursive_mutex> lock(mutex_);
160+
if (!pull_over_path_) {
161+
return false;
162+
}
163+
180164
if (pull_over_path_->incrementPathIndex()) {
181165
last_path_idx_increment_time_ = clock_->now();
182166
return true;
@@ -393,10 +377,10 @@ class GoalPlannerModule : public SceneModuleInterface
393377
void decelerateForTurnSignal(const Pose & stop_pose, PathWithLaneId & path) const;
394378
void decelerateBeforeSearchStart(
395379
const Pose & search_start_offset_pose, PathWithLaneId & path) const;
396-
PathWithLaneId generateStopPath();
397-
PathWithLaneId generateFeasibleStopPath();
380+
PathWithLaneId generateStopPath() const;
381+
PathWithLaneId generateFeasibleStopPath() const;
398382

399-
void keepStoppedWithCurrentPath(PathWithLaneId & path);
383+
void keepStoppedWithCurrentPath(PathWithLaneId & path) const;
400384
double calcSignedArcLengthFromEgo(const PathWithLaneId & path, const Pose & pose) const;
401385

402386
// status
@@ -411,6 +395,7 @@ class GoalPlannerModule : public SceneModuleInterface
411395
bool hasDecidedPath() const;
412396
void decideVelocity();
413397
bool foundPullOverPath() const;
398+
void updateStatus(const BehaviorModuleOutput & output);
414399

415400
// validation
416401
bool hasEnoughDistance(const PullOverPath & pull_over_path) const;
@@ -433,16 +418,13 @@ class GoalPlannerModule : public SceneModuleInterface
433418
const std::vector<PullOverPath> & pull_over_path_candidates,
434419
const GoalCandidates & goal_candidates) const;
435420

436-
// deal with pull over partial paths
437-
void transitionToNextPathIfFinishingCurrentPath();
438-
439421
// lanes and drivable area
440-
void setLanes();
422+
std::vector<DrivableLanes> generateDrivableLanes() const;
441423
void setDrivableAreaInfo(BehaviorModuleOutput & output) const;
442424

443425
// output setter
444-
void setOutput(BehaviorModuleOutput & output);
445-
void setStopPath(BehaviorModuleOutput & output);
426+
void setOutput(BehaviorModuleOutput & output) const;
427+
void setStopPath(BehaviorModuleOutput & output) const;
446428

447429
/**
448430
* @brief Sets a stop path in the current path based on safety conditions and previous paths.
@@ -453,7 +435,7 @@ class GoalPlannerModule : public SceneModuleInterface
453435
*
454436
* @param output BehaviorModuleOutput
455437
*/
456-
void setStopPathFromCurrentPath(BehaviorModuleOutput & output);
438+
void setStopPathFromCurrentPath(BehaviorModuleOutput & output) const;
457439
void setModifiedGoal(BehaviorModuleOutput & output) const;
458440
void setTurnSignalInfo(BehaviorModuleOutput & output) const;
459441

planning/behavior_path_planner/include/behavior_path_planner/utils/goal_planner/pull_over_planner_base.hpp

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ struct PullOverPath
5353
Pose end_pose{};
5454
std::vector<Pose> debug_poses{};
5555
size_t goal_id{};
56+
bool decided_velocity{false};
5657

5758
PathWithLaneId getFullPath() const
5859
{

0 commit comments

Comments
 (0)