#include <Client.h>
Classes | |
struct | InfoPerNode |
struct | InfoPerTopic |
struct | ZMQImpl |
Public Member Functions | |
Client () | |
Client (const std::string &nodeName) | |
~Client () | |
Main mvsim client communication API | |
void | setName (const std::string &nodeName) |
void | connect () |
bool | connected () const |
void | shutdown () noexcept |
template<typename T > | |
void | advertiseTopic (const std::string &topicName) |
void | publishTopic (const std::string &topicName, const google::protobuf::Message &msg) |
template<typename MSG_T > | |
void | subscribeTopic (const std::string &topicName, const std::function< void(const MSG_T &)> &callback) |
template<typename INPUT_MSG_T , typename OUTPUT_MSG_T > | |
void | advertiseService (const std::string &serviceName, const std::function< OUTPUT_MSG_T(const INPUT_MSG_T &)> &callback) |
template<typename INPUT_MSG_T , typename OUTPUT_MSG_T > | |
void | callService (const std::string &serviceName, const INPUT_MSG_T &input, OUTPUT_MSG_T &output) |
std::string | callService (const std::string &serviceName, const std::string &inputSerializedMsg) |
std::vector< InfoPerNode > | requestListOfNodes () |
std::vector< InfoPerTopic > | requestListOfTopics () |
Private Types | |
using | service_callback_t = std::function< std::shared_ptr< google::protobuf::Message >(const std::string &)> |
using | topic_callback_t = std::function< void(const zmq::message_t &)> |
Private Member Functions | |
void | doAdvertiseService (const std::string &serviceName, const google::protobuf::Descriptor *descIn, const google::protobuf::Descriptor *descOut, service_callback_t callback) |
void | doAdvertiseTopic (const std::string &topicName, const google::protobuf::Descriptor *descriptor) |
void | doCallService (const std::string &serviceName, const std::string &inputSerializedMsg, mrpt::optional_ref< google::protobuf::Message > outputMsg, mrpt::optional_ref< std::string > outputSerializedMsg=std::nullopt, mrpt::optional_ref< std::string > outputMsgTypeName=std::nullopt) |
void | doRegisterClient () |
void | doSubscribeTopic (const std::string &topicName, const google::protobuf::Descriptor *descriptor, const topic_callback_t &callback) |
void | doUnregisterClient () |
void | internalServiceServingThread () |
void | internalTopicSubscribeThread (internal::InfoPerSubscribedTopic &ipt) |
void | internalTopicUpdatesThread () |
Private Attributes | |
std::string | nodeName_ = "anonymous" |
std::string | serverHostAddress_ = "localhost" |
std::thread | serviceInvokerThread_ |
std::thread | topicUpdatesThread_ |
std::unique_ptr< ZMQImpl > | zmq_ |
Friends | |
struct | internal::InfoPerService |
struct | internal::InfoPerSubscribedTopic |
This is the connection of any user program with the MVSIM server, so it can advertise and subscribe to topics and use remote services.
Users should instance a class mvsim::Client (C++) or mvsim.Client (Python) to communicate with the simulation runnin in mvsim::World or any other module.
Usage:
Messages and topics are described as Protobuf messages, and communications are done via ZMQ sockets.
|
private |
Client::Client | ( | ) |
Definition at line 118 of file src/Comms/Client.cpp.
Client::Client | ( | const std::string & | nodeName | ) |
Definition at line 123 of file src/Comms/Client.cpp.
Client::~Client | ( | ) |
Definition at line 125 of file src/Comms/Client.cpp.
void mvsim::Client::advertiseService | ( | const std::string & | serviceName, |
const std::function< OUTPUT_MSG_T(const INPUT_MSG_T &)> & | callback | ||
) |
void mvsim::Client::advertiseTopic | ( | const std::string & | topicName | ) |
void mvsim::Client::callService | ( | const std::string & | serviceName, |
const INPUT_MSG_T & | input, | ||
OUTPUT_MSG_T & | output | ||
) |
std::string Client::callService | ( | const std::string & | serviceName, |
const std::string & | inputSerializedMsg | ||
) |
Definition at line 691 of file src/Comms/Client.cpp.
void Client::connect | ( | ) |
Connects to the server in a parallel thread.
Definition at line 138 of file src/Comms/Client.cpp.
bool Client::connected | ( | ) | const |
Whether the client is correctly connected to the server.
Definition at line 129 of file src/Comms/Client.cpp.
|
private |
Definition at line 419 of file src/Comms/Client.cpp.
|
private |
Definition at line 356 of file src/Comms/Client.cpp.
|
private |
Definition at line 705 of file src/Comms/Client.cpp.
|
private |
Definition at line 236 of file src/Comms/Client.cpp.
|
private |
Definition at line 763 of file src/Comms/Client.cpp.
|
private |
Definition at line 262 of file src/Comms/Client.cpp.
|
private |
Definition at line 526 of file src/Comms/Client.cpp.
|
private |
Definition at line 812 of file src/Comms/Client.cpp.
|
private |
Definition at line 601 of file src/Comms/Client.cpp.
void Client::publishTopic | ( | const std::string & | topicName, |
const google::protobuf::Message & | msg | ||
) |
Definition at line 479 of file src/Comms/Client.cpp.
std::vector< Client::InfoPerNode > Client::requestListOfNodes | ( | ) |
Definition at line 288 of file src/Comms/Client.cpp.
std::vector< Client::InfoPerTopic > Client::requestListOfTopics | ( | ) |
Definition at line 315 of file src/Comms/Client.cpp.
void Client::setName | ( | const std::string & | nodeName | ) |
Definition at line 127 of file src/Comms/Client.cpp.
|
noexcept |
Shutdowns the communication thread. Blocks until the thread is stopped. There is no need to manually call this method, it is called upon destruction.
Definition at line 204 of file src/Comms/Client.cpp.
|
private |
|
private |