Template Class URProducer
Defined in File producer.h
Inheritance Relationships
Base Type
public urcl::comm::IProducer< T >
(Template Class IProducer)
Class Documentation
-
template<typename T>
class URProducer : public urcl::comm::IProducer<T> A general producer for URPackages. Implements funcionality to produce packages by reading and parsing from a byte stream.
- Template Parameters:
HeaderT – Header type of packages to produce.
Public Functions
-
inline URProducer(URStream<T> &stream, Parser<T> &parser)
Creates a URProducer object, registering a stream and a parser.
- Parameters:
stream – The stream to read from
parser – The parser to use to interpret received byte information
-
inline virtual void setupProducer(const size_t max_num_tries = 0, const std::chrono::milliseconds reconnection_time = std::chrono::seconds(10)) override
Triggers the stream to connect to the robot.
- Parameters:
max_num_tries – Maximum number of connection attempts before counting the connection as failed. Unlimited number of attempts when set to 0.
reconnection_time – time in between connection attempts to the server
-
inline virtual void teardownProducer() override
Tears down the producer. Currently no special handling needed.
-
inline virtual void stopProducer() override
Stops the producer. Currently no functionality needed.
-
inline virtual void startProducer() override
-
inline virtual bool tryGet(std::vector<std::unique_ptr<T>> &products) override
Attempts to read byte stream from the robot and parse it as a URPackage.
- Parameters:
products – Unique pointer to hold the produced package
- Returns:
Success of reading and parsing the package
-
inline void setReconnectionCallback(std::function<void()> on_reconnect_cb)
Sets the reconnection callback. Use this to configure a reconnection callback instead of connecting directly to the stream again. This is needed for RTDE as it requires setting up the communication again upon reconnection it is not enough to just reconnect to the stream.
- Parameters:
on_reconnect_cb – Callback to be invoked when connection is lost to the stream.