@@ -8,7 +8,8 @@ applications using this library, follow the usual cmake procedure:
88
99.. code :: console
1010
11- $ cd <clone of this repository>
11+ $ git clone https://github.com/UniversalRobots/Universal_Robots_Client_Library ur_client_library
12+ $ cd ur_client_library
1213 $ mkdir build && cd build
1314 $ cmake ..
1415 $ make
@@ -24,9 +25,9 @@ Inside a ROS / ROS 2 workspace
2425The ``ur_client_library `` is available in all maintained ROS distribution and can be installed
2526using
2627
27- .. code-block :: console
28+ .. code :: console
2829
29- $ sudo apt install ros-<distro> -ur-client-library
30+ $ sudo apt install ros-$ROS_DISTRO -ur-client-library
3031
3132 Unless you explicitly want to contribute to this library we recommend using the binary installation
3233instead of building from source as explained below.
@@ -57,15 +58,23 @@ Use this library in other projects
5758
5859When you want to use this library in other cmake projects, make sure to
5960
60- * Add ``find_package(ur_client_library REQUIRED) `` to your ``CMakeLists.txt ``
61+ * Add ``find_package(ur_client_library REQUIRED) `` to your ``CMakeLists.txt `` (Requires to have the
62+ client library installed and your PATH setup done correctly. As an alternative, fetch and build
63+ it as part of your project as shown below.)
6164* add ``ur_client_library::urcl `` to the list of ``target_link_libraries(...) `` commands inside your
62- ``CMakeLists.txt `` file
65+ ``CMakeLists.txt `` file.
6366
6467As a minimal example, take the following “project”:
6568
66- .. code :: cpp
69+ As a minimal executable, we'll create a client for the dashboard server and ask for the
70+ PolyscopeVersion.
71+
72+ .. note :: This will not work on Polyscope X versions, as the dashboard server is not available
73+ there.
6774
68- /*main.cpp*/
75+ .. code-block :: cpp
76+ :caption: main.cpp
77+ :linenos:
6978
7079 #include <iostream>
7180 #include <ur_client_library/ur/dashboard_client.h>
@@ -83,13 +92,43 @@ As a minimal example, take the following “project”:
8392 return 0;
8493 }
8594
86- .. code :: cmake
95+ In this example, we'll fetch the client library as part of the project and build it together with
96+ our application:
8797
88- # CMakeLists.txt
98+ .. code-block :: cmake
99+ :caption: CMakeLists.txt
100+ :linenos:
89101
90- cmake_minimum_required(VERSION 3.0.2)
102+ cmake_minimum_required(VERSION 3.11.0) # That's the minimum required version for FetchContent
91103 project(minimal_example)
92104
93- find_package(ur_client_library REQUIRED)
105+ include(FetchContent)
106+ FetchContent_Declare(
107+ ur_client_library
108+ GIT_REPOSITORY https://github.com/UniversalRobots/Universal_Robots_Client_Library.git
109+ GIT_TAG master
110+ )
111+
112+ # This will download the ur_client_library and replace the `find_package(ur_client_library)` call.
113+ FetchContent_MakeAvailable(ur_client_library)
114+
94115 add_executable(db_client main.cpp)
95116 target_link_libraries(db_client ur_client_library::urcl)
117+
118+ To build the project, create a build directory and run cmake:
119+
120+ .. code :: console
121+
122+ $ mkdir build && cd build
123+ $ cmake ..
124+ $ cmake --build .
125+
126+ Then (with a robot switched on and available on 192.168.56.101), you can test the minimal example application:
127+
128+ .. code :: console
129+
130+ $ ./db_client
131+ INFO /<...>/ur/dashboard_client.cpp 72: Connected: Universal Robots Dashboard Server
132+
133+ URSoftware 5.19.0.1210631 (Oct 23 2024)
134+ INFO /<...>/ur/dashboard_client.cpp 98: Disconnecting from Dashboard server on 192.168.56.101:29999
0 commit comments