@@ -796,7 +796,7 @@ std::vector<DrivableLanes> GoalPlannerModule::generateDrivableLanes() const
796
796
return utils::generateDrivableLanesWithShoulderLanes (current_lanes, pull_over_lanes);
797
797
}
798
798
799
- void GoalPlannerModule::setOutput (BehaviorModuleOutput & output) const
799
+ void GoalPlannerModule::setOutput (BehaviorModuleOutput & output)
800
800
{
801
801
output.reference_path = getPreviousModuleOutput ().reference_path ;
802
802
@@ -907,7 +907,7 @@ void GoalPlannerModule::setModifiedGoal(BehaviorModuleOutput & output) const
907
907
}
908
908
}
909
909
910
- void GoalPlannerModule::setTurnSignalInfo (BehaviorModuleOutput & output) const
910
+ void GoalPlannerModule::setTurnSignalInfo (BehaviorModuleOutput & output)
911
911
{
912
912
const auto original_signal = getPreviousModuleOutput ().turn_signal_info ;
913
913
const auto new_signal = calcTurnSignalInfo ();
@@ -1433,43 +1433,98 @@ bool GoalPlannerModule::isOnModifiedGoal() const
1433
1433
parameters_->th_arrived_distance ;
1434
1434
}
1435
1435
1436
- TurnSignalInfo GoalPlannerModule::calcTurnSignalInfo () const
1436
+ TurnSignalInfo GoalPlannerModule::calcTurnSignalInfo ()
1437
1437
{
1438
- TurnSignalInfo turn_signal{}; // output
1438
+ const auto path = thread_safe_data_.get_pull_over_path ()->getFullPath ();
1439
+ if (path.points .empty ()) return getPreviousModuleOutput ().turn_signal_info ;
1439
1440
1440
1441
const auto & current_pose = planner_data_->self_odometry ->pose .pose ;
1441
1442
const auto & start_pose = thread_safe_data_.get_pull_over_path ()->start_pose ;
1442
1443
const auto & end_pose = thread_safe_data_.get_pull_over_path ()->end_pose ;
1443
- const auto full_path = thread_safe_data_.get_pull_over_path ()->getFullPath ();
1444
1444
1445
- // calc TurnIndicatorsCommand
1446
- {
1447
- const double distance_to_end =
1448
- calcSignedArcLength (full_path.points , current_pose.position , end_pose.position );
1449
- const bool is_before_end_pose = distance_to_end >= 0.0 ;
1450
- if (is_before_end_pose) {
1451
- if (left_side_parking_) {
1452
- turn_signal.turn_signal .command = TurnIndicatorsCommand::ENABLE_LEFT;
1453
- } else {
1454
- turn_signal.turn_signal .command = TurnIndicatorsCommand::ENABLE_RIGHT;
1455
- }
1456
- } else {
1457
- turn_signal.turn_signal .command = TurnIndicatorsCommand::NO_COMMAND;
1445
+ const auto shift_start_idx = motion_utils::findNearestIndex (path.points , start_pose.position );
1446
+ const auto shift_end_idx = motion_utils::findNearestIndex (path.points , end_pose.position );
1447
+
1448
+ const auto is_ignore_signal = [this ](const lanelet::Id & id) {
1449
+ if (!ignore_signal_.has_value ()) {
1450
+ return false ;
1458
1451
}
1452
+ return ignore_signal_.value () == id;
1453
+ };
1454
+
1455
+ const auto update_ignore_signal = [this ](const lanelet::Id & id, const bool is_ignore) {
1456
+ return is_ignore ? std::make_optional (id) : std::nullopt;
1457
+ };
1458
+
1459
+ const lanelet::ConstLanelets current_lanes = utils::getExtendedCurrentLanes (
1460
+ planner_data_, parameters_->backward_goal_search_length ,
1461
+ parameters_->forward_goal_search_length ,
1462
+ /* forward_only_in_route*/ false );
1463
+
1464
+ if (current_lanes.empty ()) {
1465
+ return {};
1459
1466
}
1460
1467
1461
- // calc desired/required start/end point
1462
- {
1463
- // ego decelerates so that current pose is the point `turn_light_on_threshold_time` seconds
1464
- // before starting pull_over
1465
- turn_signal.desired_start_point =
1466
- last_approval_data_ && hasDecidedPath () ? last_approval_data_->pose : current_pose;
1467
- turn_signal.desired_end_point = end_pose;
1468
- turn_signal.required_start_point = start_pose;
1469
- turn_signal.required_end_point = end_pose;
1468
+ lanelet::Lanelet closest_lanelet;
1469
+ lanelet::utils::query::getClosestLanelet (current_lanes, current_pose, &closest_lanelet);
1470
+
1471
+ if (is_ignore_signal (closest_lanelet.id ())) {
1472
+ return getPreviousModuleOutput ().turn_signal_info ;
1470
1473
}
1471
1474
1472
- return turn_signal;
1475
+ const double current_shift_length =
1476
+ lanelet::utils::getArcCoordinates (current_lanes, current_pose).distance ;
1477
+
1478
+ constexpr bool egos_lane_is_shifted = true ;
1479
+ constexpr bool is_driving_forward = true ;
1480
+
1481
+ constexpr bool is_pull_out = false ;
1482
+ const bool override_ego_stopped_check = std::invoke ([&]() {
1483
+ if (thread_safe_data_.getPullOverPlannerType () == PullOverPlannerType::SHIFT) {
1484
+ return false ;
1485
+ }
1486
+ constexpr double distance_threshold = 1.0 ;
1487
+ const auto stop_point =
1488
+ thread_safe_data_.get_pull_over_path ()->partial_paths .front ().points .back ();
1489
+ const double distance_from_ego_to_stop_point = std::abs (motion_utils::calcSignedArcLength (
1490
+ path.points , stop_point.point .pose .position , current_pose.position ));
1491
+ return distance_from_ego_to_stop_point < distance_threshold;
1492
+ });
1493
+
1494
+ const auto [new_signal, is_ignore] = planner_data_->getBehaviorTurnSignalInfo (
1495
+ path, shift_start_idx, shift_end_idx, current_lanes, current_shift_length, is_driving_forward,
1496
+ egos_lane_is_shifted, override_ego_stopped_check, is_pull_out);
1497
+ ignore_signal_ = update_ignore_signal (closest_lanelet.id (), is_ignore);
1498
+
1499
+ return new_signal;
1500
+ // // calc TurnIndicatorsCommand
1501
+ // {
1502
+ // const double distance_to_end =
1503
+ // calcSignedArcLength(full_path.points, current_pose.position, end_pose.position);
1504
+ // const bool is_before_end_pose = distance_to_end >= 0.0;
1505
+ // if (is_before_end_pose) {
1506
+ // if (left_side_parking_) {
1507
+ // turn_signal.turn_signal.command = TurnIndicatorsCommand::ENABLE_LEFT;
1508
+ // } else {
1509
+ // turn_signal.turn_signal.command = TurnIndicatorsCommand::ENABLE_RIGHT;
1510
+ // }
1511
+ // } else {
1512
+ // turn_signal.turn_signal.command = TurnIndicatorsCommand::NO_COMMAND;
1513
+ // }
1514
+ // }
1515
+
1516
+ // // calc desired/required start/end point
1517
+ // {
1518
+ // // ego decelerates so that current pose is the point `turn_light_on_threshold_time` seconds
1519
+ // // before starting pull_over
1520
+ // turn_signal.desired_start_point =
1521
+ // last_approval_data_ && hasDecidedPath() ? last_approval_data_->pose : current_pose;
1522
+ // turn_signal.desired_end_point = end_pose;
1523
+ // turn_signal.required_start_point = start_pose;
1524
+ // turn_signal.required_end_point = end_pose;
1525
+ // }
1526
+
1527
+ // return turn_signal;
1473
1528
}
1474
1529
1475
1530
bool GoalPlannerModule::checkOccupancyGridCollision (const PathWithLaneId & path) const
0 commit comments