Skip to content

Commit 932579d

Browse files
authored
fix(behavior_velocity_traffic_light): stop for outdated signals and set prev_state_stop when using time to red signal (#1259)
* fix(behavior_velocity_traffic_light): stop when the signal is timed out Signed-off-by: Tomohito Ando <tomohito.ando@tier4.jp> * fix(behavior_velocity_traffic_light): set prev_state_stop when using time to red signal Signed-off-by: Tomohito Ando <tomohito.ando@tier4.jp> --------- Signed-off-by: Tomohito Ando <tomohito.ando@tier4.jp>
1 parent 5d76f9a commit 932579d

File tree

1 file changed

+8
-6
lines changed
  • planning/behavior_velocity_traffic_light_module/src

1 file changed

+8
-6
lines changed

planning/behavior_velocity_traffic_light_module/src/scene.cpp

+8-6
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ bool TrafficLightModule::modifyPathVelocity(PathWithLaneId * path, StopReason *
233233

234234
const bool is_unknown_signal = isUnknownSignal(looking_tl_state_);
235235
const bool is_signal_timed_out = isTrafficSignalTimedOut();
236+
const bool is_stop_signal = isStopSignal();
237+
const bool is_stop_required = is_unknown_signal || is_signal_timed_out || is_stop_signal;
236238

237239
// Decide if stop or proceed using the remaining time to red signal
238240
// If the upcoming traffic signal color is unknown or timed out, do not use the time to red and
@@ -241,20 +243,20 @@ bool TrafficLightModule::modifyPathVelocity(PathWithLaneId * path, StopReason *
241243
planner_data_->getRestTimeToRedSignal(traffic_light_reg_elem_.id());
242244
const bool is_time_to_red_signal_available =
243245
(rest_time_to_red_signal.has_value() && !isDataTimeout(rest_time_to_red_signal->stamp));
244-
const bool is_stop_required = is_unknown_signal || is_signal_timed_out;
245246

246247
if (planner_param_.v2i_use_rest_time && is_time_to_red_signal_available && !is_stop_required) {
247248
if (!canPassStopLineBeforeRed(*rest_time_to_red_signal, signed_arc_length_to_stop_point)) {
248249
*path = insertStopPose(input_path, stop_line_point_idx, stop_line_point, stop_reason);
250+
is_prev_state_stop_ = true;
251+
return true;
249252
}
253+
254+
is_prev_state_stop_ = false;
250255
return true;
251256
}
252257

253-
// Check if stop is coming.
254-
const bool is_stop_signal = isStopSignal();
255-
256258
// Update stop signal received time
257-
if (is_stop_signal || is_unknown_signal || is_signal_timed_out) {
259+
if (is_stop_required) {
258260
if (!stop_signal_received_time_ptr_) {
259261
stop_signal_received_time_ptr_ = std::make_unique<Time>(clock_->now());
260262
}
@@ -268,7 +270,7 @@ bool TrafficLightModule::modifyPathVelocity(PathWithLaneId * path, StopReason *
268270
? std::max((clock_->now() - *stop_signal_received_time_ptr_).seconds(), 0.0)
269271
: 0.0;
270272
const bool to_be_stopped =
271-
is_stop_signal && (is_prev_state_stop_ || time_diff > planner_param_.stop_time_hysteresis);
273+
is_stop_required && (is_prev_state_stop_ || time_diff > planner_param_.stop_time_hysteresis);
272274

273275
setSafe(!to_be_stopped);
274276
if (isActivated()) {

0 commit comments

Comments
 (0)