Skip to content

Commit adcf6cf

Browse files
committed
Update ScriptSender documentation with example
1 parent 648973f commit adcf6cf

File tree

5 files changed

+80
-6
lines changed

5 files changed

+80
-6
lines changed

doc/conf.py renamed to conf.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import os
2020
import catkin_pkg.package
2121

22-
catkin_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
22+
catkin_dir = os.path.dirname(os.path.abspath(__file__))
2323
catkin_package = catkin_pkg.package.parse_package(
2424
os.path.join(catkin_dir, catkin_pkg.package.PACKAGE_MANIFEST_FILENAME)
2525
)
@@ -63,7 +63,7 @@
6363
source_suffix = ".rst"
6464

6565
# The master toctree document.
66-
master_doc = "index"
66+
master_doc = "doc/index"
6767

6868
# The language for content autogenerated by Sphinx. Refer to documentation
6969
# for a list of supported languages.
@@ -87,11 +87,11 @@
8787
# a list of builtin themes.
8888
#
8989
html_theme = "sphinx_rtd_theme"
90-
html_static_path = ["_static"]
91-
html_logo = "_static/images/ur_logo.svg"
92-
html_favicon = "_static/images/icon.svg"
90+
html_static_path = ["doc/_static"]
91+
html_logo = "doc/_static/images/ur_logo.svg"
92+
html_favicon = "doc/_static/images/icon.svg"
9393
html_css_files = [
94-
'css/ur_theme.css',
94+
'doc/css/ur_theme.css',
9595
]
9696

9797
# Theme options are theme-specific and customize the look and feel of a theme

doc/architecture.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ The core of this library is the ``UrDriver`` class which creates a
1313
fully functioning robot interface. For details on how to use it, please see the
1414
:ref:`example-driver` section.
1515

16+
.. toctree::
17+
:maxdepth: 1
18+
19+
architecture/script_sender
20+
1621
The ``UrDriver``'s modules will be explained in the following.
1722

1823
RTDEClient

doc/architecture/script_sender.rst

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
ScriptSender
2+
============
3+
4+
The ``ScriptSender`` class opens a tcp socket listens for "*request_program*" request. Upon such a
5+
request, a predefined URScript code is sent to the caller. The script code itself has to be passed
6+
to the ``ScriptSender``'s constructor.
7+
8+
Use this class in conjunction with the `External Control URCap
9+
<https://github.com/UniversalRobots/Universal_Robots_ExternalControl_URCap>`_ which will make the
10+
corresponding request when starting a program on the robot that contains the **External Control**
11+
program node. In order to work properly, make sure that the IP address and script sender port are
12+
configured correctly on the robot.
13+
14+
The following example creates a ``ScriptSender`` listening on port ``12345`` and sends the script
15+
``textmsg("Hello, World!")`` when requested. A fully compilable example can be found in `script_sender.cpp <https://github.com/UniversalRobots/Universal_Robots_Client_Library/blob/master/examples/script_sender.cpp>`_
16+
17+
.. literalinclude:: ../../examples/script_sender.cpp
18+
:language: c++
19+
:linenos:
20+
:start-at: constexpr uint32_t PORT

examples/CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,3 +54,8 @@ add_executable(force_mode_example
5454
force_mode_example.cpp)
5555
target_compile_options(force_mode_example PUBLIC ${CXX17_FLAG})
5656
target_link_libraries(force_mode_example ur_client_library::urcl)
57+
58+
add_executable(script_sender_example
59+
script_sender.cpp)
60+
target_compile_options(script_sender_example PUBLIC ${CXX17_FLAG})
61+
target_link_libraries(script_sender_example ur_client_library::urcl)

examples/script_sender.cpp

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// -- BEGIN LICENSE BLOCK ----------------------------------------------
2+
// Copyright 2024 Universal Robots A/S
3+
//
4+
// Licensed under the Apache License, Version 2.0 (the "License");
5+
// you may not use this file except in compliance with the License.
6+
// You may obtain a copy of the License at
7+
//
8+
// http://www.apache.org/licenses/LICENSE-2.0
9+
//
10+
// Unless required by applicable law or agreed to in writing, software
11+
// distributed under the License is distributed on an "AS IS" BASIS,
12+
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
// See the License for the specific language governing permissions and
14+
// limitations under the License.
15+
// -- END LICENSE BLOCK ------------------------------------------------
16+
17+
//----------------------------------------------------------------------
18+
/*!\file
19+
*
20+
* \author Felix Exner [email protected]
21+
* \date 2024-12-04
22+
*
23+
*/
24+
//----------------------------------------------------------------------
25+
26+
#include <iostream>
27+
#include <thread>
28+
29+
#include <ur_client_library/control/script_sender.h>
30+
31+
constexpr uint32_t PORT = 12345;
32+
int main(int argc, char* argv[])
33+
{
34+
urcl::control::ScriptSender sender(PORT, "textmsg(\"Hello, World!\")");
35+
36+
std::cout << "Waiting for incoming requests on port " << PORT << "..." << std::endl;
37+
38+
while (true)
39+
{
40+
std::this_thread::sleep_for(std::chrono::seconds(1));
41+
}
42+
43+
return 0;
44+
}

0 commit comments

Comments
 (0)