12 #include <mrpt/system/COutputLogger.h> 22 struct InfoPerService;
23 struct InfoPerSubscribedTopic;
47 class Client :
public mrpt::system::COutputLogger
51 Client(
const std::string& nodeName);
57 void setName(
const std::string& nodeName);
63 bool connected()
const;
68 void shutdown() noexcept;
71 void advertiseTopic(
const std::string& topicName);
74 const std::string& topicName,
const google::protobuf::Message& msg);
76 template <
typename MSG_T>
78 const std::string& topicName,
79 const std::function<
void(
const MSG_T&)>& callback);
81 template <
typename INPUT_MSG_T,
typename OUTPUT_MSG_T>
83 const std::string& serviceName,
84 const std::function<OUTPUT_MSG_T(
const INPUT_MSG_T&)>& callback);
86 template <
typename INPUT_MSG_T,
typename OUTPUT_MSG_T>
88 const std::string& serviceName,
const INPUT_MSG_T&
input,
89 OUTPUT_MSG_T& output);
92 std::string callService(
93 const std::string& serviceName,
const std::string& inputSerializedMsg);
99 std::vector<InfoPerNode> requestListOfNodes();
107 std::vector<InfoPerTopic> requestListOfTopics();
113 std::unique_ptr<ZMQImpl>
zmq_;
115 std::string serverHostAddress_ =
"localhost";
116 std::string nodeName_ =
"anonymous";
121 void doRegisterClient();
122 void doUnregisterClient();
124 void internalServiceServingThread();
125 void internalTopicUpdatesThread();
126 void internalTopicSubscribeThread(internal::InfoPerSubscribedTopic& ipt);
129 std::function<std::shared_ptr<google::protobuf::Message>(
130 const std::string& )>;
132 void doAdvertiseTopic(
133 const std::string& topicName,
134 const google::protobuf::Descriptor* descriptor);
135 void doAdvertiseService(
136 const std::string& serviceName,
137 const google::protobuf::Descriptor* descIn,
138 const google::protobuf::Descriptor* descOut,
143 void doSubscribeTopic(
144 const std::string& topicName,
145 const google::protobuf::Descriptor* descriptor,
148 const std::string& serviceName,
const std::string& inputSerializedMsg,
149 mrpt::optional_ref<google::protobuf::Message> outputMsg,
150 mrpt::optional_ref<std::string> outputSerializedMsg = std::nullopt,
151 mrpt::optional_ref<std::string> outputMsgTypeName = std::nullopt);
153 friend struct internal::InfoPerService;
154 friend struct internal::InfoPerSubscribedTopic;
157 template <
typename T>
160 doAdvertiseTopic(topicName, T::descriptor());
163 template <
typename INPUT_MSG_T,
typename OUTPUT_MSG_T>
165 const std::string& serviceName,
166 const std::function<OUTPUT_MSG_T(
const INPUT_MSG_T&)>& callback)
169 serviceName, INPUT_MSG_T::descriptor(), OUTPUT_MSG_T::descriptor(),
172 in.ParseFromString(inData);
173 return std::make_shared<OUTPUT_MSG_T>(callback(in));
177 template <
typename MSG_T>
179 const std::string& topicName,
180 const std::function<
void(
const MSG_T&)>& callback)
183 topicName, MSG_T::descriptor(),
186 mvsim::parseMessage(m, in);
191 template <
typename INPUT_MSG_T,
typename OUTPUT_MSG_T>
193 const std::string& serviceName,
const INPUT_MSG_T&
input,
194 OUTPUT_MSG_T& output)
196 doCallService(serviceName, input.SerializeAsString(), output);
GLvoid *typedef void(GLAPIENTRY *PFNGLGETVERTEXATTRIBDVPROC)(GLuint
std::thread topicUpdatesThread_
std::unique_ptr< ZMQImpl > zmq_
GLenum GLenum GLenum input
void subscribeTopic(const std::string &topicName, const std::function< void(const MSG_T &)> &callback)
ServiceServer advertiseService(ros::NodeHandle n, std::string name, boost::function< bool(const typename ActionSpec::_action_goal_type::_goal_type &, typename ActionSpec::_action_result_type::_result_type &result)> service_cb)
std::function< void(const zmq::message_t &)> topic_callback_t
void advertiseService(const std::string &serviceName, const std::function< OUTPUT_MSG_T(const INPUT_MSG_T &)> &callback)
void callService(const std::string &serviceName, const INPUT_MSG_T &input, OUTPUT_MSG_T &output)
std::thread serviceInvokerThread_
void advertiseTopic(const std::string &topicName)
std::vector< std::string > publishers
std::function< std::shared_ptr< google::protobuf::Message >(const std::string &)> service_callback_t