Skip to content

Commit dc018dc

Browse files
committed
Update documentation for PolyScope X dashboard client
1 parent d0839c9 commit dc018dc

File tree

4 files changed

+90
-51
lines changed

4 files changed

+90
-51
lines changed

doc/architecture/dashboard_client.rst

Lines changed: 64 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,25 +5,78 @@
55
DashboardClient
66
===============
77

8-
The ``DashboardClient`` wraps the calls on the `Dashboard server <https://www.universal-robots.com/articles/ur-articles/dashboard-server-e-series-port-29999/>`_
8+
For CB3 robots and PolyScope 5 the ``DashboardClient`` wraps the calls on the `Dashboard server <https://www.universal-robots.com/articles/ur-articles/dashboard-server-e-series-port-29999/>`_
99
directly into C++ functions.
1010

11-
After connecting to the dashboard server by using the ``connect()`` function, dashboard calls can be
12-
sent using the ``sendAndReceive()`` function. Answers from the dashboard server will be returned as
13-
string from this function. If no answer is received, a ``UrException`` is thrown.
11+
For PolyScope X the so-called Robot API `released with PolyScope X 10.11.0
12+
<https://www.universal-robots.com/articles/ur/release-notes/release-note-software-version-1011x/>`_
13+
is used. It offers a subset of the Dashboard Server from previous software versions.
1414

15-
Some functions are also wrapped into ``command...()`` functions such as
16-
``commandCloseSafetyPopup()``. These functions are blocking and will wait for the necessary action
17-
being done. This can involve querying another call to the dashboard server until the action is
18-
done. For example, ``commandPowerOn()`` will block until the robot reports "Robotmode: RUNNING" or
19-
the given timeout is reached.
15+
After connecting to the dashboard server by using the ``connect()`` function, dashboard calls can
16+
be done using the ``command...()`` functions such as ``commandCloseSafetyPopup()``. These functions
17+
are blocking and will wait for the necessary action being done. This can involve querying another
18+
call to the dashboard server until the action is done. For example, ``commandPowerOn()`` will block
19+
until the robot reports "Robotmode: RUNNING" or the given timeout is reached.
2020

21-
The `dashboard_example.cpp <https://github.com/UniversalRobots/Universal_Robots_Client_Library/blob/master/examples/dashboard_example.cpp>`_ shows how to use this class:
21+
The return value of those functions indicate whether or not the call was successful. If you want to
22+
get the call's full response, use the ``command...WithResponse()`` calls, instead. They will return
23+
a response struct
24+
25+
.. literalinclude:: ../../include/ur_client_library/ur/dashboard_client_implementation.h
26+
:language: c++
27+
:caption: urcl::DashboardResponse
28+
:start-at: struct DashboardResponse
29+
:end-at: };
30+
31+
The ``data`` dictionary of that response struct is populated by each command individually. See the
32+
commands' docstrings for details.
33+
34+
The `dashboard_example.cpp <https://github.com/UniversalRobots/Universal_Robots_Client_Library/blob/master/examples/dashboard_example.cpp>`_ shows how to use the dashboard client:
2235

2336
.. literalinclude:: ../../examples/dashboard_example.cpp
2437
:language: c++
2538
:caption: examples/dashboard_example.cpp
2639
:linenos:
2740
:lineno-match:
2841
:start-at: std::make_unique<DashboardClient>
29-
:end-at: my_dashboard->commandCloseSafetyPopup();
42+
:end-at: return 0
43+
44+
CB 3 and PolyScope 5 only
45+
-------------------------
46+
47+
All commands are blocking and will wait for the necessary action being done. The dashboard server's
48+
response will be compared with an expected response. For example, when calling
49+
``commandPowerOn(timeout)``, it is checked that the dashboard server is answering ``"Powering on"`` and
50+
then it is queried until the robot reports ``"Robotmode: IDLE"`` or until the timeout is reached.
51+
The example contains more commands that follow the same scheme.
52+
53+
54+
If you want to send a query / command to the dashboard server and only want to receive the
55+
response, you can use the ``sendAndReceive()`` function:
56+
57+
.. literalinclude:: ../../examples/dashboard_example.cpp
58+
:language: c++
59+
:caption: examples/dashboard_example.cpp
60+
:linenos:
61+
:lineno-match:
62+
:start-at: // Make a raw request and save the response
63+
:end-at: URCL_LOG_INFO("Program state: %s", program_state.c_str());
64+
65+
For checking the response against an expected regular expression use ``sendRequest()``:
66+
67+
.. literalinclude:: ../../examples/dashboard_example.cpp
68+
:language: c++
69+
:caption: examples/dashboard_example.cpp
70+
:linenos:
71+
:lineno-match:
72+
:start-at: // The response can be checked with a regular expression
73+
:end-at: URCL_LOG_INFO("Power off command success: %d", success);
74+
75+
PolyScope X only
76+
----------------
77+
78+
Internally, the dashboard client makes calls against a RESTful (**Re**\ presentational **S**\ tate **T**\ ransfer) API. Hence, all responses contain a JSON-encoded string of the received answer. For example, an answer to a pause request could be
79+
80+
.. code-block:: json
81+
82+
{"state":"PAUSED","message":"Program state changed: PAUSED","details":"Pause successful"}

doc/examples/dashboard_client.rst

