Skip to content

Commit 60ac4c8

Browse files
zulfaqar-azmi-t4KhalilSelyan
authored and
KhalilSelyan
committed
refactor(lane_change): move struct to lane change namespace (#7841)
* move struct to lane change namespace Signed-off-by: Muhammad Zulfaqar Azmi <zulfaqar.azmi@tier4.jp> * Revert "move struct to lane change namespace" This reverts commit 306984a. Signed-off-by: Muhammad Zulfaqar Azmi <zulfaqar.azmi@tier4.jp> --------- Signed-off-by: Muhammad Zulfaqar Azmi <zulfaqar.azmi@tier4.jp>
1 parent a66d26f commit 60ac4c8

File tree

3 files changed

+99
-26
lines changed

3 files changed

+99
-26
lines changed

planning/behavior_path_planner/autoware_behavior_path_lane_change_module/include/autoware/behavior_path_lane_change_module/utils/base_class.hpp

+17-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ class LaneChangeBase
5050
LaneChangeBase(
5151
std::shared_ptr<LaneChangeParameters> parameters, LaneChangeModuleType type,
5252
Direction direction)
53-
: lane_change_parameters_{std::move(parameters)}, direction_{direction}, type_{type}
53+
: lane_change_parameters_{std::move(parameters)},
54+
common_data_ptr_{std::make_shared<lane_change::CommonData>()},
55+
direction_{direction},
56+
type_{type}
5457
{
5558
}
5659

@@ -151,7 +154,18 @@ class LaneChangeBase
151154

152155
bool isValidPath() const { return status_.is_valid_path; }
153156

154-
void setData(const std::shared_ptr<const PlannerData> & data) { planner_data_ = data; }
157+
void setData(const std::shared_ptr<const PlannerData> & data)
158+
{
159+
planner_data_ = data;
160+
if (!common_data_ptr_->bpp_param_ptr) {
161+
common_data_ptr_->bpp_param_ptr =
162+
std::make_shared<BehaviorPathPlannerParameters>(data->parameters);
163+
}
164+
common_data_ptr_->self_odometry_ptr = data->self_odometry;
165+
common_data_ptr_->route_handler_ptr = data->route_handler;
166+
common_data_ptr_->lc_param_ptr = lane_change_parameters_;
167+
common_data_ptr_->direction = direction_;
168+
}
155169

156170
void toNormalState() { current_lane_change_state_ = LaneChangeStates::Normal; }
157171

@@ -219,6 +233,7 @@ class LaneChangeBase
219233
std::shared_ptr<LaneChangeParameters> lane_change_parameters_{};
220234
std::shared_ptr<LaneChangePath> abort_path_{};
221235
std::shared_ptr<const PlannerData> planner_data_{};
236+
lane_change::CommonDataPtr common_data_ptr_{};
222237
BehaviorModuleOutput prev_module_output_{};
223238
std::optional<Pose> lane_change_stop_pose_{std::nullopt};
224239

planning/behavior_path_planner/autoware_behavior_path_lane_change_module/include/autoware/behavior_path_lane_change_module/utils/data_structs.hpp

+80-22
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,28 @@
1717
#include "autoware/behavior_path_planner_common/utils/path_safety_checker/path_safety_checker_parameters.hpp"
1818
#include "autoware/behavior_path_planner_common/utils/path_shifter/path_shifter.hpp"
1919

20+
#include <autoware/behavior_path_planner_common/parameters.hpp>
21+
#include <autoware/route_handler/route_handler.hpp>
2022
#include <interpolation/linear_interpolation.hpp>
2123

24+
#include <nav_msgs/msg/odometry.hpp>
25+
2226
#include <lanelet2_core/primitives/Lanelet.h>
2327
#include <lanelet2_core/primitives/Polygon.h>
2428

29+
#include <memory>
2530
#include <utility>
2631
#include <vector>
2732

28-
namespace autoware::behavior_path_planner
33+
namespace autoware::behavior_path_planner::lane_change
2934
{
35+
using geometry_msgs::msg::Pose;
36+
using geometry_msgs::msg::Twist;
37+
using nav_msgs::msg::Odometry;
38+
using route_handler::Direction;
39+
using route_handler::RouteHandler;
40+
using utils::path_safety_checker::ExtendedPredictedObjects;
41+
3042
struct LateralAccelerationMap
3143
{
3244
std::vector<double> base_vel;
@@ -68,7 +80,7 @@ struct LateralAccelerationMap
6880
}
6981
};
7082

71-
struct LaneChangeCancelParameters
83+
struct CancelParameters
7284
{
7385
bool enable_on_prepare_phase{true};
7486
bool enable_on_lane_changing_phase{false};
@@ -83,7 +95,7 @@ struct LaneChangeCancelParameters
8395
int unsafe_hysteresis_threshold{2};
8496
};
8597

86-
struct LaneChangeParameters
98+
struct Parameters
8799
{
88100
// trajectory generation
89101
double backward_lane_length{200.0};
@@ -92,8 +104,8 @@ struct LaneChangeParameters
92104
int lateral_acc_sampling_num{10};
93105

94106
// lane change parameters
95-
double backward_length_buffer_for_end_of_lane;
96-
double backward_length_buffer_for_blocking_object;
107+
double backward_length_buffer_for_end_of_lane{0.0};
108+
double backward_length_buffer_for_blocking_object{0.0};
97109
double lane_changing_lateral_jerk{0.5};
98110
double minimum_lane_changing_velocity{5.6};
99111
double lane_change_prepare_duration{4.0};
@@ -143,40 +155,40 @@ struct LaneChangeParameters
143155
utils::path_safety_checker::RSSparams rss_params_for_stuck{};
144156

145157
// abort
146-
LaneChangeCancelParameters cancel{};
158+
CancelParameters cancel{};
147159

148160
double finish_judge_lateral_threshold{0.2};
149161

150162
// debug marker
151163
bool publish_debug_marker{false};
152164
};
153165

154-
enum class LaneChangeStates {
166+
enum class States {
155167
Normal = 0,
156168
Cancel,
157169
Abort,
158170
Stop,
159171
};
160172

161-
struct LaneChangePhaseInfo
173+
struct PhaseInfo
162174
{
163175
double prepare{0.0};
164176
double lane_changing{0.0};
165177

166178
[[nodiscard]] double sum() const { return prepare + lane_changing; }
167179

168-
LaneChangePhaseInfo(const double _prepare, const double _lane_changing)
180+
PhaseInfo(const double _prepare, const double _lane_changing)
169181
: prepare(_prepare), lane_changing(_lane_changing)
170182
{
171183
}
172184
};
173185

174-
struct LaneChangeInfo
186+
struct Info
175187
{
176-
LaneChangePhaseInfo longitudinal_acceleration{0.0, 0.0};
177-
LaneChangePhaseInfo velocity{0.0, 0.0};
178-
LaneChangePhaseInfo duration{0.0, 0.0};
179-
LaneChangePhaseInfo length{0.0, 0.0};
188+
PhaseInfo longitudinal_acceleration{0.0, 0.0};
189+
PhaseInfo velocity{0.0, 0.0};
190+
PhaseInfo duration{0.0, 0.0};
191+
PhaseInfo length{0.0, 0.0};
180192

181193
lanelet::ConstLanelets current_lanes{};
182194
lanelet::ConstLanelets target_lanes{};
@@ -190,22 +202,19 @@ struct LaneChangeInfo
190202
double terminal_lane_changing_velocity{0.0};
191203
};
192204

193-
struct LaneChangeLanesFilteredObjects
205+
struct LanesObjects
194206
{
195-
utils::path_safety_checker::ExtendedPredictedObjects current_lane{};
196-
utils::path_safety_checker::ExtendedPredictedObjects target_lane{};
197-
utils::path_safety_checker::ExtendedPredictedObjects other_lane{};
207+
ExtendedPredictedObjects current_lane{};
208+
ExtendedPredictedObjects target_lane{};
209+
ExtendedPredictedObjects other_lane{};
198210
};
199211

200-
enum class LaneChangeModuleType {
212+
enum class ModuleType {
201213
NORMAL = 0,
202214
EXTERNAL_REQUEST,
203215
AVOIDANCE_BY_LANE_CHANGE,
204216
};
205-
} // namespace autoware::behavior_path_planner
206217

207-
namespace autoware::behavior_path_planner::lane_change
208-
{
209218
struct PathSafetyStatus
210219
{
211220
bool is_safe{true};
@@ -218,6 +227,55 @@ struct LanesPolygon
218227
std::optional<lanelet::BasicPolygon2d> target;
219228
std::vector<lanelet::BasicPolygon2d> target_backward;
220229
};
230+
231+
struct Lanes
232+
{
233+
lanelet::ConstLanelets current;
234+
lanelet::ConstLanelets target;
235+
std::vector<lanelet::ConstLanelets> preceding_target;
236+
};
237+
238+
struct CommonData
239+
{
240+
std::shared_ptr<RouteHandler> route_handler_ptr;
241+
Odometry::ConstSharedPtr self_odometry_ptr;
242+
std::shared_ptr<BehaviorPathPlannerParameters> bpp_param_ptr;
243+
std::shared_ptr<Parameters> lc_param_ptr;
244+
Lanes lanes;
245+
Direction direction;
246+
247+
[[nodiscard]] Pose get_ego_pose() const { return self_odometry_ptr->pose.pose; }
248+
249+
[[nodiscard]] Twist get_ego_twist() const { return self_odometry_ptr->twist.twist; }
250+
251+
[[nodiscard]] double get_ego_speed(bool use_norm = false) const
252+
{
253+
if (!use_norm) {
254+
return get_ego_twist().linear.x;
255+
}
256+
257+
const auto x = get_ego_twist().linear.x;
258+
const auto y = get_ego_twist().linear.y;
259+
return std::hypot(x, y);
260+
}
261+
};
262+
263+
using RouteHandlerPtr = std::shared_ptr<RouteHandler>;
264+
using BppParamPtr = std::shared_ptr<BehaviorPathPlannerParameters>;
265+
using LCParamPtr = std::shared_ptr<Parameters>;
266+
using CommonDataPtr = std::shared_ptr<CommonData>;
267+
using LanesPtr = std::shared_ptr<Lanes>;
221268
} // namespace autoware::behavior_path_planner::lane_change
222269

270+
namespace autoware::behavior_path_planner
271+
{
272+
using LaneChangeModuleType = lane_change::ModuleType;
273+
using LaneChangeParameters = lane_change::Parameters;
274+
using LaneChangeStates = lane_change::States;
275+
using LaneChangePhaseInfo = lane_change::PhaseInfo;
276+
using LaneChangeInfo = lane_change::Info;
277+
using LaneChangeLanesFilteredObjects = lane_change::LanesObjects;
278+
using LateralAccelerationMap = lane_change::LateralAccelerationMap;
279+
} // namespace autoware::behavior_path_planner
280+
223281
#endif // AUTOWARE__BEHAVIOR_PATH_LANE_CHANGE_MODULE__UTILS__DATA_STRUCTS_HPP_

planning/behavior_path_planner/autoware_behavior_path_lane_change_module/include/autoware/behavior_path_lane_change_module/utils/path.hpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ struct LaneChangePath
3131
{
3232
PathWithLaneId path{};
3333
ShiftedPath shifted_path{};
34-
PathWithLaneId prev_path{};
35-
LaneChangeInfo info{};
34+
LaneChangeInfo info;
35+
bool is_safe{false};
3636
};
3737
using LaneChangePaths = std::vector<LaneChangePath>;
3838

0 commit comments

Comments
 (0)