scenario_simulator_v2 C++ API
traffic_light_publisher.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_PUBLISHER_HPP_
16 #define TRAFFIC_SIMULATOR__TRAFFIC_LIGHTS__TRAFFIC_LIGHT_PUBLISHER_HPP_
17 
18 #include <memory>
19 #include <rclcpp/rclcpp.hpp>
21 #include <string>
23 
24 namespace traffic_simulator
25 {
27 {
28 public:
29  virtual auto publish(
30  const rclcpp::Time & current_ros_time,
31  const simulation_api_schema::UpdateTrafficLightsRequest & request) -> void = 0;
32 };
33 
34 template <typename Message>
36 {
37  const typename rclcpp::Publisher<Message>::SharedPtr traffic_light_state_array_publisher_;
38 
39  const std::shared_ptr<hdmap_utils::HdMapUtils> hdmap_utils_;
40 
41 public:
42  template <typename NodePointer>
44  const std::string & topic_name, const NodePointer & node,
45  const std::shared_ptr<hdmap_utils::HdMapUtils> & hdmap_utils = nullptr)
47  traffic_light_state_array_publisher_(
48  rclcpp::create_publisher<Message>(node, topic_name, rclcpp::QoS(10).transient_local())),
49  hdmap_utils_(hdmap_utils)
50  {
51  }
52 
53  auto publish(
54  const rclcpp::Time & current_ros_time,
55  const simulation_api_schema::UpdateTrafficLightsRequest & request) -> void override;
56 };
57 } // namespace traffic_simulator
58 #endif // TRAFFIC_SIMULATOR__TRAFFIC_LIGHTS__TRAFFIC_LIGHT_PUBLISHER_HPP_
Definition: traffic_light_publisher.hpp:27
virtual auto publish(const rclcpp::Time &current_ros_time, const simulation_api_schema::UpdateTrafficLightsRequest &request) -> void=0
Definition: traffic_light_publisher.hpp:36
auto publish(const rclcpp::Time &current_ros_time, const simulation_api_schema::UpdateTrafficLightsRequest &request) -> void override
TrafficLightPublisher(const std::string &topic_name, const NodePointer &node, const std::shared_ptr< hdmap_utils::HdMapUtils > &hdmap_utils=nullptr)
Definition: traffic_light_publisher.hpp:43
Definition: cache.hpp:46
Definition: api.hpp:48
std::string string
Definition: junit5.hpp:26