1 #include <mrpt/system/CTimeLogger.h>
3 #include <pybind11/functional.h>
4 #include <pybind11/pybind11.h>
5 #include <pybind11/stl.h>
12 #include <string_view>
14 #ifndef BINDER_PYBIND11_TYPE_CASTER
15 #define BINDER_PYBIND11_TYPE_CASTER
16 PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>)
17 PYBIND11_DECLARE_HOLDER_TYPE(T, T*)
18 PYBIND11_MAKE_OPAQUE(std::shared_ptr<void>)
24 pybind11::class_<mvsim::Client, std::shared_ptr<mvsim::Client>> cl(
26 "This is the connection of any user program with the MVSIM server, "
27 "so\n it can advertise and subscribe to topics and use remote "
28 "services.\n\n Users should instance a class mvsim::Client (C++) "
29 "or mvsim.Client (Python) to\n communicate with the simulation "
30 "runnin in mvsim::World or any other module.\n\n Usage:\n - "
31 "Instantiate a Client object.\n - Call connect(). It will return "
32 "immediately.\n - The client will be working on the background as "
33 "long as the object is not\n destroyed.\n\n Messages and topics "
34 "are described as Protobuf messages, and communications\n are done "
35 "via ZMQ sockets.\n\n See: https://mvsimulator.readthedocs.io/\n\n "
38 cl.def(pybind11::init<const std::string&>(), pybind11::arg(
"nodeName"));
42 "@{ \n\nC++: mvsim::Client::setName(const std::string &) --> void",
43 pybind11::arg(
"nodeName"));
47 "C++: mvsim::Client::serverHostAddress() const --> const "
49 pybind11::return_value_policy::automatic);
53 "C++: mvsim::Client::serverHostAddress(const std::string &) --> "
55 pybind11::arg(
"serverIpOrAddressName"));
58 "Connects to the server in a parallel thread.\n Default server "
59 "address is `localhost`, can be changed with\n "
60 "serverHostAddress().\n\nC++: mvsim::Client::connect() --> void");
63 "Whether the client is correctly connected to the server. \n\nC++: "
64 "mvsim::Client::connected() const --> bool");
67 "Shutdowns the communication thread. Blocks until the thread is "
68 "stopped.\n There is no need to manually call this method, it is "
69 "called upon\n destruction. \n\nC++: mvsim::Client::shutdown() --> "
73 (std::string(
mvsim::Client::*)(
const std::string&,
const std::string&)) &
75 "Overload for python wrapper\n\nC++: "
76 "mvsim::Client::callService(const std::string &, const std::string "
78 pybind11::arg(
"serviceName"), pybind11::arg(
"inputSerializedMsg"));
83 const class std::function<
void(
85 const class std::vector<
88 "Overload for python wrapper (callback accepts "
89 "bytes-string)\n\nC++: mvsim::Client::subscribeTopic(const "
90 "std::string &, const class std::function<void (const std::string "
91 "&, const class std::vector<unsigned char, class "
92 "std::allocator<unsigned char> > &)> &) --> void",
93 pybind11::arg(
"topicName"), pybind11::arg(
"callback"));
96 "C++: mvsim::Client::enable_profiler(bool) --> void", pybind11::arg(
"enable"));
99 auto& enclosing_class = cl;
102 cl(enclosing_class,
"InfoPerNode",
"");
111 mvsim::Client::InfoPerNode::operator=,
112 "C++: mvsim::Client::InfoPerNode::operator=(const struct "
113 "mvsim::Client::InfoPerNode &) --> struct "
114 "mvsim::Client::InfoPerNode &",
115 pybind11::return_value_policy::automatic, pybind11::arg(
""));
119 auto& enclosing_class = cl;
122 cl(enclosing_class,
"InfoPerTopic",
"");
134 mvsim::Client::InfoPerTopic::operator=,
135 "C++: mvsim::Client::InfoPerTopic::operator=(const struct "
136 "mvsim::Client::InfoPerTopic &) --> struct "
137 "mvsim::Client::InfoPerTopic &",
138 pybind11::return_value_policy::automatic, pybind11::arg(
""));