Skip to content

Commit 13e6530

Browse files
authored
refactor(goal planner): hold modified_goal in PullOverPath ,copy modified goal once from background thread (autowarefoundation#9006)
refactor(goal_planner): save modified_goal_pose in PullOverPlannerBase Signed-off-by: Mamoru Sobue <mamoru.sobue@tier4.jp>
1 parent f85bf32 commit 13e6530

File tree

9 files changed

+60
-51
lines changed

9 files changed

+60
-51
lines changed

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ class FreespacePullOver : public PullOverPlannerBase
3737
PullOverPlannerType getPlannerType() const override { return PullOverPlannerType::FREESPACE; }
3838

3939
std::optional<PullOverPath> plan(
40-
const size_t goal_id, const size_t id, const std::shared_ptr<const PlannerData> planner_data,
41-
const BehaviorModuleOutput & previous_module_output, const Pose & goal_pose) override;
40+
const GoalCandidate & modified_goal_pose, const size_t id,
41+
const std::shared_ptr<const PlannerData> planner_data,
42+
const BehaviorModuleOutput & previous_module_output) override;
4243

4344
protected:
4445
const double velocity_;

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

+3-2
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ class GeometricPullOver : public PullOverPlannerBase
4343
Pose getCl() const { return planner_.getCl(); }
4444

4545
std::optional<PullOverPath> plan(
46-
const size_t goal_id, const size_t id, const std::shared_ptr<const PlannerData> planner_data,
47-
const BehaviorModuleOutput & previous_module_output, const Pose & goal_pose) override;
46+
const GoalCandidate & modified_goal_pose, const size_t id,
47+
const std::shared_ptr<const PlannerData> planner_data,
48+
const BehaviorModuleOutput & previous_module_output) override;
4849

