@@ -1092,20 +1092,81 @@ bool NormalLaneChange::get_lane_change_paths(LaneChangePaths & candidate_paths)
1092
1092
}
1093
1093
1094
1094
const auto & current_lanes = get_current_lanes ();
1095
- const auto & target_lanes = get_target_lanes ();
1096
1095
1097
- const auto sorted_lane_ids = utils::lane_change::get_sorted_lane_ids (common_data_ptr_);
1098
1096
const auto target_objects = get_target_objects (filtered_objects_, current_lanes);
1099
1097
1100
1098
const auto prepare_phase_metrics = get_prepare_metrics ();
1101
1099
1100
+ const auto sorted_lane_ids = utils::lane_change::get_sorted_lane_ids (common_data_ptr_);
1102
1101
if (
1103
1102
common_data_ptr_->lc_param_ptr ->frenet .enable &&
1104
1103
common_data_ptr_->transient_data .is_ego_near_current_terminal_start ) {
1105
- return get_path_using_frenet (prepare_phase_metrics, target_objects, candidate_paths);
1104
+ return get_path_using_frenet (
1105
+ prepare_phase_metrics, target_objects, sorted_lane_ids, candidate_paths);
1106
+ }
1107
+
1108
+ return get_path_using_path_shifter (
1109
+ prepare_phase_metrics, target_objects, sorted_lane_ids, candidate_paths);
1110
+ }
1111
+
1112
+ bool NormalLaneChange::get_path_using_frenet (
1113
+ const std::vector<LaneChangePhaseMetrics> & prepare_metrics,
1114
+ const lane_change::TargetObjects & target_objects,
1115
+ const std::vector<std::vector<int64_t >> & sorted_lane_ids,
1116
+ LaneChangePaths & candidate_paths) const
1117
+ {
1118
+ stop_watch_.tic (" frenet_candidates" );
1119
+ constexpr auto found_safe_path = true ;
1120
+ const auto frenet_candidates = utils::lane_change::generate_frenet_candidates (
1121
+ common_data_ptr_, prev_module_output_.path , prepare_metrics);
1122
+ RCLCPP_DEBUG (
1123
+ logger_, " Generated %lu candidate paths in %2.2f[us]" , frenet_candidates.size (),
1124
+ stop_watch_.toc (" frenet_candidates" ));
1125
+
1126
+ for (const auto & frenet_candidate : frenet_candidates) {
1127
+ std::optional<LaneChangePath> candidate_path_opt;
1128
+ try {
1129
+ candidate_path_opt =
1130
+ utils::lane_change::get_candidate_path (frenet_candidate, common_data_ptr_, sorted_lane_ids);
1131
+ } catch (const std::exception & e) {
1132
+ RCLCPP_DEBUG (logger_, " %s" , e.what ());
1133
+ }
1134
+
1135
+ if (!candidate_path_opt) {
1136
+ continue ;
1137
+ }
1138
+ try {
1139
+ if (check_candidate_path_safety (*candidate_path_opt, target_objects)) {
1140
+ RCLCPP_DEBUG (
1141
+ logger_, " Found safe path after %lu candidate(s). Total time: %2.2f[us]" ,
1142
+ frenet_candidates.size (), stop_watch_.toc (" frenet_candidates" ));
1143
+ candidate_paths.push_back (*candidate_path_opt);
1144
+ return found_safe_path;
1145
+ }
1146
+ } catch (const std::exception & e) {
1147
+ RCLCPP_DEBUG (logger_, " %s" , e.what ());
1148
+ }
1149
+
1150
+ if (candidate_paths.empty ()) {
1151
+ candidate_paths.push_back (*candidate_path_opt);
1152
+ }
1106
1153
}
1154
+
1155
+ RCLCPP_DEBUG (
1156
+ logger_, " No safe path after %lu candidate(s). Total time: %2.2f[us]" , frenet_candidates.size (),
1157
+ stop_watch_.toc (" frenet_candidates" ));
1158
+ return !found_safe_path;
1159
+ }
1160
+
1161
+ bool NormalLaneChange::get_path_using_path_shifter (
1162
+ const std::vector<LaneChangePhaseMetrics> & prepare_metrics,
1163
+ const lane_change::TargetObjects & target_objects,
1164
+ const std::vector<std::vector<int64_t >> & sorted_lane_ids,
1165
+ LaneChangePaths & candidate_paths) const
1166
+ {
1167
+ const auto & target_lanes = get_target_lanes ();
1107
1168
candidate_paths.reserve (
1108
- prepare_phase_metrics .size () * lane_change_parameters_->trajectory .lat_acc_sampling_num );
1169
+ prepare_metrics .size () * lane_change_parameters_->trajectory .lat_acc_sampling_num );
1109
1170
1110
1171
const bool only_tl = getStopTime () >= lane_change_parameters_->th_stop_time ;
1111
1172
const auto dist_to_next_regulatory_element =
@@ -1124,7 +1185,7 @@ bool NormalLaneChange::get_lane_change_paths(LaneChangePaths & candidate_paths)
1124
1185
return lc_diff > lane_change_parameters_->trajectory .th_lane_changing_length_diff ;
1125
1186
};
1126
1187
1127
- for (const auto & prep_metric : prepare_phase_metrics ) {
1188
+ for (const auto & prep_metric : prepare_metrics ) {
1128
1189
const auto debug_print = [&](const std::string & s) {
1129
1190
RCLCPP_DEBUG (
1130
1191
logger_, " %s | prep_time: %.5f | lon_acc: %.5f | prep_len: %.5f" , s.c_str (),
@@ -1199,53 +1260,6 @@ bool NormalLaneChange::get_lane_change_paths(LaneChangePaths & candidate_paths)
1199
1260
return false ;
1200
1261
}
1201
1262
1202
- bool NormalLaneChange::get_path_using_frenet (
1203
- const std::vector<LaneChangePhaseMetrics> & prepare_metrics,
1204
- const lane_change::TargetObjects & target_objects, LaneChangePaths & candidate_paths) const
1205
- {
1206
- stop_watch_.tic (" frenet_candidates" );
1207
- constexpr auto found_safe_path = true ;
1208
- const auto frenet_candidates = utils::lane_change::generate_frenet_candidates (
1209
- common_data_ptr_, prev_module_output_.path , prepare_metrics);
1210
- RCLCPP_DEBUG (
1211
- logger_, " Generated %lu candidate paths in %2.2f[us]" , frenet_candidates.size (),
1212
- stop_watch_.toc (" frenet_candidates" ));
1213
-
1214
- for (const auto & frenet_candidate : frenet_candidates) {
1215
- std::optional<LaneChangePath> candidate_path_opt;
1216
- try {
1217
- candidate_path_opt =
1218
- utils::lane_change::get_candidate_path (frenet_candidate, common_data_ptr_);
1219
- } catch (const std::exception & e) {
1220
- RCLCPP_DEBUG (logger_, " %s" , e.what ());
1221
- }
1222
-
1223
- if (!candidate_path_opt) {
1224
- continue ;
1225
- }
1226
- try {
1227
- if (check_candidate_path_safety (*candidate_path_opt, target_objects)) {
1228
- RCLCPP_DEBUG (
1229
- logger_, " Found safe path after %lu candidate(s). Total time: %2.2f[us]" ,
1230
- frenet_candidates.size (), stop_watch_.toc (" frenet_candidates" ));
1231
- candidate_paths.push_back (*candidate_path_opt);
1232
- return found_safe_path;
1233
- }
1234
- } catch (const std::exception & e) {
1235
- RCLCPP_DEBUG (logger_, " %s" , e.what ());
1236
- }
1237
-
1238
- if (candidate_paths.empty ()) {
1239
- candidate_paths.push_back (*candidate_path_opt);
1240
- }
1241
- }
1242
-
1243
- RCLCPP_DEBUG (
1244
- logger_, " No safe path after %lu candidate(s). Total time: %2.2f[us]" , frenet_candidates.size (),
1245
- stop_watch_.toc (" frenet_candidates" ));
1246
- return !found_safe_path;
1247
- }
1248
-
1249
1263
bool NormalLaneChange::check_candidate_path_safety (
1250
1264
const LaneChangePath & candidate_path, const lane_change::TargetObjects & target_objects) const
1251
1265
{
0 commit comments