diff --git a/ur_rtde_driver/include/ur_rtde_driver/comm/producer.h b/ur_rtde_driver/include/ur_rtde_driver/comm/producer.h index 9088e7a..a1f871f 100644 --- a/ur_rtde_driver/include/ur_rtde_driver/comm/producer.h +++ b/ur_rtde_driver/include/ur_rtde_driver/comm/producer.h @@ -30,6 +30,12 @@ namespace ur_driver { namespace comm { +/*! + * \brief A general producer for URPackages. Implements funcionality to produce packages by + * reading and parsing from a byte stream. + * + * @tparam HeaderT Header type of packages to produce. + */ template class URProducer : public IProducer { @@ -39,10 +45,19 @@ private: std::chrono::seconds timeout_; public: + /*! + * \brief Creates a URProducer object, registering a stream and a parser. + * + * \param stream The stream to read from + * \param parser The parser to use to interpret received byte information + */ URProducer(URStream& stream, Parser& parser) : stream_(stream), parser_(parser), timeout_(1) { } + /*! + * \brief Triggers the stream to connect to the robot. + */ void setupProducer() { timeval tv; @@ -54,14 +69,27 @@ public: throw UrException("Failed to connect to robot. Please check if the robot is booted and connected."); } } + /*! + * \brief Tears down the producer. Currently no special handling needed. + */ void teardownProducer() { stopProducer(); } + /*! + * \brief Stops the producer. Currently no functionality needed. + */ void stopProducer() { } + /*! + * \brief Attempts to read byte stream from the robot and parse it as a URPackage. + * + * \param products Unique pointer to hold the produced package + * + * \returns Success of reading and parsing the package + */ bool tryGet(std::vector>>& products) { // 4KB should be enough to hold any packet received from UR diff --git a/ur_rtde_driver/include/ur_rtde_driver/comm/reverse_interface.h b/ur_rtde_driver/include/ur_rtde_driver/comm/reverse_interface.h index c8f3ede..7926de7 100644 --- a/ur_rtde_driver/include/ur_rtde_driver/comm/reverse_interface.h +++ b/ur_rtde_driver/include/ur_rtde_driver/comm/reverse_interface.h @@ -37,10 +37,19 @@ namespace ur_driver { namespace comm { +/*! + * \brief The ReverseInterface class handles communication to the robot. It starts a server and + * waits for the robot to connect via its URCaps program. + */ class ReverseInterface { public: ReverseInterface() = delete; + /*! + * \brief Creates a ReverseInterface object including a URServer. + * + * \param port Port the Server is started on + */ ReverseInterface(uint32_t port) : server_(port) { if (!server_.bind()) @@ -52,11 +61,22 @@ public: throw std::runtime_error("Failed to accept robot connection"); } } + /*! + * \brief Disconnects possible clients so the reverse interface object can be safely destroyed. + */ ~ReverseInterface() { server_.disconnectClient(); } + /*! + * \brief Writes needed information to the robot to be read by the URCaps program. + * + * \param positions A vector of joint position targets for the robot + * \param type An additional integer used to command the program to end when needed + * + * \returns True, if the write was performed successfully, false otherwise. + */ bool write(const vector6d_t* positions, const int32_t type = 2) { uint8_t buffer[sizeof(uint32_t) * 7]; @@ -80,6 +100,11 @@ public: return server_.write(buffer, sizeof(buffer), written); } + /*! + * \brief Reads a keepalive signal from the robot. + * + * \returns The received keepalive string or the empty string, if nothing was received + */ std::string readKeepalive() { size_t buf_len = 16; diff --git a/ur_rtde_driver/include/ur_rtde_driver/comm/script_sender.h b/ur_rtde_driver/include/ur_rtde_driver/comm/script_sender.h index e98d6c5..3551657 100644 --- a/ur_rtde_driver/include/ur_rtde_driver/comm/script_sender.h +++ b/ur_rtde_driver/include/ur_rtde_driver/comm/script_sender.h @@ -36,10 +36,20 @@ namespace ur_driver { namespace comm { +/*! + * \brief The ScriptSender class starts a URServer for a robot to connect to and waits for a + * request to receive a program. This program is then delivered to the requesting robot. + */ class ScriptSender { public: ScriptSender() = delete; + /*! + * \brief Creates a ScriptSender object, including a new URServer and not yet started thread. + * + * \param port Port to start the server on + * \param program Program to send to the robot upon request + */ ScriptSender(uint32_t port, const std::string& program) : server_(port), script_thread_(), program_(program) { if (!server_.bind()) @@ -48,6 +58,9 @@ public: } } + /*! + * \brief Starts the thread that handles program requests by a robot. + */ void start() { script_thread_ = std::thread(&ScriptSender::runScriptSender, this);