4950
std::vector<PullOverPath> generatePullOverPaths(
5051
const lanelet::ConstLanelets & road_lanes, const lanelet::ConstLanelets & shoulder_lanes,

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

+14-12
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#pragma once
1616

1717
#include "autoware/behavior_path_goal_planner_module/goal_planner_parameters.hpp"
18+
#include "autoware/behavior_path_goal_planner_module/goal_searcher_base.hpp"
1819
#include "autoware/behavior_path_planner_common/data_manager.hpp"
1920

2021
#include <geometry_msgs/msg/pose_stamped.hpp>
@@ -41,19 +42,20 @@ struct PullOverPath
4142
{
4243
public:
4344
static std::optional<PullOverPath> create(
44-
const PullOverPlannerType & type, const size_t goal_id, const size_t id,
45+
const PullOverPlannerType & type, const size_t id,
4546
const std::vector<PathWithLaneId> & partial_paths, const Pose & start_pose,
46-
const Pose & end_pose,
47+
const GoalCandidate & modified_goal_pose,
4748
const std::vector<std::pair<double, double>> & pairs_terminal_velocity_and_accel);
4849

4950
PullOverPath(const PullOverPath & other);
5051
PullOverPath & operator=(const PullOverPath & other) = default;
5152

5253
PullOverPlannerType type() const { return type_; }
53-
size_t goal_id() const { return goal_id_; }
54+
size_t goal_id() const { return modified_goal_pose_.id; }
5455
size_t id() const { return id_; }
5556
Pose start_pose() const { return start_pose_; }
56-
Pose end_pose() const { return end_pose_; }
57+
Pose end_pose() const { return modified_goal_pose_.goal_pose; }
58+
GoalCandidate modified_goal_pose() const { return modified_goal_pose_; }
5759

5860
std::vector<PathWithLaneId> & partial_paths() { return partial_paths_; }
5961
const std::vector<PathWithLaneId> & partial_paths() const { return partial_paths_; }
@@ -86,19 +88,18 @@ struct PullOverPath
8688

8789
private:
8890
PullOverPath(
89-
const PullOverPlannerType & type, const size_t goal_id, const size_t id,
90-
const Pose & start_pose, const Pose & end_pose,
91-
const std::vector<PathWithLaneId> & partial_paths, const PathWithLaneId & full_path,
92-
const PathWithLaneId & parking_path, const std::vector<double> & full_path_curvatures,
91+
const PullOverPlannerType & type, const size_t id, const Pose & start_pose,
92+
const GoalCandidate & modified_goal_pose, const std::vector<PathWithLaneId> & partial_paths,
93+
const PathWithLaneId & full_path, const PathWithLaneId & parking_path,
94+
const std::vector<double> & full_path_curvatures,
9395
const std::vector<double> & parking_path_curvatures, const double full_path_max_curvature,
9496
const double parking_path_max_curvature,
9597
const std::vector<std::pair<double, double>> & pairs_terminal_velocity_and_accel);
9698

9799
PullOverPlannerType type_;
98-
size_t goal_id_;
100+
GoalCandidate modified_goal_pose_;
99101
size_t id_;
100102
Pose start_pose_;
101-
Pose end_pose_;
102103

103104
std::vector<PathWithLaneId> partial_paths_;
104105
PathWithLaneId full_path_;
@@ -126,8 +127,9 @@ class PullOverPlannerBase
126127

127128
virtual PullOverPlannerType getPlannerType() const = 0;
128129
virtual std::optional<PullOverPath> plan(
129-
const size_t goal_id, const size_t id, const std::shared_ptr<const PlannerData> planner_data,
130-
const BehaviorModuleOutput & previous_module_output, const Pose & goal_pose) = 0;
130+
const GoalCandidate & modified_goal_pose, const size_t id,
131+
const std::shared_ptr<const PlannerData> planner_data,
132+
const BehaviorModuleOutput & previous_module_output) = 0;
131133

132134
protected:
133135
const autoware::vehicle_info_utils::VehicleInfo vehicle_info_;

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

+6-5
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,9 @@ class ShiftPullOver : public PullOverPlannerBase
3636
const LaneDepartureChecker & lane_departure_checker);
3737
PullOverPlannerType getPlannerType() const override { return PullOverPlannerType::SHIFT; };
3838
std::optional<PullOverPath> plan(
39-
const size_t goal_id, const size_t id, const std::shared_ptr<const PlannerData> planner_data,
40-
const BehaviorModuleOutput & previous_module_output, const Pose & goal_pose) override;
39+
const GoalCandidate & modified_goal_pose, const size_t id,
40+
const std::shared_ptr<const PlannerData> planner_data,
41+
const BehaviorModuleOutput & previous_module_output) override;
4142