Lines changed: 13 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,30 @@ This example shows how to use the builtin `Dashboard server <https://www.univers
77

88
.. note::
99

10-
The Dashboard Server is only available on CB3 and e-Series robots. It is not available on
11-
PolyScope X.
10+
The Dashboard Server euqivalent for PolyScope X is called the Robot API. In the client library
11+
it is accessed through the DashboardClient, as well, as it is meant as a replacement for the
12+
Dashboard Server. It doesn't offer full feature parity at the time of writing and is available
13+
only from Software 10.11.0 on.
1214

1315

1416
The `dashboard_example.cpp <https://github.com/UniversalRobots/Universal_Robots_Client_Library/blob/master/examples/dashboard_example.cpp>`_ shows how to use this class:
1517

16-
.. note:: For the following example to work on an e-Series (PolyScope 5) robot, the robot has to be
17-
in *remote control mode*.
18+
.. note:: For the following example to work, the robot has to be in *remote control mode*. CB3
19+
robots don't require that.
1820

1921
.. literalinclude:: ../../examples/dashboard_example.cpp
2022
:language: c++
2123
:caption: examples/dashboard_example.cpp
2224
:linenos:
2325
:lineno-match:
24-
:start-at: std::make_unique<DashboardClient>
26+
:start-at: // Query the robot information
2527
:end-at: my_dashboard->commandCloseSafetyPopup();
2628

27-
At first, a ``DashboardClient`` object is created with the IP address of the robot. Then, the
28-
client is connected to the robot. After that, the client sends a command to the robot and receives
29-
the answer.
29+
At first, a ``DashboardClient`` object is created with the IP address of the robot and a
30+
DashboardClient implementation policy. That policy can be either ``POLYSCOPE_X`` or ``G5``. To
31+
generalize this, the robot's sofware version is queried using the primary interface beforehand.
32+
Then, the client is connected to the robot. After that, the client sends a command to the robot and
33+
receives the answer.
3034

3135
Some commands support getting the response from the robot. For example, the
3236
``commandPolyScopeVersion()`` function:
@@ -49,34 +53,5 @@ initialization:
4953
:linenos:
5054
:lineno-match:
5155
:start-at: // Power it on
52-
:end-at: // Load existing program
53-
54-
All commands are blocking and will wait for the necessary action being done. The dashboard server's
55-
response will be compared with an expected response. For example, when calling
56-
``commandPowerOn(timeout)``, it is checked that the dashboard server is answering ``"Powering on"`` and
57-
then it is queried until the robot reports ``"Robotmode: IDLE"`` or until the timeout is reached.
58-
The example contains more commands that follow the same scheme.
59-
60-
61-
If you want to send a query / command to the dashboard server and only want to receive the
62-
response, you can use the ``sendAndReceive()`` function:
63-
64-
.. literalinclude:: ../../examples/dashboard_example.cpp
65-
:language: c++
66-
:caption: examples/dashboard_example.cpp
67-
:linenos:
68-
:lineno-match:
69-
:start-at: // Make a raw request and save the response
70-
:end-at: URCL_LOG_INFO("Program state: %s", program_state.c_str());
71-
72-
For checking the response against an expected regular expression use ``sendRequest()``:
73-
74-
.. literalinclude:: ../../examples/dashboard_example.cpp
75-
:language: c++
76-
:caption: examples/dashboard_example.cpp
77-
:linenos:
78-
:lineno-match:
79-
:start-at: // The response can be checked with a regular expression
80-
:end-at: URCL_LOG_INFO("Power off command success: %d", success);
81-
56+
:end-before: // Load existing program
8257

doc/polyscope_compatibility.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ table below or checkout the latest tag before the breaking changes were introduc
4141
|polyscope| X doesn't support all features supported by this library for |polyscope| 5.
4242
Currently, the following components are known not to be supported:
4343

44-
- Dashboard client -- |polyscope| X doesn't have a dashboard server.
44+
- Dashboard client -- |polyscope| X received the first implementation of the Robot API
45+
replacing the Dashboard Server in version 10.11.0. It covers robot state control and loading
46+
and playing programs.
4547
- Using external control on |polyscope| X requires another URCapX for making external control
4648
work. This is currently in the process of being created.
4749
See `Universal Robots External Control URCapX <https://github.com/UniversalRobots/Universal_Robots_ExternalControl_URCapX>`_

examples/dashboard_example.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,28 @@ int main(int argc, char* argv[])
5959
robot_ip = std::string(argv[1]);
6060
}
6161

62+
// Query the robot information from the primary interface in order to select the correct
63+
// implementation policy.
6264
urcl::comm::INotifier notifier;
6365
urcl::primary_interface::PrimaryClient primary_client(robot_ip, notifier);
6466
primary_client.start();
6567
auto version_information = primary_client.getRobotVersion();
68+
DashboardClient::ClientPolicy policy = DashboardClient::ClientPolicy::POLYSCOPE_X;
69+
if (version_information->major < 10)
70+
{
71+
policy = DashboardClient::ClientPolicy::G5;
72+
}
6673

6774
// Connect to the robot Dashboard Server
68-
auto my_dashboard = std::make_unique<DashboardClient>(robot_ip, DashboardClient::ClientPolicy::POLYSCOPE_X);
75+
auto my_dashboard = std::make_unique<DashboardClient>(robot_ip, policy);
6976
if (!my_dashboard->connect())
7077
{
7178
URCL_LOG_ERROR("Could not connect to dashboard");
7279
return 1;
7380
}
7481

82+
// Bring the robot to a defined state being powered off. We're ignoring errors here since
83+
// powering off an already powered off robot will return an error.
7584
if (version_information->major < 10)
7685
{
7786
if (!my_dashboard->commandPowerOff())

0 commit comments

Comments
 (0)