15 #ifndef SIMULATION_INTERFACE__ZMQ_MULTI_SERVER_HPP_
16 #define SIMULATION_INTERFACE__ZMQ_MULTI_SERVER_HPP_
18 #include <simulation_api_schema.pb.h>
21 #include <rclcpp/rclcpp.hpp>
27 #include <zmqpp/zmqpp.hpp>
34 template <
typename... Ts>
38 : context_(zmqpp::context()),
39 type_(zmqpp::socket_type::reply),
40 socket_(context_, type_),
41 functions_(
std::forward<decltype(
xs)>(
xs)...)
45 thread_ = std::thread(&MultiServer::start_poll,
this);
54 const zmqpp::context context_;
55 const zmqpp::socket_type type_;
56 zmqpp::poller poller_;
57 zmqpp::socket socket_;
59 #define DEFINE_FUNCTION_TYPE(TYPENAME) \
60 using TYPENAME = std::function<simulation_api_schema::TYPENAME##Response( \
61 const simulation_api_schema::TYPENAME##Request &)>
63 DEFINE_FUNCTION_TYPE(Initialize);
64 DEFINE_FUNCTION_TYPE(UpdateFrame);
65 DEFINE_FUNCTION_TYPE(SpawnVehicleEntity);
66 DEFINE_FUNCTION_TYPE(SpawnPedestrianEntity);
67 DEFINE_FUNCTION_TYPE(SpawnMiscObjectEntity);
68 DEFINE_FUNCTION_TYPE(DespawnEntity);
69 DEFINE_FUNCTION_TYPE(UpdateEntityStatus);
70 DEFINE_FUNCTION_TYPE(AttachImuSensor);
71 DEFINE_FUNCTION_TYPE(AttachLidarSensor);
72 DEFINE_FUNCTION_TYPE(AttachDetectionSensor);
73 DEFINE_FUNCTION_TYPE(AttachOccupancyGridSensor);
74 DEFINE_FUNCTION_TYPE(UpdateTrafficLights);
75 DEFINE_FUNCTION_TYPE(AttachPseudoTrafficLightDetector);
76 DEFINE_FUNCTION_TYPE(UpdateStepTime);
78 #undef DEFINE_FUNCTION_TYPE
81 Initialize, UpdateFrame, SpawnVehicleEntity, SpawnPedestrianEntity, SpawnMiscObjectEntity,
82 DespawnEntity, UpdateEntityStatus, AttachImuSensor, AttachLidarSensor, AttachDetectionSensor,
83 AttachOccupancyGridSensor, UpdateTrafficLights, AttachPseudoTrafficLightDetector,
Definition: zmq_multi_server.hpp:32
MultiServer(const simulation_interface::TransportProtocol &protocol, const simulation_interface::HostName &hostname, const unsigned int socket_port, Ts &&... xs)
Definition: zmq_multi_server.hpp:35
~MultiServer()
Definition: zmq_multi_server.cpp:21
HostName
Definition: constants.hpp:26
TransportProtocol
Definition: constants.hpp:22
const TransportProtocol protocol
Definition: constants.hpp:30
std::string getEndPoint(const TransportProtocol &protocol, const HostName &hostname, const unsigned int &port)
Definition: constants.cpp:21
Definition: junit5.hpp:25
Definition: conversions.hpp:56