4243
protected:
4344
PathWithLaneId generateReferencePath(
@@ -46,10 +47,10 @@ class ShiftPullOver : public PullOverPlannerBase
4647
std::optional<PathWithLaneId> cropPrevModulePath(
4748
const PathWithLaneId & prev_module_path, const Pose & shift_end_pose) const;
4849
std::optional<PullOverPath> generatePullOverPath(
49-
const size_t goal_id, const size_t id, const std::shared_ptr<const PlannerData> planner_data,
50+
const GoalCandidate & goal_candidate, const size_t id,
51+
const std::shared_ptr<const PlannerData> planner_data,
5052
const BehaviorModuleOutput & previous_module_output, const lanelet::ConstLanelets & road_lanes,
51-
const lanelet::ConstLanelets & shoulder_lanes, const Pose & goal_pose,
52-
const double lateral_jerk) const;
53+
const lanelet::ConstLanelets & shoulder_lanes, const double lateral_jerk) const;
5354
static double calcBeforeShiftedArcLength(
5455
const PathWithLaneId & path, const double after_shifted_arc_length, const double dr);
5556
static std::vector<double> splineTwoPoints(

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/goal_planner_module.cpp

+4-6
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,7 @@ void GoalPlannerModule::onTimer()
303303
const std::shared_ptr<PullOverPlannerBase> & planner,
304304
const GoalCandidate & goal_candidate) {
305305
const auto pull_over_path = planner->plan(
306-
goal_candidate.id, path_candidates.size(), local_planner_data, previous_module_output,
307-
goal_candidate.goal_pose);
306+
goal_candidate, path_candidates.size(), local_planner_data, previous_module_output);
308307
if (pull_over_path) {
309308
// calculate absolute maximum curvature of parking path(start pose to end pose) for path
310309
// priority
@@ -803,9 +802,8 @@ bool GoalPlannerModule::planFreespacePath(
803802
continue;
804803
}
805804
const auto freespace_path = freespace_planner_->plan(
806-
goal_candidate.id, 0, planner_data,
807-
BehaviorModuleOutput{}, // NOTE: not used so passing {} is OK
808-
goal_candidate.goal_pose);
805+
goal_candidate, 0, planner_data, BehaviorModuleOutput{} // NOTE: not used so passing {} is OK
806+
);
809807
if (!freespace_path) {
810808
continue;
811809
}
@@ -1824,7 +1822,7 @@ TurnSignalInfo GoalPlannerModule::calcTurnSignalInfo(const PullOverContextData &
18241822
return ignore_signal_.value() == id;
18251823
};
18261824

