scenario_simulator_v2 C++ API
zmq_multi_client.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 SIMULATION_INTERFACE__ZMQ_MULTI_CLIENT_HPP_
16 #define SIMULATION_INTERFACE__ZMQ_MULTI_CLIENT_HPP_
17 
18 #include <simulation_api_schema.pb.h>
19 
20 #include <functional>
21 #include <iostream>
22 #include <memory>
23 #include <rclcpp/rclcpp.hpp>
26 #include <string>
27 #include <thread>
28 #include <zmqpp/zmqpp.hpp>
29 
30 namespace zeromq
31 {
33 {
34 public:
35  explicit MultiClient(
37  const unsigned int socket_port);
38 
39  ~MultiClient();
40 
41  void closeConnection();
42 
43  auto call(const simulation_api_schema::SimulationRequest &)
44  -> simulation_api_schema::SimulationResponse;
45 
46  auto call(const simulation_api_schema::InitializeRequest &)
47  -> simulation_api_schema::InitializeResponse;
48 
49  auto call(const simulation_api_schema::UpdateFrameRequest &)
50  -> simulation_api_schema::UpdateFrameResponse;
51 
52  auto call(const simulation_api_schema::UpdateStepTimeRequest &)
53  -> simulation_api_schema::UpdateStepTimeResponse;
54 
55  auto call(const simulation_api_schema::SpawnVehicleEntityRequest &)
56  -> simulation_api_schema::SpawnVehicleEntityResponse;
57 
58  auto call(const simulation_api_schema::SpawnPedestrianEntityRequest &)
59  -> simulation_api_schema::SpawnPedestrianEntityResponse;
60 
61  auto call(const simulation_api_schema::SpawnMiscObjectEntityRequest &)
62  -> simulation_api_schema::SpawnMiscObjectEntityResponse;
63 
64  auto call(const simulation_api_schema::DespawnEntityRequest &)
65  -> simulation_api_schema::DespawnEntityResponse;
66 
67  auto call(const simulation_api_schema::UpdateEntityStatusRequest &)
68  -> simulation_api_schema::UpdateEntityStatusResponse;
69 
70  auto call(const simulation_api_schema::AttachImuSensorRequest &)
71  -> simulation_api_schema::AttachImuSensorResponse;
72 
73  auto call(const simulation_api_schema::AttachLidarSensorRequest &)
74  -> simulation_api_schema::AttachLidarSensorResponse;
75 
76  auto call(const simulation_api_schema::AttachDetectionSensorRequest &)
77  -> simulation_api_schema::AttachDetectionSensorResponse;
78 
79  auto call(const simulation_api_schema::AttachOccupancyGridSensorRequest &)
80  -> simulation_api_schema::AttachOccupancyGridSensorResponse;
81 
82  auto call(const simulation_api_schema::UpdateTrafficLightsRequest &)
83  -> simulation_api_schema::UpdateTrafficLightsResponse;
84 
85  auto call(const simulation_api_schema::AttachPseudoTrafficLightDetectorRequest &)
86  -> simulation_api_schema::AttachPseudoTrafficLightDetectorResponse;
87 
90 
91 private:
92  zmqpp::context context_;
93  const zmqpp::socket_type type_;
94  zmqpp::socket socket_;
95 
96  bool is_running = true;
97 };
98 } // namespace zeromq
99 
100 #endif // SIMULATION_INTERFACE__ZMQ_MULTI_CLIENT_HPP_
Definition: zmq_multi_client.hpp:33
const simulation_interface::TransportProtocol protocol
Definition: zmq_multi_client.hpp:88
MultiClient(const simulation_interface::TransportProtocol &protocol, const std::string &hostname, const unsigned int socket_port)
Definition: zmq_multi_client.cpp:21
void closeConnection()
Definition: zmq_multi_client.cpp:33
auto call(const simulation_api_schema::SimulationRequest &) -> simulation_api_schema::SimulationResponse
Definition: zmq_multi_client.cpp:43
~MultiClient()
Definition: zmq_multi_client.cpp:41
const std::string hostname
Definition: zmq_multi_client.hpp:89
TransportProtocol
Definition: constants.hpp:22
std::string string
Definition: junit5.hpp:26
Definition: conversions.hpp:56