Skip to content

Commit

Permalink
WIP: service interface examples
Browse files Browse the repository at this point in the history
  • Loading branch information
ipa-vsp committed Apr 23, 2024
1 parent c4e9d1b commit db3a93d
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 11 deletions.
66 changes: 66 additions & 0 deletions canopen/sphinx/examples/service-interface-examples.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
Service Interface Examples
==========================

Before running these examples, ensure that to :ref:`start the vcan0 interface <quick-start-setup-can-controller>`.
You can find these examples in the ``canopen_test`` package.

Proxy Driver Examples
---------------------
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`.

Configuring ``bus.yaml``
~~~~~~~~~~~~~~~~~~~~~~~~
The configuration for the proxy driver is specified in the ``bus.yaml`` file. Here's an example configuration:

.. code-block:: yaml
options:
dcf_path: "@BUS_CONFIG_PATH@"
master:
node_id: 1
driver: "ros2_canopen::MasterDriver"
package: "canopen_master_driver"
defaults:
dcf: "simple.eds"
driver: "ros2_canopen::ProxyDriver"
package: "canopen_proxy_driver"
polling: true
period: 10
nodes:
proxy_device_1:
node_id: 2
proxy_device_2:
node_id: 3
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.

Running the Proxy Driver Examples
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To launch the proxy driver setup, use the following command:

.. code-block:: bash
$ ros2 launch canopen_tests proxy_setup.launch.py
Verify that all services are available by running the ROS2 topic and service list commands. To conduct a test:

.. code-block:: bash
$ ros2 topic pub /proxy_device_1/tpdo canopen_interfaces/msg/COData "{ index: 0x4000, subindex: 0, data: 200 }"
Check the output by running:

.. code-block:: bash
$ ros2 topic echo /proxy_device_1/rpdo
.. note::

These examples use a fake slave device. Running on actual hardware may yield different results.
Always refer to the device's documentation for specific details.

CiA402 Driver Examples
-----------------------
9 changes: 8 additions & 1 deletion canopen/sphinx/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,13 @@ This is the documentation of the ROS2 CANopen stack.
user-guide/how-to-create-a-cia301-system
user-guide/how-to-create-a-robot-system

.. toctree::
:maxdepth: 1
:caption: Examples
:glob:

examples/service-interface-examples


.. toctree::
:maxdepth: 1
Expand All @@ -37,7 +44,7 @@ This is the documentation of the ROS2 CANopen stack.
developers-guide/architecture
developers-guide/new-driver
developers-guide/new-master
API Reference <https://ros-industrial.github.io/ros2_canopen/api/>
API Reference <https://ros-industrial.github.io/ros2_canopen/api/rolling/>

.. toctree::
:maxdepth: 1
Expand Down
2 changes: 1 addition & 1 deletion canopen_tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ find_package(ament_cmake REQUIRED)
find_package(lely_core_libraries REQUIRED)


generate_dcf(simple)
cogen_dcf(simple)
generate_dcf(canopen_system)
cogen_dcf(cia402_system)
cogen_dcf(cia402_namespaced_system)
Expand Down
15 changes: 6 additions & 9 deletions canopen_tests/config/simple/bus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@ master:
driver: "ros2_canopen::MasterDriver"
package: "canopen_master_driver"

proxy_device_1:
node_id: 2
defaults:
dcf: "simple.eds"
driver: "ros2_canopen::ProxyDriver"
package: "canopen_proxy_driver"
polling: true
period: 10

proxy_device_2:
node_id: 3
dcf: "simple.eds"
driver: "ros2_canopen::ProxyDriver"
package: "canopen_proxy_driver"
polling: true
period: 10
nodes:
proxy_device_1:
node_id: 2
proxy_device_2:
node_id: 3

0 comments on commit db3a93d

Please sign in to comment.