1827-
const auto update_ignore_signal = [this](const lanelet::Id & id, const bool is_ignore) {
1825+
const auto update_ignore_signal = [](const lanelet::Id & id, const bool is_ignore) {
18281826
return is_ignore ? std::make_optional(id) : std::nullopt;
18291827
};
18301828

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/pull_over_planner/freespace_pull_over.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ FreespacePullOver::FreespacePullOver(
5757
}
5858

5959
std::optional<PullOverPath> FreespacePullOver::plan(
60-
const size_t goal_id, const size_t id, const std::shared_ptr<const PlannerData> planner_data,
61-
[[maybe_unused]] const BehaviorModuleOutput & previous_module_output, const Pose & goal_pose)
60+
const GoalCandidate & modified_goal_pose, const size_t id,
61+
const std::shared_ptr<const PlannerData> planner_data,
62+
[[maybe_unused]] const BehaviorModuleOutput & previous_module_output)
6263
{
6364
const Pose & current_pose = planner_data->self_odometry->pose.pose;
6465

@@ -67,6 +68,7 @@ std::optional<PullOverPath> FreespacePullOver::plan(
6768
// offset goal pose to make straight path near goal for improving parking precision
6869
// todo: support straight path when using back
6970
constexpr double straight_distance = 1.0;
71+
const auto & goal_pose = modified_goal_pose.goal_pose;
7072
const Pose end_pose =
7173
use_back_ ? goal_pose
7274
: autoware::universe_utils::calcOffsetPose(goal_pose, -straight_distance, 0.0, 0.0);
@@ -146,7 +148,7 @@ std::optional<PullOverPath> FreespacePullOver::plan(
146148
}
147149

148150
auto pull_over_path_opt = PullOverPath::create(
149-
getPlannerType(), goal_id, id, partial_paths, current_pose, goal_pose,
151+
getPlannerType(), id, partial_paths, current_pose, modified_goal_pose,
150152
pairs_terminal_velocity_and_accel);
151153
if (!pull_over_path_opt) {
152154
return {};

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/pull_over_planner/geometric_pull_over.cpp

+6-4
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,13 @@ GeometricPullOver::GeometricPullOver(
3838
}
3939

4040
std::optional<PullOverPath> GeometricPullOver::plan(
41-
const size_t goal_id, const size_t id, const std::shared_ptr<const PlannerData> planner_data,
42-
[[maybe_unused]] const BehaviorModuleOutput & previous_module_output, const Pose & goal_pose)
41+
const GoalCandidate & modified_goal_pose, const size_t id,
42+
const std::shared_ptr<const PlannerData> planner_data,
43+
[[maybe_unused]] const BehaviorModuleOutput & previous_module_output)
4344
{
4445
const auto & route_handler = planner_data->route_handler;
4546

47+
const auto & goal_pose = modified_goal_pose.goal_pose;
4648
// prepare road nad shoulder lanes
4749
const auto road_lanes = utils::getExtendedCurrentLanes(
4850
planner_data, parameters_.backward_goal_search_length, parameters_.forward_goal_search_length,
@@ -73,8 +75,8 @@ std::optional<PullOverPath> GeometricPullOver::plan(
7375
if (lane_departure_checker_.checkPathWillLeaveLane(lanes, arc_path)) return {};
7476

7577
auto pull_over_path_opt = PullOverPath::create(
76-
getPlannerType(), goal_id, id, planner_.getPaths(), planner_.getStartPose(),
77-
planner_.getArcEndPose(), planner_.getPairsTerminalVelocityAndAccel());
78+
getPlannerType(), id, planner_.getPaths(), planner_.getStartPose(), modified_goal_pose,
79+
planner_.getPairsTerminalVelocityAndAccel());
7880
if (!pull_over_path_opt) {
7981
return {};
8082
}

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/pull_over_planner/pull_over_planner_base.cpp

+8-9
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,9 @@ namespace autoware::behavior_path_planner
1818
{
1919

2020
std::optional<PullOverPath> PullOverPath::create(
21-
const PullOverPlannerType & type, const size_t goal_id, const size_t id,
22-
const std::vector<PathWithLaneId> & partial_paths, const Pose & start_pose, const Pose & end_pose,
21+
const PullOverPlannerType & type, const size_t id,
22+
const std::vector<PathWithLaneId> & partial_paths, const Pose & start_pose,
23+
const GoalCandidate & modified_goal_pose,
2324
const std::vector<std::pair<double, double>> & pairs_terminal_velocity_and_accel)
2425
{
2526
if (partial_paths.empty()) {
@@ -76,17 +77,16 @@ std::optional<PullOverPath> PullOverPath::create(
7677
calculateCurvaturesAndMax(parking_path);
7778

7879
return PullOverPath(
79-
type, goal_id, id, start_pose, end_pose, partial_paths, full_path, parking_path,
80+
type, id, start_pose, modified_goal_pose, partial_paths, full_path, parking_path,
8081
full_path_curvatures, parking_path_curvatures, full_path_max_curvature,
8182
parking_path_max_curvature, pairs_terminal_velocity_and_accel);
8283
}
8384

8485
PullOverPath::PullOverPath(const PullOverPath & other)
8586
: type_(other.type_),
86-
goal_id_(other.goal_id_),
87+
modified_goal_pose_(other.modified_goal_pose_),
8788
id_(other.id_),
8889
start_pose_(other.start_pose_),
89-
end_pose_(other.end_pose_),
9090
partial_paths_(other.partial_paths_),
9191
full_path_(other.full_path_),
9292
parking_path_(other.parking_path_),
@@ -100,18 +100,17 @@ PullOverPath::PullOverPath(const PullOverPath & other)
100100
}
101101

102102
PullOverPath::PullOverPath(
103-
const PullOverPlannerType & type, const size_t goal_id, const size_t id, const Pose & start_pose,
104-
const Pose & end_pose, const std::vector<PathWithLaneId> & partial_paths,
103+
const PullOverPlannerType & type, const size_t id, const Pose & start_pose,
104+
const GoalCandidate & modified_goal_pose, const std::vector<PathWithLaneId> & partial_paths,
105105
const PathWithLaneId & full_path, const PathWithLaneId & parking_path,
106106
const std::vector<double> & full_path_curvatures,
107107
const std::vector<double> & parking_path_curvatures, const double full_path_max_curvature,
108108
const double parking_path_max_curvature,
109109
const std::vector<std::pair<double, double>> & pairs_terminal_velocity_and_accel)
110110
: type_(type),
111-
goal_id_(goal_id),
111+
modified_goal_pose_(modified_goal_pose),
112112
id_(id),
113113
start_pose_(start_pose),
114-
end_pose_(end_pose),
115114
partial_paths_(partial_paths),
116115
full_path_(full_path),
117116
parking_path_(parking_path),

planning/behavior_path_planner/autoware_behavior_path_goal_planner_module/src/pull_over_planner/shift_pull_over.cpp

+11-8
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,9 @@ ShiftPullOver::ShiftPullOver(
3535
{
3636
}
3737
std::optional<PullOverPath> ShiftPullOver::plan(
38-
const size_t goal_id, const size_t id, const std::shared_ptr<const PlannerData> planner_data,
39-
const BehaviorModuleOutput & previous_module_output, const Pose & goal_pose)
38+
const GoalCandidate & modified_goal_pose, const size_t id,
39+
const std::shared_ptr<const PlannerData> planner_data,
40+
const BehaviorModuleOutput & previous_module_output)
4041
{
4142
const auto & route_handler = planner_data->route_handler;
4243
const double min_jerk = parameters_.minimum_lateral_jerk;
@@ -59,7 +60,7 @@ std::optional<PullOverPath> ShiftPullOver::plan(
5960
// find safe one from paths with different jerk
6061
for (double lateral_jerk = min_jerk; lateral_jerk <= max_jerk; lateral_jerk += jerk_resolution) {
6162
const auto pull_over_path = generatePullOverPath(
62-
goal_id, id, planner_data, previous_module_output, road_lanes, pull_over_lanes, goal_pose,
63+
modified_goal_pose, id, planner_data, previous_module_output, road_lanes, pull_over_lanes,
6364
lateral_jerk);
6465
if (!pull_over_path) continue;
6566
return *pull_over_path;
@@ -127,14 +128,16 @@ std::optional<PathWithLaneId> ShiftPullOver::cropPrevModulePath(
127128
}
128129

129130
std::optional<PullOverPath> ShiftPullOver::generatePullOverPath(
130-
const size_t goal_id, const size_t id, const std::shared_ptr<const PlannerData> planner_data,
131+
const GoalCandidate & goal_candidate, const size_t id,
132+
const std::shared_ptr<const PlannerData> planner_data,
131133
const BehaviorModuleOutput & previous_module_output, const lanelet::ConstLanelets & road_lanes,
132-
const lanelet::ConstLanelets & shoulder_lanes, const Pose & goal_pose,
133-
const double lateral_jerk) const
134+
const lanelet::ConstLanelets & shoulder_lanes, const double lateral_jerk) const
134135
{
135136
const double pull_over_velocity = parameters_.pull_over_velocity;
136137
const double after_shift_straight_distance = parameters_.after_shift_straight_distance;
137138

139+
const auto & goal_pose = goal_candidate.goal_pose;
140+
138141
// shift end pose is longitudinal offset from goal pose to improve parking angle accuracy
139142
const Pose shift_end_pose =
140143
autoware::universe_utils::calcOffsetPose(goal_pose, -after_shift_straight_distance, 0, 0);
@@ -256,8 +259,8 @@ std::optional<PullOverPath> ShiftPullOver::generatePullOverPath(
256259

257260
// set pull over path
258261
auto pull_over_path_opt = PullOverPath::create(
259-
getPlannerType(), goal_id, id, {shifted_path.path}, path_shifter.getShiftLines().front().start,
260-
path_shifter.getShiftLines().front().end, {std::make_pair(pull_over_velocity, 0)});
262+
getPlannerType(), id, {shifted_path.path}, path_shifter.getShiftLines().front().start,
263+
goal_candidate, {std::make_pair(pull_over_velocity, 0)});
261264

262265
if (!pull_over_path_opt) {
263266
return {};

0 commit comments

Comments
 (0)