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>
20 #include <string>
24 
25 namespace traffic_simulator
26 {
28 {
29 public:
30  virtual auto publish(
31  const rclcpp::Time & current_ros_time,
32  const simulation_api_schema::UpdateTrafficLightsRequest & request) const -> void = 0;
33  virtual ~TrafficLightPublisherBase() = default;
34 };
35 
36 template <typename MessageType>
38 {
39 public:
40  template <typename NodeTypePointer>
42  const NodeTypePointer & node_ptr, const std::string & topic_name,
43  const std::string & frame = "camera_link") // DIRTY HACK!!!
45  frame_(frame),
46  traffic_light_state_array_publisher_(rclcpp::create_publisher<MessageType>(
47  node_ptr, topic_name, rclcpp::QoS(10).transient_local()))
48  {
49  }
50 
51  ~TrafficLightPublisher() override = default;
52 
53  auto publish(
54  const rclcpp::Time & current_ros_time,
55  const simulation_api_schema::UpdateTrafficLightsRequest & request) const -> void override;
56 
57 private:
58  const std::string frame_;
59 
60  const typename rclcpp::Publisher<MessageType>::SharedPtr traffic_light_state_array_publisher_;
61 };
62 } // namespace traffic_simulator
63 #endif // TRAFFIC_SIMULATOR__TRAFFIC_LIGHTS__TRAFFIC_LIGHT_PUBLISHER_HPP_
Definition: traffic_light_publisher.hpp:28
virtual auto publish(const rclcpp::Time &current_ros_time, const simulation_api_schema::UpdateTrafficLightsRequest &request) const -> void=0
Definition: traffic_light_publisher.hpp:38
auto publish(const rclcpp::Time &current_ros_time, const simulation_api_schema::UpdateTrafficLightsRequest &request) const -> void override
TrafficLightPublisher(const NodeTypePointer &node_ptr, const std::string &topic_name, const std::string &frame="camera_link")
Definition: traffic_light_publisher.hpp:41
Definition: api.hpp:49
std::string string
Definition: junit5.hpp:26