|
| 1 | +:github_url: https://github.com/UniversalRobots/Universal_Robots_Client_Library/blob/master/doc/examples/freedrive.rst |
| 2 | + |
| 3 | +Freedrive Mode example |
| 4 | +====================== |
| 5 | + |
| 6 | +`Freedrive |
| 7 | +<https://www.universal-robots.com/manuals/EN/HTML/SW5_20/Content/prod-scriptmanual/G5/freedrive_mode.htm>`_ |
| 8 | +allows the robot arm to be manually pulled into desired positions and/or poses. The joints move |
| 9 | +with little resistance because the brakes are released. |
| 10 | + |
| 11 | +An example to utilize the freedrive mode can be found in the `freedrive_example.cpp <https://github.com/UniversalRobots/Universal_Robots_Client_Library/blob/master/examples/freedrive_example.cpp>`_. |
| 12 | + |
| 13 | +.. note:: For the following example to work on an e-Series (PolyScope 5) robot, the robot has to be |
| 14 | + in *remote control mode*. |
| 15 | + |
| 16 | +At first, we create a ``ExampleRobotWrapper`` object in order to initialize communication with the |
| 17 | +robot. |
| 18 | + |
| 19 | +.. literalinclude:: ../../examples/freedrive_example.cpp |
| 20 | + :language: c++ |
| 21 | + :caption: examples/freedrive_example.cpp |
| 22 | + :linenos: |
| 23 | + :lineno-match: |
| 24 | + :start-at: bool headless_mode = true; |
| 25 | + :end-before: URCL_LOG_INFO("Starting freedrive mode"); |
| 26 | + |
| 27 | + |
| 28 | +Start freedrive mode |
| 29 | +-------------------- |
| 30 | + |
| 31 | +The ``UrDriver`` provides a method to start freedrive mode directly: |
| 32 | + |
| 33 | +.. literalinclude:: ../../examples/freedrive_example.cpp |
| 34 | + :language: c++ |
| 35 | + :caption: examples/freedrive_example.cpp |
| 36 | + :linenos: |
| 37 | + :lineno-match: |
| 38 | + :start-at: URCL_LOG_INFO("Starting freedrive mode"); |
| 39 | + :end-at: sendFreedriveMessageOrDie(control::FreedriveControlMessage::FREEDRIVE_START); |
| 40 | + |
| 41 | +As it is potentially dangerous to leave the robot in freedrive mode, the robot program expect |
| 42 | +frequent keepalive messages to verify that the remote connection is still available and freedrive |
| 43 | +mode is being expected to be active. |
| 44 | + |
| 45 | +Freedrive mode will be active from this point on until it is either stopped, or no keepalive |
| 46 | +message is received by the robot anymore. |
| 47 | + |
| 48 | +Therefore, we have to make sure to send regular keepalive messages to the robot. The following |
| 49 | +section will keep freedrive mode active for a period of time defined in ``seconds_to_run``. |
| 50 | + |
| 51 | +.. literalinclude:: ../../examples/freedrive_example.cpp |
| 52 | + :language: c++ |
| 53 | + :caption: examples/freedrive_example.cpp |
| 54 | + :linenos: |
| 55 | + :lineno-match: |
| 56 | + :start-at: std::chrono::duration<double> time_done(0); |
| 57 | + :end-before: sendFreedriveMessageOrDie(control::FreedriveControlMessage::FREEDRIVE_STOP); |
| 58 | + |
| 59 | +Stop force Mode |
| 60 | +--------------- |
| 61 | + |
| 62 | +To stop force mode either stop sending keepalive signals or request deactivating it explicitly: |
| 63 | + |
| 64 | +.. literalinclude:: ../../examples/freedrive_example.cpp |
| 65 | + :language: c++ |
| 66 | + :caption: examples/freedrive_example.cpp |
| 67 | + :linenos: |
| 68 | + :lineno-match: |
| 69 | + :start-at: sendFreedriveMessageOrDie(control::FreedriveControlMessage::FREEDRIVE_STOP); |
| 70 | + :end-at: sendFreedriveMessageOrDie(control::FreedriveControlMessage::FREEDRIVE_STOP); |
0 commit comments