|
5 | 5 | DashboardClient |
6 | 6 | =============== |
7 | 7 |
|
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/>`_ |
9 | 9 | directly into C++ functions. |
10 | 10 |
|
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. |
14 | 14 |
|
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. |
20 | 20 |
|
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: |
22 | 35 |
|
23 | 36 | .. literalinclude:: ../../examples/dashboard_example.cpp |
24 | 37 | :language: c++ |
25 | 38 | :caption: examples/dashboard_example.cpp |
26 | 39 | :linenos: |
27 | 40 | :lineno-match: |
28 | 41 | :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"} |
0 commit comments