@@ -452,14 +452,7 @@ BehaviorModuleOutput StartPlannerModule::plan()
452
452
453
453
setDrivableAreaInfo (output);
454
454
455
- const uint16_t steering_factor_direction = std::invoke ([&output]() {
456
- if (output.turn_signal_info .turn_signal .command == TurnIndicatorsCommand::ENABLE_LEFT) {
457
- return SteeringFactor::LEFT;
458
- } else if (output.turn_signal_info .turn_signal .command == TurnIndicatorsCommand::ENABLE_RIGHT) {
459
- return SteeringFactor::RIGHT;
460
- }
461
- return SteeringFactor::STRAIGHT;
462
- });
455
+ const auto steering_factor_direction = getSteeringFactorDirection (output);
463
456
464
457
if (status_.driving_forward ) {
465
458
const double start_distance = motion_utils::calcSignedArcLength (
@@ -473,15 +466,16 @@ BehaviorModuleOutput StartPlannerModule::plan()
473
466
{status_.pull_out_path .start_pose , status_.pull_out_path .end_pose },
474
467
{start_distance, finish_distance}, PlanningBehavior::START_PLANNER, steering_factor_direction,
475
468
SteeringFactor::TURNING, " " );
476
- } else {
477
- const double distance = motion_utils::calcSignedArcLength (
478
- path.points , planner_data_->self_odometry ->pose .pose .position ,
479
- status_.pull_out_path .start_pose .position );
480
- updateRTCStatus (0.0 , distance);
481
- steering_factor_interface_ptr_->updateSteeringFactor (
482
- {status_.pull_out_path .start_pose , status_.pull_out_path .end_pose }, {0.0 , distance},
483
- PlanningBehavior::START_PLANNER, steering_factor_direction, SteeringFactor::TURNING, " " );
469
+ setDebugData ();
470
+ return output;
484
471
}
472
+ const double distance = motion_utils::calcSignedArcLength (
473
+ path.points , planner_data_->self_odometry ->pose .pose .position ,
474
+ status_.pull_out_path .start_pose .position );
475
+ updateRTCStatus (0.0 , distance);
476
+ steering_factor_interface_ptr_->updateSteeringFactor (
477
+ {status_.pull_out_path .start_pose , status_.pull_out_path .end_pose }, {0.0 , distance},
478
+ PlanningBehavior::START_PLANNER, steering_factor_direction, SteeringFactor::TURNING, " " );
485
479
486
480
setDebugData ();
487
481
@@ -562,14 +556,7 @@ BehaviorModuleOutput StartPlannerModule::planWaitingApproval()
562
556
563
557
setDrivableAreaInfo (output);
564
558
565
- const uint16_t steering_factor_direction = std::invoke ([&output]() {
566
- if (output.turn_signal_info .turn_signal .command == TurnIndicatorsCommand::ENABLE_LEFT) {
567
- return SteeringFactor::LEFT;
568
- } else if (output.turn_signal_info .turn_signal .command == TurnIndicatorsCommand::ENABLE_RIGHT) {
569
- return SteeringFactor::RIGHT;
570
- }
571
- return SteeringFactor::STRAIGHT;
572
- });
559
+ const auto steering_factor_direction = getSteeringFactorDirection (output);
573
560
574
561
if (status_.driving_forward ) {
575
562
const double start_distance = motion_utils::calcSignedArcLength (
@@ -583,15 +570,17 @@ BehaviorModuleOutput StartPlannerModule::planWaitingApproval()
583
570
{status_.pull_out_path .start_pose , status_.pull_out_path .end_pose },
584
571
{start_distance, finish_distance}, PlanningBehavior::START_PLANNER, steering_factor_direction,
585
572
SteeringFactor::APPROACHING, " " );
586
- } else {
587
- const double distance = motion_utils::calcSignedArcLength (
588
- stop_path.points , planner_data_->self_odometry ->pose .pose .position ,
589
- status_.pull_out_path .start_pose .position );
590
- updateRTCStatus (0.0 , distance);
591
- steering_factor_interface_ptr_->updateSteeringFactor (
592
- {status_.pull_out_path .start_pose , status_.pull_out_path .end_pose }, {0.0 , distance},
593
- PlanningBehavior::START_PLANNER, steering_factor_direction, SteeringFactor::APPROACHING, " " );
573
+ setDebugData ();
574
+
575
+ return output;
594
576
}
577
+ const double distance = motion_utils::calcSignedArcLength (
578
+ stop_path.points , planner_data_->self_odometry ->pose .pose .position ,
579
+ status_.pull_out_path .start_pose .position );
580
+ updateRTCStatus (0.0 , distance);
581
+ steering_factor_interface_ptr_->updateSteeringFactor (
582
+ {status_.pull_out_path .start_pose , status_.pull_out_path .end_pose }, {0.0 , distance},
583
+ PlanningBehavior::START_PLANNER, steering_factor_direction, SteeringFactor::APPROACHING, " " );
595
584
596
585
setDebugData ();
597
586
@@ -651,16 +640,20 @@ PriorityOrder StartPlannerModule::determinePriorityOrder(
651
640
order_priority.emplace_back (i, planner);
652
641
}
653
642
}
654
- } else if (search_priority == " short_back_distance" ) {
643
+ return order_priority;
644
+ }
645
+
646
+ if (search_priority == " short_back_distance" ) {
655
647
for (size_t i = 0 ; i < start_pose_candidates_num; i++) {
656
648
for (const auto & planner : start_planners_) {
657
649
order_priority.emplace_back (i, planner);
658
650
}
659
651
}
660
- } else {
661
- RCLCPP_ERROR (getLogger (), " Invalid search_priority: %s" , search_priority.c_str ());
662
- throw std::domain_error (" [start_planner] invalid search_priority" );
652
+ return order_priority;
663
653
}
654
+
655
+ RCLCPP_ERROR (getLogger (), " Invalid search_priority: %s" , search_priority.c_str ());
656
+ throw std::domain_error (" [start_planner] invalid search_priority" );
664
657
return order_priority;
665
658
}
666
659
@@ -1092,12 +1085,7 @@ bool StartPlannerModule::isStuck()
1092
1085
return false ;
1093
1086
}
1094
1087
1095
- if (status_.planner_type == PlannerType::STOP) {
1096
- return true ;
1097
- }
1098
-
1099
- // not found safe path
1100
- if (!status_.found_pull_out_path ) {
1088
+ if (status_.planner_type == PlannerType::STOP || !status_.found_pull_out_path ) {
1101
1089
return true ;
1102
1090
}
1103
1091
@@ -1190,30 +1178,26 @@ TurnSignalInfo StartPlannerModule::calcTurnSignalInfo() const
1190
1178
return false ;
1191
1179
});
1192
1180
1193
- if (is_near_intersection) {
1194
- // offset required end pose with ration to activate turn signal for intersection
1195
- turn_signal.required_end_point = std::invoke ([&]() {
1196
- const double length_start_to_end =
1197
- motion_utils::calcSignedArcLength (path.points , start_pose.position , end_pose.position );
1198
- const auto ratio = std::clamp (
1199
- parameters_->length_ratio_for_turn_signal_deactivation_near_intersection , 0.0 , 1.0 );
1200
-
1201
- const double required_end_length = length_start_to_end * ratio;
1202
- double accumulated_length = 0.0 ;
1203
- const size_t start_idx = motion_utils::findNearestIndex (path.points , start_pose.position );
1204
- for (size_t i = start_idx; i < path.points .size () - 1 ; ++i) {
1205
- accumulated_length +=
1206
- tier4_autoware_utils::calcDistance2d (path.points .at (i), path.points .at (i + 1 ));
1207
- if (accumulated_length > required_end_length) {
1208
- return path.points .at (i).point .pose ;
1209
- }
1181
+ turn_signal.required_end_point = std::invoke ([&]() {
1182
+ if (is_near_intersection) return end_pose;
1183
+ const double length_start_to_end =
1184
+ motion_utils::calcSignedArcLength (path.points , start_pose.position , end_pose.position );
1185
+ const auto ratio = std::clamp (
1186
+ parameters_->length_ratio_for_turn_signal_deactivation_near_intersection , 0.0 , 1.0 );
1187
+
1188
+ const double required_end_length = length_start_to_end * ratio;
1189
+ double accumulated_length = 0.0 ;
1190
+ const size_t start_idx = motion_utils::findNearestIndex (path.points , start_pose.position );
1191
+ for (size_t i = start_idx; i < path.points .size () - 1 ; ++i) {
1192
+ accumulated_length +=
1193
+ tier4_autoware_utils::calcDistance2d (path.points .at (i), path.points .at (i + 1 ));
1194
+ if (accumulated_length > required_end_length) {
1195
+ return path.points .at (i).point .pose ;
1210
1196
}
1211
- // not found required end point
1212
- return end_pose;
1213
- });
1214
- } else {
1215
- turn_signal.required_end_point = end_pose;
1216
- }
1197
+ }
1198
+ // not found required end point
1199
+ return end_pose;
1200
+ });
1217
1201
1218
1202
return turn_signal;
1219
1203
}
@@ -1382,22 +1366,27 @@ bool StartPlannerModule::planFreespacePath()
1382
1366
1383
1367
void StartPlannerModule::setDrivableAreaInfo (BehaviorModuleOutput & output) const
1384
1368
{
1385
- if (status_.planner_type == PlannerType::FREESPACE) {
1386
- const double drivable_area_margin = planner_data_->parameters .vehicle_width ;
1387
- output.drivable_area_info .drivable_margin =
1388
- planner_data_->parameters .vehicle_width / 2.0 + drivable_area_margin;
1389
- } else {
1390
- const auto target_drivable_lanes = utils::getNonOverlappingExpandedLanes (
1391
- output.path , generateDrivableLanes (output.path ),
1392
- planner_data_->drivable_area_expansion_parameters );
1393
-
1394
- DrivableAreaInfo current_drivable_area_info;
1395
- current_drivable_area_info.drivable_lanes = target_drivable_lanes;
1396
- output.drivable_area_info =
1397
- status_.driving_forward
1398
- ? utils::combineDrivableAreaInfo (
1399
- current_drivable_area_info, getPreviousModuleOutput ().drivable_area_info )
1400
- : current_drivable_area_info;
1369
+ switch (status_.planner_type ) {
1370
+ case PlannerType::FREESPACE: {
1371
+ const double drivable_area_margin = planner_data_->parameters .vehicle_width ;
1372
+ output.drivable_area_info .drivable_margin =
1373
+ planner_data_->parameters .vehicle_width / 2.0 + drivable_area_margin;
1374
+ break ;
1375
+ }
1376
+ default : {
1377
+ const auto target_drivable_lanes = utils::getNonOverlappingExpandedLanes (
1378
+ output.path , generateDrivableLanes (output.path ),
1379
+ planner_data_->drivable_area_expansion_parameters );
1380
+
1381
+ DrivableAreaInfo current_drivable_area_info;
1382
+ current_drivable_area_info.drivable_lanes = target_drivable_lanes;
1383
+ output.drivable_area_info =
1384
+ status_.driving_forward
1385
+ ? utils::combineDrivableAreaInfo (
1386
+ current_drivable_area_info, getPreviousModuleOutput ().drivable_area_info )
1387
+ : current_drivable_area_info;
1388
+ break ;
1389
+ }
1401
1390
}
1402
1391
}
1403
1392
0 commit comments