@@ -54,6 +54,51 @@ NormalLaneChange::NormalLaneChange(
54
54
void NormalLaneChange::updateLaneChangeStatus ()
55
55
{
56
56
updateStopTime ();
57
+ status_.current_lanes = getCurrentLanes ();
58
+ if (status_.current_lanes .empty ()) {
59
+ return ;
60
+ }
61
+
62
+ lanelet::ConstLanelet current_lane;
63
+ if (!getRouteHandler ()->getClosestLaneletWithinRoute (getEgoPose (), ¤t_lane)) {
64
+ RCLCPP_DEBUG (logger_, " ego's current lane not in route" );
65
+ return ;
66
+ }
67
+ status_.current_lane_ = current_lane;
68
+
69
+ const auto ego_footprint =
70
+ utils::lane_change::getEgoCurrentFootprint (getEgoPose (), getCommonParam ().vehicle_info );
71
+ status_.is_ego_in_turn_direction_lane =
72
+ utils::lane_change::isWithinTurnDirectionLanes (current_lane, ego_footprint);
73
+ status_.is_ego_in_intersection =
74
+ utils::lane_change::isWithinIntersection (getRouteHandler (), current_lane, ego_footprint);
75
+
76
+ if (
77
+ status_.is_ego_in_intersection && status_.is_ego_in_turn_direction_lane &&
78
+ status_.path_after_intersection .points .empty ()) {
79
+ const auto target_neighbor =
80
+ utils::lane_change::getTargetNeighborLanes (*getRouteHandler (), status_.current_lanes , type_);
81
+ status_.path_after_intersection = getRouteHandler ()->getCenterLinePath (
82
+ target_neighbor, 0.0 , std::numeric_limits<double >::max ());
83
+ status_.distance_from_prev_intersection = 0.0 ;
84
+ }
85
+
86
+ if (
87
+ !status_.is_ego_in_intersection && !status_.is_ego_in_turn_direction_lane &&
88
+ !status_.path_after_intersection .points .empty ()) {
89
+ status_.distance_from_prev_intersection = calcSignedArcLength (
90
+ status_.path_after_intersection .points ,
91
+ status_.path_after_intersection .points .front ().point .pose .position , getEgoPosition ());
92
+ }
93
+
94
+ if (
95
+ !status_.is_ego_in_intersection && !status_.is_ego_in_turn_direction_lane &&
96
+ status_.distance_from_prev_intersection >
97
+ lane_change_parameters_->backward_length_from_intersection &&
98
+ !status_.path_after_intersection .points .empty ()) {
99
+ status_.path_after_intersection = PathWithLaneId ();
100
+ status_.distance_from_prev_intersection = std::numeric_limits<double >::max ();
101
+ }
57
102
const auto [found_valid_path, found_safe_path] = getSafePath (status_.lane_change_path );
58
103
59
104
// Update status
@@ -135,6 +180,24 @@ bool NormalLaneChange::isStoppedAtRedTrafficLight() const
135
180
status_.lane_change_path .info .length .sum ());
136
181
}
137
182
183
+ bool NormalLaneChange::is_safe_to_try_change_lanes_at_intersection () const
184
+ {
185
+ if (debug_filtered_objects_.target_lane .empty () || status_.target_lanes .empty ()) {
186
+ return true ;
187
+ }
188
+
189
+ const auto has_overtaking_turn_direction_object =
190
+ utils::lane_change::has_overtaking_turn_lane_object (
191
+ status_.target_lanes , status_.current_lane_ , debug_filtered_objects_.target_lane );
192
+
193
+ if (!has_overtaking_turn_direction_object) {
194
+ return true ;
195
+ }
196
+
197
+ return status_.distance_from_prev_intersection >
198
+ lane_change_parameters_->backward_length_from_intersection ;
199
+ }
200
+
138
201
LaneChangePath NormalLaneChange::getLaneChangePath () const
139
202
{
140
203
return status_.lane_change_path ;
@@ -1372,6 +1435,18 @@ bool NormalLaneChange::getLaneChangePaths(
1372
1435
}
1373
1436
candidate_paths->push_back (*candidate_path);
1374
1437
1438
+ if (status_.is_ego_in_intersection && status_.is_ego_in_turn_direction_lane ) {
1439
+ return false ;
1440
+ }
1441
+ if (
1442
+ status_.distance_from_prev_intersection <
1443
+ lane_change_parameters_->backward_length_from_intersection &&
1444
+ utils::lane_change::has_overtaking_turn_lane_object (
1445
+ status_.target_lanes , status_.current_lane_ , target_objects.target_lane )) {
1446
+ RCLCPP_DEBUG (logger_, " has overtaking object while ego leaves intersection" );
1447
+ return false ;
1448
+ }
1449
+
1375
1450
std::vector<ExtendedPredictedObject> filtered_objects =
1376
1451
filterObjectsInTargetLane (target_objects, target_lanes);
1377
1452
if (
0 commit comments