Skip to content
Binary file added example_1/doc/ros2_control_demo_example_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
82 changes: 82 additions & 0 deletions example_1/doc/userdoc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,77 @@ The *RRBot* URDF files can be found in the ``description/urdf`` folder.

.. include:: ../../doc/run_from_docker.rst


RRBot Architecture Overview
---------------------------

.. image:: ros2_control_demo_example_1.png
:width: 600
:align: center
:alt: ROS 2 Control Demo Example 1 Architecture Overview

This section provides an overview of how **ROS2 Control** components interact in *Example 1 (RRBot System Position Only)*. It summarizes the relationship between the hardware interface, controllers, and the robot’s URDF.

A custom hardware interface ``RRBotSystemPositionOnlyHardware`` is implemented in:
``ros2_control_demo_example_1/rrbot_hardware_interface.cpp``

This hardware plugin:

- Inherits from ``hardware_interface::SystemInterface``
- Defines how to **read joint positions** (from hardware, simulated here)
- Defines how to **write commands** (set joint positions)
- Is registered in a ``plugin.xml`` file so the **ResourceManager** can load it

From the UML:

- ``hardware_interface::SystemInterface`` → implemented by the RRBot hardware plugin
- ``hardware_interface::ResourceManager`` → manages your hardware plugin after loading it

The robot description is defined in:
``rrbot.urdf.xacro``

The URDF contains:

- Links and joints of the robot
- A ``<ros2_control>`` tag specifying which hardware plugin to load

When launched, **ros2_control** reads this URDF and knows:

- Which joints exist
- Which hardware plugin provides those joints

From the UML:

- ``robot_config (URDF)`` → parsed into **``hardware_interface::HardwareInfo``** and passed to **ResourceManager**

The ``controller_manager::ControllerManager`` is the core ROS2 node.

Responsibilities:

- Loads your hardware plugin (via **ResourceManager**)
- Loads and manages controllers (defined in a YAML config file)

From the UML:

- ``controller_manager::ControllerManager`` → central node
- Uses ``controllers_config (YAML)`` and ``robot_config (URDF)`` to configure everything

**Forward Command Controller**

- ``forward_position_controller`` (from ``forward_command_controller`` package)
- Directly forwards position commands to the hardware interface

**Joint State Broadcaster**

- Publishes ``/joint_states``
- Allows visualization of the robot in RViz

From the UML:

- ``controller_interface::ControllerInterface`` → base class for controllers
- ``forward_command_controller::ForwardCommandController`` → used in this demo
- ``joint_state_broadcaster::JointStateBroadcaster`` → publishes joint states

Tutorial steps
--------------------------

Expand Down Expand Up @@ -501,3 +572,14 @@ Controllers from this demo
* ``Joint State Broadcaster`` (`ros2_controllers repository <https://github.com/ros-controls/ros2_controllers/tree/{REPOS_FILE_BRANCH}/joint_state_broadcaster>`__): :ref:`doc <joint_state_broadcaster_userdoc>`
* ``Forward Command Controller`` (`ros2_controllers repository <https://github.com/ros-controls/ros2_controllers/tree/{REPOS_FILE_BRANCH}/forward_command_controller>`__): :ref:`doc <forward_command_controller_userdoc>`
* ``Joint Trajectory Controller`` (`ros2_controllers repository <https://github.com/ros-controls/ros2_controllers/tree/{REPOS_FILE_BRANCH}/joint_trajectory_controller>`__): :ref:`doc <joint_trajectory_controller_userdoc>`



Additional Resources for this demo
----------------------------------
* `UML Class Diagram of example_1 <https://github.com/ros-controls/ros2_control_demos/tree/{REPOS_FILE_BRANCH}/example_1/doc/ros2_control_demo_example_1.svg>`__ a visual representation of the RRBot hardware interface architecture.

* `Summary Explanation of example_1 <https://github.com/ros-controls/ros2_control_demos/tree/{REPOS_FILE_BRANCH}/example_1/doc/summary_explanation_example_1.md>`__ a step-by-step explanation of the demo’s architecture and component interaction.