Skip to content

Commit 6e930ad

Browse files
committed
Add documentation for freedrive mode example
1 parent d392c39 commit 6e930ad

File tree

3 files changed

+71
-1
lines changed

3 files changed

+71
-1
lines changed

doc/examples.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ starting point for your own applications.
1212

1313
examples/dashboard_client
1414
examples/force_mode
15+
examples/freedrive
1516
examples/ur_driver

doc/examples/freedrive.rst

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
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 ``UrDriver`` object and initialize it:
17+
18+
.. literalinclude:: ../../examples/freedrive_example.cpp
19+
:language: c++
20+
:caption: examples/freedrive_example.cpp
21+
:linenos:
22+
:lineno-match:
23+
:start-at: // Now the robot is ready to receive a program
24+
:end-at: g_my_driver->startRTDECommunication();
25+
26+
27+
Start freedrive mode
28+
--------------------
29+
30+
The ``UrDriver`` provides a method to start freedrive mode directly:
31+
32+
.. literalinclude:: ../../examples/freedrive_example.cpp
33+
:language: c++
34+
:caption: examples/freedrive_example.cpp
35+
:linenos:
36+
:lineno-match:
37+
:start-at: sendFreedriveMessageOrDie(control::FreedriveControlMessage::FREEDRIVE_START);
38+
:end-at: sendFreedriveMessageOrDie(control::FreedriveControlMessage::FREEDRIVE_START);
39+
40+
As it is potentially dangerous to leave the robot in freedrive mode, the robot program expect
41+
frequent keepalive messages to verify that the remote connection is still available and freedrive
42+
mode is being expected to be active.
43+
44+
Freedrive mode will be active from this point on until it is either stopped, or no keepalive
45+
message is received by the robot anymore.
46+
47+
Therefore, we have to make sure to send regular keepalive messages to the robot. The following
48+
section will keep freedrive mode active for a period of time defined in ``seconds_to_run``.
49+
50+
.. literalinclude:: ../../examples/freedrive_example.cpp
51+
:language: c++
52+
:caption: examples/freedrive_example.cpp
53+
:linenos:
54+
:lineno-match:
55+
:start-at: std::chrono::duration<double> time_done(0);
56+
:end-before: sendFreedriveMessageOrDie(control::FreedriveControlMessage::FREEDRIVE_STOP);
57+
58+
Stop force Mode
59+
---------------
60+
61+
To stop force mode either stop sending keepalive signals or request deactivating it explicitly:
62+
63+
.. literalinclude:: ../../examples/freedrive_example.cpp
64+
:language: c++
65+
:caption: examples/freedrive_example.cpp
66+
:linenos:
67+
:lineno-match:
68+
:start-at: sendFreedriveMessageOrDie(control::FreedriveControlMessage::FREEDRIVE_STOP);
69+
:end-at: sendFreedriveMessageOrDie(control::FreedriveControlMessage::FREEDRIVE_STOP);

examples/freedrive_example.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void sendFreedriveMessageOrDie(const control::FreedriveControlMessage freedrive_
5858
bool ret = g_my_robot->ur_driver_->writeFreedriveControlMessage(freedrive_action);
5959
if (!ret)
6060
{
61-
URCL_LOG_ERROR("Could not send freedrive command. Is the robot in remote control?");
61+
URCL_LOG_ERROR("Could not send joint command. Is there an external_control program running on the robot?");
6262
exit(1);
6363
}
6464
}

0 commit comments

Comments
 (0)