Skip to content

Commit db3a93d

Browse files
committed
WIP: service interface examples
1 parent c4e9d1b commit db3a93d

File tree

4 files changed

+81
-11
lines changed

4 files changed

+81
-11
lines changed
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
Service Interface Examples
2+
==========================
3+
4+
Before running these examples, ensure that to :ref:`start the vcan0 interface <quick-start-setup-can-controller>`.
5+
You can find these examples in the ``canopen_test`` package.
6+
7+
Proxy Driver Examples
8+
---------------------
9+
A proxy driver provides a simple way to forward CANopen functionalities for a specific device using ROS2 services and messages. For more details on the proxy driver, see :doc:`../user-guide/proxy-driver`.
10+
11+
Configuring ``bus.yaml``
12+
~~~~~~~~~~~~~~~~~~~~~~~~
13+
The configuration for the proxy driver is specified in the ``bus.yaml`` file. Here's an example configuration:
14+
15+
.. code-block:: yaml
16+
17+
options:
18+
dcf_path: "@BUS_CONFIG_PATH@"
19+
20+
master:
21+
node_id: 1
22+
driver: "ros2_canopen::MasterDriver"
23+
package: "canopen_master_driver"
24+
25+
defaults:
26+
dcf: "simple.eds"
27+
driver: "ros2_canopen::ProxyDriver"
28+
package: "canopen_proxy_driver"
29+
polling: true
30+
period: 10
31+
32+
nodes:
33+
proxy_device_1:
34+
node_id: 2
35+
proxy_device_2:
36+
node_id: 3
37+
38+
For further details about the configuration, refer to :doc:`../user-guide/configuration`. Additionally, add ``cogen_dcf(simple)`` in the *CMakeLists.txt* file to generate the necessary artifacts for the proxy driver.
39+
40+
Running the Proxy Driver Examples
41+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
42+
To launch the proxy driver setup, use the following command:
43+
44+
.. code-block:: bash
45+
46+
$ ros2 launch canopen_tests proxy_setup.launch.py
47+
48+
Verify that all services are available by running the ROS2 topic and service list commands. To conduct a test:
49+
50+
.. code-block:: bash
51+
52+
$ ros2 topic pub /proxy_device_1/tpdo canopen_interfaces/msg/COData "{ index: 0x4000, subindex: 0, data: 200 }"
53+
54+
Check the output by running:
55+
56+
.. code-block:: bash
57+
58+
$ ros2 topic echo /proxy_device_1/rpdo
59+
60+
.. note::
61+
62+
These examples use a fake slave device. Running on actual hardware may yield different results.
63+
Always refer to the device's documentation for specific details.
64+
65+
CiA402 Driver Examples
66+
-----------------------

canopen/sphinx/index.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,13 @@ This is the documentation of the ROS2 CANopen stack.
2626
user-guide/how-to-create-a-cia301-system
2727
user-guide/how-to-create-a-robot-system
2828

29+
.. toctree::
30+
:maxdepth: 1
31+
:caption: Examples
32+
:glob:
33+
34+
examples/service-interface-examples
35+
2936

3037
.. toctree::
3138
:maxdepth: 1
@@ -37,7 +44,7 @@ This is the documentation of the ROS2 CANopen stack.
3744
developers-guide/architecture
3845
developers-guide/new-driver
3946
developers-guide/new-master
40-
API Reference <https://ros-industrial.github.io/ros2_canopen/api/>
47+
API Reference <https://ros-industrial.github.io/ros2_canopen/api/rolling/>
4148

4249
.. toctree::
4350
:maxdepth: 1

canopen_tests/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ find_package(ament_cmake REQUIRED)
1010
find_package(lely_core_libraries REQUIRED)
1111

1212

13-
generate_dcf(simple)
13+
cogen_dcf(simple)
1414
generate_dcf(canopen_system)
1515
cogen_dcf(cia402_system)
1616
cogen_dcf(cia402_namespaced_system)

canopen_tests/config/simple/bus.yml

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,15 @@ master:
66
driver: "ros2_canopen::MasterDriver"
77
package: "canopen_master_driver"
88

9-
proxy_device_1:
10-
node_id: 2
9+
defaults:
1110
dcf: "simple.eds"
1211
driver: "ros2_canopen::ProxyDriver"
1312
package: "canopen_proxy_driver"
1413
polling: true
1514
period: 10
1615

17-
proxy_device_2:
18-
node_id: 3
19-
dcf: "simple.eds"
20-
driver: "ros2_canopen::ProxyDriver"
21-
package: "canopen_proxy_driver"
22-
polling: true
23-
period: 10
16+
nodes:
17+
proxy_device_1:
18+
node_id: 2
19+
proxy_device_2:
20+
node_id: 3

0 commit comments

Comments
 (0)