1
0
mirror of https://gitlab.com/obbart/universal_robots_ros_driver.git synced 2026-04-09 17:40:47 +02:00

doxygen documentation comm part2

This commit is contained in:
Tristan Schnell
2019-09-23 16:25:03 +02:00
parent baf024f5d2
commit 6a0ebe6b80
3 changed files with 66 additions and 0 deletions

View File

@@ -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 <typename HeaderT>
class URProducer : public IProducer<HeaderT>
{
@@ -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<HeaderT>& stream, Parser<HeaderT>& 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<std::unique_ptr<URPackage<HeaderT>>>& products)
{
// 4KB should be enough to hold any packet received from UR

View File

@@ -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;

View File

@@ -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);