|
| 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 | +----------------------- |
0 commit comments