|
MVSim
Lightweight simulator for 2.5D vehicles and robots
|
#include <Client.h>


Classes | |
| struct | InfoPerNode |
| struct | InfoPerTopic |
Public Member Functions | |
| Client (const std::string &nodeName) | |
| const mrpt::system::CTimeLogger & | profiler () const |
| void | enable_profiler (bool enable) |
Friends | |
| struct | internal::InfoPerService |
| struct | internal::InfoPerSubscribedTopic |
Main mvsim client communication API | |
| using | topic_callback_t = std::function< void(const zmq::message_t &)> |
| void | setName (const std::string &nodeName) |
| const std::string & | serverHostAddress () const |
| void | serverHostAddress (const std::string &serverIpOrAddressName) |
| 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) |
| Overload for python wrapper. | |
| void | subscribeTopic (const std::string &topicName, const std::function< void(const std::string &, const std::vector< uint8_t > &)> &callback) |
| Overload for python wrapper (callback accepts bytes-string) | |
| std::vector< InfoPerNode > | requestListOfNodes () |
| std::vector< InfoPerTopic > | requestListOfTopics () |
| void | subscribe_topic_raw (const std::string &topicName, const topic_callback_t &callback) |
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 running in mvsim::World or any other module.
Usage:
Messages and topics are described as Protobuf messages, and communications are done via ZMQ sockets.
| void mvsim::Client::connect | ( | ) |
Connects to the server in a parallel thread. Default server address is localhost, can be changed with serverHostAddress().
| bool mvsim::Client::connected | ( | ) | const |
Whether the client is correctly connected to the server.
|
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.