scenario_simulator_v2 C++ API
traffic_light_manager.hpp
Go to the documentation of this file.
1 // Copyright 2015 TIER IV, Inc. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #ifndef TRAFFIC_SIMULATOR__TRAFFIC_LIGHTS__TRAFFIC_LIGHT_MANAGER_BASE_HPP_
16 #define TRAFFIC_SIMULATOR__TRAFFIC_LIGHTS__TRAFFIC_LIGHT_MANAGER_BASE_HPP_
17 
18 #include <iomanip>
19 #include <memory>
20 #include <rclcpp/rclcpp.hpp>
22 #include <stdexcept> // std::out_of_range
23 #include <string>
26 #include <tuple>
27 #include <unordered_map>
28 #include <utility>
29 #include <vector>
30 
31 namespace traffic_simulator
32 {
34 {
35 protected:
36  using TrafficLightMap = std::unordered_map<lanelet::Id, TrafficLight>;
37 
39 
40  const std::shared_ptr<hdmap_utils::HdMapUtils> hdmap_;
41 
42 public:
43  explicit TrafficLightManager(const std::shared_ptr<hdmap_utils::HdMapUtils> & hdmap);
44 
45  auto getTrafficLight(const lanelet::Id traffic_light_id) -> TrafficLight &;
46 
47  auto getTrafficLightIds() const -> const lanelet::Ids;
48 
49  auto getTrafficLights() const -> const TrafficLightMap &;
50 
52 
53  auto getTrafficLights(const lanelet::Id lanelet_id)
54  -> std::vector<std::reference_wrapper<TrafficLight>>;
55 
56  auto hasAnyLightChanged() -> bool;
57 
58  auto generateUpdateTrafficLightsRequest() -> simulation_api_schema::UpdateTrafficLightsRequest;
59 };
60 } // namespace traffic_simulator
61 #endif // TRAFFIC_SIMULATOR__TRAFFIC_LIGHTS__TRAFFIC_LIGHT_MANAGER_BASE_HPP_
Definition: traffic_light_manager.hpp:34
auto getTrafficLightIds() const -> const lanelet::Ids
Definition: traffic_light_manager.cpp:52
TrafficLightMap traffic_lights_
Definition: traffic_light_manager.hpp:38
auto getTrafficLights() const -> const TrafficLightMap &
Definition: traffic_light_manager.cpp:61
TrafficLightManager(const std::shared_ptr< hdmap_utils::HdMapUtils > &hdmap)
Definition: traffic_light_manager.cpp:25
auto hasAnyLightChanged() -> bool
Definition: traffic_light_manager.cpp:30
auto getTrafficLight(const lanelet::Id traffic_light_id) -> TrafficLight &
Definition: traffic_light_manager.cpp:40
const std::shared_ptr< hdmap_utils::HdMapUtils > hdmap_
Definition: traffic_light_manager.hpp:40
std::unordered_map< lanelet::Id, TrafficLight > TrafficLightMap
Definition: traffic_light_manager.hpp:36
auto generateUpdateTrafficLightsRequest() -> simulation_api_schema::UpdateTrafficLightsRequest
Definition: traffic_light_manager.cpp:88
Definition: cache.hpp:27
Definition: api.hpp:48
Definition: traffic_light.hpp:40