71 throw UrException(
"Failed to connect to robot. Please check if the robot is booted and connected.");
101 bool tryGet(std::vector<std::unique_ptr<T>>& products)
override 111 if (stream_.
read(buf,
sizeof(buf), read))
114 timeout_ = std::chrono::seconds(1);
116 return parser_.
parse(bp, products);
125 URCL_LOG_WARN(
"Failed to read from stream, reconnecting in %ld seconds...", timeout_.count());
126 std::this_thread::sleep_for(timeout_);
131 auto next = timeout_ * 2;
132 if (next <= std::chrono::seconds(120))
void teardownProducer() override
Tears down the producer. Currently no special handling needed.
std::chrono::seconds timeout_
bool read(uint8_t *buf, const size_t buf_len, size_t &read)
Reads a full UR package out of a socket. For this, it looks into the package and reads the byte lengt...
void setupProducer() override
Triggers the stream to connect to the robot.
URProducer(URStream< T > &stream, Parser< T > &parser)
Creates a URProducer object, registering a stream and a parser.
The BinParser class handles a byte buffer and functionality to iteratively parse the content...
virtual bool parse(BinParser &bp, std::vector< std::unique_ptr< T >> &results)=0
Declares the parse function.
The stream is an abstraction of the TCPSocket that offers reading a full UR data package out of the s...
bool closed()
Returns whether the underlying socket is currently closed.
The parser is a general paser. The namsepace rtde_interface and primary_interface both iclude classes...
bool connect()
Connects to the configured socket.
bool tryGet(std::vector< std::unique_ptr< T >> &products) override
Attempts to read byte stream from the robot and parse it as a URPackage.
void startProducer() override
void stopProducer() override
Stops the producer. Currently no functionality needed.
#define URCL_LOG_WARN(...)
Parent class for arbitrary producers of packages.
void setReceiveTimeout(const timeval &timeout)
Setup Receive timeout used for this socket.
A general producer for URPackages. Implements funcionality to produce packages by reading and parsing...
Our base class for exceptions. Specialized exceptions should inherit from those.