@@ -1215,103 +1215,70 @@ bool StartPlannerModule::hasFinishedCurrentPath()
1215
1215
return is_near_target && isStopped ();
1216
1216
}
1217
1217
1218
- TurnSignalInfo StartPlannerModule::calcTurnSignalInfo () const
1218
+ TurnSignalInfo StartPlannerModule::calcTurnSignalInfo ()
1219
1219
{
1220
- TurnSignalInfo turn_signal{}; // output
1220
+ const auto path = getFullPath ();
1221
+ if (path.points .empty ()) return getPreviousModuleOutput ().turn_signal_info ;
1221
1222
1222
1223
const Pose & current_pose = planner_data_->self_odometry ->pose .pose ;
1223
- const Pose & start_pose = status_.pull_out_path .start_pose ;
1224
- const Pose & end_pose = status_.pull_out_path .end_pose ;
1225
-
1226
- // turn on hazard light when backward driving
1227
- if (!status_.driving_forward ) {
1228
- turn_signal.hazard_signal .command = HazardLightsCommand::ENABLE;
1229
- const auto back_start_pose = planner_data_->route_handler ->getOriginalStartPose ();
1230
- turn_signal.desired_start_point = back_start_pose;
1231
- turn_signal.required_start_point = back_start_pose;
1232
- // pull_out start_pose is same to backward driving end_pose
1233
- turn_signal.required_end_point = start_pose;
1234
- turn_signal.desired_end_point = start_pose;
1235
- return turn_signal;
1236
- }
1237
-
1238
- // turn on right signal until passing pull_out end point
1239
- const auto path = getFullPath ();
1240
- // pull out path does not overlap
1241
- const double distance_from_end =
1242
- motion_utils::calcSignedArcLength (path.points , end_pose.position , current_pose.position );
1224
+ const auto shift_start_idx =
1225
+ motion_utils::findNearestIndex (path.points , status_.pull_out_path .start_pose .position );
1226
+ const auto shift_end_idx =
1227
+ motion_utils::findNearestIndex (path.points , status_.pull_out_path .end_pose .position );
1228
+ const lanelet::ConstLanelets current_lanes = utils::getCurrentLanes (planner_data_);
1229
+
1230
+ const auto is_ignore_signal = [this ](const lanelet::Id & id) {
1231
+ if (!ignore_signal_.has_value ()) {
1232
+ return false ;
1233
+ }
1234
+ return ignore_signal_.value () == id;
1235
+ };
1243
1236
1244
- if (path.points .empty ()) {
1245
- return {};
1237
+ const auto update_ignore_signal = [this ](const lanelet::Id & id, const bool is_ignore) {
1238
+ return is_ignore ? std::make_optional (id) : std::nullopt;
1239
+ };
1240
+
1241
+ lanelet::Lanelet closest_lanelet;
1242
+ lanelet::utils::query::getClosestLanelet (current_lanes, current_pose, &closest_lanelet);
1243
+
1244
+ if (is_ignore_signal (closest_lanelet.id ())) {
1245
+ return getPreviousModuleOutput ().turn_signal_info ;
1246
1246
}
1247
1247
1248
- // calculate lateral offset from pull out target lane center line
1249
- lanelet::ConstLanelet closest_road_lane;
1250
- const double backward_path_length =
1251
- planner_data_->parameters .backward_path_length + parameters_->max_back_distance ;
1252
- const auto road_lanes = utils::getExtendedCurrentLanes (
1253
- planner_data_, backward_path_length, std::numeric_limits<double >::max (),
1254
- /* forward_only_in_route*/ true );
1255
- lanelet::utils::query::getClosestLanelet (road_lanes, start_pose, &closest_road_lane);
1256
- const double lateral_offset =
1257
- lanelet::utils::getLateralDistanceToCenterline (closest_road_lane, start_pose);
1258
-
1259
- turn_signal.turn_signal .command = std::invoke ([&]() {
1260
- if (distance_from_end >= 0.0 ) return TurnIndicatorsCommand::DISABLE;
1261
- if (lateral_offset > parameters_->th_turn_signal_on_lateral_offset )
1262
- return TurnIndicatorsCommand::ENABLE_RIGHT;
1263
- if (lateral_offset < -parameters_->th_turn_signal_on_lateral_offset )
1264
- return TurnIndicatorsCommand::ENABLE_LEFT;
1265
- return TurnIndicatorsCommand::DISABLE;
1266
- });
1248
+ const double current_shift_length =
1249
+ lanelet::utils::getArcCoordinates (current_lanes, current_pose).distance ;
1267
1250
1268
- turn_signal.desired_start_point = start_pose;
1269
- turn_signal.required_start_point = start_pose;
1270
- turn_signal.desired_end_point = end_pose;
1271
-
1272
- // check if intersection exists within search length
1273
- const bool is_near_intersection = std::invoke ([&]() {
1274
- const double check_length = parameters_->intersection_search_length ;
1275
- double accumulated_length = 0.0 ;
1276
- const size_t current_idx = motion_utils::findNearestIndex (path.points , current_pose.position );
1277
- for (size_t i = current_idx; i < path.points .size () - 1 ; ++i) {
1278
- const auto & p = path.points .at (i);
1279
- for (const auto & lane : planner_data_->route_handler ->getLaneletsFromIds (p.lane_ids )) {
1280
- const std::string turn_direction = lane.attributeOr (" turn_direction" , " else" );
1281
- if (turn_direction == " right" || turn_direction == " left" || turn_direction == " straight" ) {
1282
- return true ;
1283
- }
1284
- }
1285
- accumulated_length += tier4_autoware_utils::calcDistance2d (p, path.points .at (i + 1 ));
1286
- if (accumulated_length > check_length) {
1287
- return false ;
1288
- }
1289
- }
1290
- return false ;
1291
- });
1251
+ constexpr bool egos_lane_is_shifted = true ;
1252
+ constexpr bool is_pull_out = true ;
1292
1253
1293
- turn_signal.required_end_point = std::invoke ([&]() {
1294
- if (is_near_intersection) return end_pose;
1295
- const double length_start_to_end =
1296
- motion_utils::calcSignedArcLength (path.points , start_pose.position , end_pose.position );
1297
- const auto ratio = std::clamp (
1298
- parameters_->length_ratio_for_turn_signal_deactivation_near_intersection , 0.0 , 1.0 );
1299
-
1300
- const double required_end_length = length_start_to_end * ratio;
1301
- double accumulated_length = 0.0 ;
1302
- const size_t start_idx = motion_utils::findNearestIndex (path.points , start_pose.position );
1303
- for (size_t i = start_idx; i < path.points .size () - 1 ; ++i) {
1304
- accumulated_length +=
1305
- tier4_autoware_utils::calcDistance2d (path.points .at (i), path.points .at (i + 1 ));
1306
- if (accumulated_length > required_end_length) {
1307
- return path.points .at (i).point .pose ;
1308
- }
1254
+ // In Geometric pull out, the ego stops once and then steers the wheels to the opposite direction.
1255
+ // This sometimes causes the getBehaviorTurnSignalInfo method to detect the ego as stopped and
1256
+ // close to complete its shift, so it wrongly turns off the blinkers, this override helps avoid
1257
+ // this issue.
1258
+ const bool override_ego_stopped_check = std::invoke ([&]() {
1259
+ if (status_.planner_type != PlannerType::GEOMETRIC) {
1260
+ return false ;
1309
1261
}
1310
- // not found required end point
1311
- return end_pose;
1262
+ constexpr double distance_threshold = 1.0 ;
1263
+ const auto stop_point = status_.pull_out_path .partial_paths .front ().points .back ();
1264
+ const double distance_from_ego_to_stop_point = std::abs (motion_utils::calcSignedArcLength (
1265
+ path.points , stop_point.point .pose .position , current_pose.position ));
1266
+ return distance_from_ego_to_stop_point < distance_threshold;
1312
1267
});
1313
1268
1314
- return turn_signal;
1269
+ const auto [new_signal, is_ignore] = planner_data_->getBehaviorTurnSignalInfo (
1270
+ path, shift_start_idx, shift_end_idx, current_lanes, current_shift_length,
1271
+ status_.driving_forward , egos_lane_is_shifted, override_ego_stopped_check, is_pull_out);
1272
+ ignore_signal_ = update_ignore_signal (closest_lanelet.id (), is_ignore);
1273
+
1274
+ const auto original_signal = getPreviousModuleOutput ().turn_signal_info ;
1275
+ const auto current_seg_idx = planner_data_->findEgoSegmentIndex (path.points );
1276
+ const auto output_turn_signal_info = planner_data_->turn_signal_decider .use_prior_turn_signal (
1277
+ path, current_pose, current_seg_idx, original_signal, new_signal,
1278
+ planner_data_->parameters .ego_nearest_dist_threshold ,
1279
+ planner_data_->parameters .ego_nearest_yaw_threshold );
1280
+
1281
+ return output_turn_signal_info;
1315
1282
}
1316
1283
1317
1284
bool StartPlannerModule::isSafePath () const
0 commit comments