From 4dc4df7919b9e2a4a462d907504133b4041df609 Mon Sep 17 00:00:00 2001 From: satoshi-ota Date: Fri, 27 Dec 2024 13:16:08 +0900 Subject: [PATCH] fix: implementation Signed-off-by: satoshi-ota --- .../src/traffic_lights/traffic_lights_base.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/simulation/traffic_simulator/src/traffic_lights/traffic_lights_base.cpp b/simulation/traffic_simulator/src/traffic_lights/traffic_lights_base.cpp index 763af0eebdc..906e8025807 100644 --- a/simulation/traffic_simulator/src/traffic_lights/traffic_lights_base.cpp +++ b/simulation/traffic_simulator/src/traffic_lights/traffic_lights_base.cpp @@ -115,10 +115,6 @@ auto TrafficLightsBase::isTrafficLightAdded(const lanelet::Id traffic_light_id) auto TrafficLightsBase::addTrafficLight(const lanelet::Id traffic_light_id) -> void { - if (isTrafficLightAdded(traffic_light_id)) { - return; - } - // emplace will not modify the map if the key already exists traffic_lights_map_.emplace( std::piecewise_construct, std::forward_as_tuple(traffic_light_id), @@ -127,6 +123,10 @@ auto TrafficLightsBase::addTrafficLight(const lanelet::Id traffic_light_id) -> v auto TrafficLightsBase::getTrafficLight(const lanelet::Id traffic_light_id) -> TrafficLight & { + if (isTrafficLightAdded(traffic_light_id)) { + return traffic_lights_map_.at(traffic_light_id); + } + addTrafficLight(traffic_light_id); return traffic_lights_map_.at(traffic_light_id); }