Skip to content

Commit 2a4e843

Browse files
committed
Add documentation for freedrive mode example
1 parent d392c39 commit 2a4e843

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-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: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
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);

examples/freedrive_example.cpp

Lines changed: 2 additions & 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
}
@@ -106,6 +106,7 @@ int main(int argc, char* argv[])
106106
stopwatch_now = std::chrono::steady_clock::now();
107107
time_done += stopwatch_now - stopwatch_last;
108108
stopwatch_last = stopwatch_now;
109+
std::this_thread::sleep_for(std::chrono::milliseconds(2));
109110
}
110111

111112
URCL_LOG_INFO("Stopping freedrive mode");

0 commit comments

Comments
 (0)