Skip to content

Commit 8cc0969

Browse files
committed
Add instruction_executor example doc
# Conflicts: # doc/architecture/instruction_executor.rst
1 parent 2a4e843 commit 8cc0969

File tree

3 files changed

+70
-9
lines changed

3 files changed

+70
-9
lines changed

doc/architecture/instruction_executor.rst

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. _instruction_executor:
2+
13
Instruction Executor
24
====================
35

@@ -21,12 +23,4 @@ for sending motion instructions to the robot. Hence, it requires a :ref:`ur_driv
2123
Therefore, all parameters and restrictions of these functions apply. For example, velocity and
2224
acceleration parameters will be ignored if there is a time > 0 given.
2325

24-
As a minimal working example, please see ``examples/instruction_executor.cpp`` example:
25-
26-
.. literalinclude:: ../../examples/instruction_executor.cpp
27-
:language: c++
28-
:caption: examples/instruction_executor.cpp
29-
:linenos:
30-
:lineno-match:
31-
:start-at: g_my_driver.reset
32-
:end-at: g_my_driver->stopControl();
26+
As a minimal working example, please see the :ref:`instruction_executor_example`.

doc/examples.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ starting point for your own applications.
1313
examples/dashboard_client
1414
examples/force_mode
1515
examples/freedrive
16+
examples/instruction_executor
1617
examples/ur_driver
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
:github_url: https://github.com/UniversalRobots/Universal_Robots_Client_Library/blob/master/doc/examples/instruction_executor.rst
2+
3+
.. _instruction_executor_example:
4+
5+
Instruction Executor example
6+
============================
7+
8+
This example shows how to use the :ref:`instruction_executor` class. It can be used for easily
9+
executing a sequence of instructions such as motions on the robot using the built-in URScript functions.
10+
11+
The `instruction_executor.cpp <https://github.com/UniversalRobots/Universal_Robots_Client_Library/blob/master/examples/instruction_executor.cpp>`_ shows how to use this class:
12+
13+
.. note:: For the instruciton executor to work there has to be an established connection to the
14+
:ref:`reverse_interface`. That means, the respective program has to be running on the robot. The
15+
example below will do that automatically, if the connected robot is in *remote_control* mode.
16+
17+
18+
.. literalinclude:: ../../examples/instruction_executor.cpp
19+
:language: c++
20+
:caption: examples/instruction_executor.cpp
21+
:linenos:
22+
:lineno-match:
23+
:start-at: std::unique_ptr<urcl::ToolCommSetup> tool_comm_setup;
24+
:end-at: auto instruction_executor = std::make_shared<urcl::InstructionExecutor>(g_my_driver);
25+
26+
At first, a ``InstructionExecutor`` object is created with the URDriver object as it needs that
27+
for communication with the robot.
28+
29+
Currently, the ``InstructionExecutor`` can either be used to run sequences of motions or single motions.
30+
31+
Execute a sequence of motions
32+
-----------------------------
33+
34+
To run a sequence of motions, create an
35+
``std::vector<std::shared_ptr<urcl::cointrol::MotionPrimitive>>`` and pass it to the
36+
``executeMotion`` function:
37+
38+
.. literalinclude:: ../../examples/instruction_executor.cpp
39+
:language: c++
40+
:caption: examples/instruction_executor.cpp
41+
:linenos:
42+
:lineno-match:
43+
:start-at: // Trajectory definition
44+
:end-at: instruction_executor->executeMotion(motion_sequence);
45+
46+
Each element in the motion sequence can be a different motion type. In the example, there are two
47+
``MoveJ`` motions and two ``MoveL`` motion. The primitives' parameters are directly forwarded to
48+
the underlying script functions, so the parameter descriptions for them apply, as well.
49+
Particularly, you may want to choose between either a time-based execution speed or an acceleration
50+
/ velocity parametrization. The latter will be ignored if a time > 0 is given.
51+
52+
Execute a single motion
53+
-----------------------
54+
55+
To run a single motion, the ``InstructionExecutor`` provides the methods ``moveJ(...)`` and
56+
``moveL(...)``:
57+
58+
.. literalinclude:: ../../examples/instruction_executor.cpp
59+
:language: c++
60+
:caption: examples/instruction_executor.cpp
61+
:linenos:
62+
:lineno-match:
63+
:start-at: double goal_time_sec = 2.0;
64+
:end-before: g_my_driver->stopControl();
65+
66+
Again, time parametrization has priority over acceleration / velocity parameters.

0 commit comments

Comments
 (0)