Skip to content
Open
4 changes: 4 additions & 0 deletions example_1/doc/ros2_control_demo_example_1.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
78 changes: 78 additions & 0 deletions example_1/doc/summary_explanation_example_1.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
# ROS2 Control - Example 1 (RRBot System Position Only)

This example demonstrates the **basic architecture of ROS2 Control** using a simple 2-joint robot (**RRBot**) with a custom hardware interface and controllers.

---

## Hardware

The robot (**RRBot**) is a simple 2-joint robot.

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

---

## Robot Description (URDF/Xacro)

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**

---

## Controller Manager

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

---

## Controllers

**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

---

11 changes: 11 additions & 0 deletions example_1/doc/userdoc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -501,3 +501,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.