|
| 1 | +RTDEClient |
| 2 | +========== |
| 3 | + |
| 4 | +The ``RTDEClient`` class serves as a standalone |
| 5 | +`RTDE <https://www.universal-robots.com/articles/ur-articles/real-time-data-exchange-rtde-guide/>`_ |
| 6 | +client. To use the RTDE-Client, you'll have to initialize and start it separately: |
| 7 | + |
| 8 | +.. code-block:: c++ |
| 9 | + |
| 10 | + rtde_interface::RTDEClient my_client(ROBOT_IP, notifier, OUTPUT_RECIPE, INPUT_RECIPE); |
| 11 | + my_client.init(); |
| 12 | + my_client.start(); |
| 13 | + while (true) |
| 14 | + { |
| 15 | + std::unique_ptr<rtde_interface::DataPackage> data_pkg = my_client.getDataPackage(READ_TIMEOUT); |
| 16 | + if (data_pkg) |
| 17 | + { |
| 18 | + std::cout << data_pkg->toString() << std::endl; |
| 19 | + } |
| 20 | + } |
| 21 | + |
| 22 | +Upon construction, two recipe files have to be given, one for the RTDE inputs, one for the RTDE |
| 23 | +outputs. Please refer to the `RTDE |
| 24 | +guide <https://www.universal-robots.com/articles/ur-articles/real-time-data-exchange-rtde-guide/>`_ |
| 25 | +on which elements are available. |
| 26 | + |
| 27 | +Inside the ``RTDEclient`` data is received in a separate thread, parsed by the ``RTDEParser`` and |
| 28 | +added to a pipeline queue. |
| 29 | + |
| 30 | +Right after calling ``my_client.start()``, it should be made sure to read the buffer from the |
| 31 | +``RTDEClient`` by calling ``getDataPackage()`` frequently. The Client's queue can only contain a |
| 32 | +restricted number of items at a time, so a ``Pipeline producer overflowed!`` error will be raised if the buffer isn't read frequently enough. |
| 33 | + |
| 34 | +For writing data to the RTDE interface, use the ``RTDEWriter`` member of the ``RTDEClient``. It can be |
| 35 | +retrieved by calling ``getWriter()`` method. The ``RTDEWriter`` provides convenience methods to write |
| 36 | +all data available at the RTDE interface. Make sure that the required keys are configured inside the |
| 37 | +input recipe, as otherwise the send-methods will return ``false`` if the data field is not setup in |
| 38 | +the recipe. |
| 39 | + |
| 40 | +An example of a standalone RTDE-client can be found in the ``examples`` subfolder. To run it make |
| 41 | +sure to |
| 42 | + |
| 43 | +* have an instance of a robot controller / URSim running at the configured IP address (or adapt the |
| 44 | + address to your needs) |
| 45 | +* run it from the package's main folder, as for simplicity reasons it doesn't use any sophisticated |
| 46 | + method to locate the required files. |
| 47 | + |
| 48 | +.. note:: |
| 49 | + The ``URDriver`` class creates a ``RTDEClient`` during initialization using the provided |
| 50 | + recipes and utilizing the robot model's maximum frequency. If you would like to use a different |
| 51 | + frequency, please use the ``resetRTDEClient()`` method after the ``UrDriver`` object has been |
| 52 | + created. |
| 53 | + |
| 54 | +RTDEWriter |
| 55 | +---------- |
| 56 | + |
| 57 | +The ``RTDEWriter`` class provides an interface to write data to the RTDE interface. Data fields that |
| 58 | +should be written have to be defined inside the ``INPUT_RECIPE`` as noted above. |
| 59 | + |
| 60 | +The class offers specific methods for every RTDE input possible to write. |
| 61 | + |
| 62 | +Data is sent asynchronously to the RTDE interface. |
| 63 | + |
0 commit comments