From c242104c28eca8345e1803951a0f58099253f8ef Mon Sep 17 00:00:00 2001 From: Joel Moriana Date: Mon, 18 Jul 2022 17:37:34 +0200 Subject: [PATCH] Avoid notification of green-yellow state to TM vehicles --- LibCarla/source/carla/trafficmanager/SimulationState.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/LibCarla/source/carla/trafficmanager/SimulationState.cpp b/LibCarla/source/carla/trafficmanager/SimulationState.cpp index cec6a2e3f..6f75bcb1b 100644 --- a/LibCarla/source/carla/trafficmanager/SimulationState.cpp +++ b/LibCarla/source/carla/trafficmanager/SimulationState.cpp @@ -43,6 +43,14 @@ void SimulationState::UpdateKinematicHybridEndLocation(ActorId actor_id, cg::Loc } void SimulationState::UpdateTrafficLightState(ActorId actor_id, TrafficLightState state) { + // The green-yellow state transition is not notified to the vehicle. This is done to avoid + // having vehicles stopped very near the intersection when only the rear part of the vehicle + // is colliding with the trigger volume of the traffic light. + auto previous_tl_state = GetTLS(actor_id); + if (previous_tl_state.at_traffic_light && previous_tl_state.tl_state == TLS::Green) { + state.tl_state = TLS::Green; + } + tl_state_map.at(actor_id) = state; }