Skip to content

Commit 046ce0c

Browse files
destoglbmagyarv-lopez
authored
Add corrections and extensions for the rrbot (#71)
* Add corrections and extensions for the rrbot * Correct build and remove demo nodes from readme. * Apply suggestions from code review Co-authored-by: Bence Magyar <[email protected]> * Adjust colors of the robot * Update ros2_control_demo_robot/package.xml Co-authored-by: Victor Lopez <[email protected]> * Update ros2_control_demo_robot/launch/test_rrbot_description.launch.py Co-authored-by: Bence Magyar <[email protected]> Co-authored-by: Victor Lopez <[email protected]>
1 parent 620b703 commit 046ce0c

File tree

13 files changed

+464
-142
lines changed

13 files changed

+464
-142
lines changed

README.md

Lines changed: 130 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
# ROS2 Control Demos
1+
# ros2_control Demos
22

33
[![Build Status](https://github.com/ros-controls/ros2_control_demos/workflows/CI/badge.svg?branch=master)](https://github.com/ros-controls/ros2_control_demos/actions?query=workflow%3ACI)
44
[![Linters Status](https://github.com/ros-controls/ros2_control_demos/workflows/Linters/badge.svg?branch=master)](https://github.com/ros-controls/ros2_control_demos/actions?query=workflow%3ALinters)
55
[![Coverage Status](https://github.com/ros-controls/ros2_control_demos/workflows/Coverage/badge.svg?branch=master)](https://github.com/ros-controls/ros2_control_demos/actions?query=workflow%3ACoverage)
66
[![Licence](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
77

8-
This repository provides templates for the development of `ros2_control`-enabled robots and a simple simulation of a robot.
8+
This repository provides templates for the development of `ros2_control`-enabled robots and a simple simulations to demonstrate and prove `ros2_control` concepts.
99

1010
## Goals
1111

@@ -46,10 +46,15 @@ These are some quick hints, especially for those coming from a ROS1 control back
4646
* <ros2_control> tags in the URDF must be compatible with the controller's configuration.
4747
* PLUGINLIB_EXPORT_CLASS macro is required when implementing an interface.
4848

49-
# Test of the Scenario Before the First Release
50-
* Checkout [ros-controls/ros2_control](https://github.com/ros-controls/ros2_control) to get the core.
51-
* Checkout [ros-controls/ros2_controllers](https://github.com/ros-controls/ros2_controllers) to get all the controllers.
52-
* Checkout [ros-controls/ros2_control_demos](https://github.com/ros-controls/ros2_control_demos) to get example hardware and robot launch files.
49+
# Build from source
50+
```
51+
git clone https://github.com/ros-controls/ros2_control
52+
git clone https://github.com/ros-controls/ros2_controllers
53+
git clone https://github.com/ros-controls/ros2_control_demos
54+
```
55+
56+
**NOTE**: `ros2_control` and `ros2_controllers` packages are released for foxy and can be installed using package manager.
57+
For daily use it is recommended to use the released version but there may always be some not-yet-released changes that are required to build the demos.
5358

5459
* Install dependencies (maybe you need `sudo`):
5560
```
@@ -64,80 +69,125 @@ These are some quick hints, especially for those coming from a ROS1 control back
6469
* Do not forget to source `setup.bash` from the `install` folder!
6570

6671

67-
# Getting Started with ROS2 Control
72+
# Getting Started with ros2_control
6873

6974
Each of the described example cases from the roadmap has its own launch and URDF file.
7075

71-
## Example 1: "Industrial Robots with only one interface"
72-
73-
1. Start the roslaunch file:
74-
```
75-
ros2 launch ros2_control_demo_robot rrbot_system_position_only.launch.py
76-
```
77-
78-
2. Open another terminal and check if `RRBotSystemPositionOnlyHardware` is loaded properly:
79-
```
80-
ros2 control list_hardware_interfaces
81-
```
82-
You should get something like:
83-
```
84-
command interfaces
85-
joint1/position [unclaimed]
86-
joint2/position [unclaimed]
87-
state interfaces
88-
joint1/position
89-
joint2/position
90-
```
91-
92-
3. Open another terminal and load, configure, and start controllers:
93-
```
94-
ros2 control load_start_controller joint_state_controller
95-
ros2 control load_configure_controller forward_command_controller_position
96-
```
97-
98-
Check if the controller is loaded properly:
99-
```
100-
ros2 control list_controllers
101-
```
102-
You should get the response:
103-
```
104-
joint_state_controller[joint_state_controller/JointStateController] active
105-
forward_command_controller_position[forward_command_controller/ForwardCommandController] inactive
106-
```
107-
108-
4. Starting controller:
109-
```
110-
ros2 control switch_controllers --start-controllers forward_command_controller_position
111-
```
112-
113-
Check if controllers are activated:
114-
```
115-
ros2 control list_controllers
116-
```
117-
You should get `active` in the response:
118-
```
119-
joint_state_controller[joint_state_controller/JointStateController] active
120-
forward_command_controller_position[forward_command_controller/ForwardCommandController] active
121-
```
122-
123-
5. Open another terminal and send a message to the controller:
124-
```
125-
ros2 topic pub /forward_command_controller_position/commands std_msgs/msg/Float64MultiArray "data:
126-
- 0.5
127-
- 0.5"
128-
```
129-
130-
You should see how the example output changes. Look for the following lines
131-
```
132-
[RRBotSystemPositionOnlyHardware]: Got state 0.0 for joint 0!
133-
[RRBotSystemPositionOnlyHardware]: Got state 0.0 for joint 1!
134-
```
135-
136-
If you echo the `/joint_states` or `/dynamic_joint_states` topics you should also get similar values.
137-
```
138-
ros2 topic echo /joint_states
139-
ros2 topic echo /dynamic_joint_states
140-
```
141-
142-
The other launch-files have corresponding names to their coresponding example.
143-
The URDF files can be found in the `description` folder.
76+
## Starting example robots
77+
78+
Each example is started with a single launch file which starts up the robot hardware, loads controller configurations and it also opens `rviz2`.
79+
80+
The `rviz2` setup can be recreated following these steps:
81+
82+
- The robot models can be visualized using `RobotModel` display using `/robot_description` topic.
83+
- Or you can simply open the configuration from `rviz` folder in `ros2_control_demo_robot` package manually or directly by executing:
84+
```
85+
rviz2 --display-config `ros2 pkg prefix ros2_control_demo_robot`/share/ros2_control_demo_robot/rviz/rrbot.rviz
86+
```
87+
88+
*RRBot*, or ''Revolute-Revolute Manipulator Robot'', is a simple 3-linkage, 2-joint arm that we will use to demonstrate various features. It essentially a double inverted pendulum and demonstrates some fun control concepts within a simulator and was originally introduced for Gazebo tutorials.
89+
The *RRbot* URDF files can be found in the `description` folder of `ros2_control_demo_robot` package.
90+
91+
### Example 1: "Industrial Robots with only one interface"
92+
93+
1. Open another terminal and start the roslaunch file:
94+
```
95+
ros2 launch ros2_control_demo_robot rrbot_system_position_only.launch.py
96+
```
97+
98+
2. Open another terminal and check that `RRBotSystemPositionOnlyHardware` loaded properly:
99+
```
100+
ros2 control list_hardware_interfaces
101+
```
102+
You should get something like:
103+
```
104+
command interfaces
105+
joint1/position [unclaimed]
106+
joint2/position [unclaimed]
107+
state interfaces
108+
joint1/position
109+
joint2/position
110+
```
111+
112+
## Controlles and moving hardware
113+
To move the robot you should load and start controllers.
114+
The `JointStateController` is used to publish the joint states to ROS topics.
115+
Direct joint commands are sent to this robot via the `ForwardCommandController`.
116+
The sections below describe their usage.
117+
Check the [Results](##result) section on how to ensure that things went well.
118+
119+
### JointStateController
120+
121+
Open another terminal and load, configure and start `joint_state_controller`:
122+
```
123+
ros2 control load_start_controller joint_state_controller
124+
```
125+
Check if controller is loaded properly:
126+
```
127+
ros2 control list_controllers
128+
```
129+
You should get the response:
130+
```
131+
joint_state_controller[joint_state_controller/JointStateController] active
132+
```
133+
134+
Now you should also see the *RRbot* represented correctly in `rviz2`.
135+
136+
137+
### Using ForwardCommandController
138+
139+
1. If you want to test hardware with `ForwardCommandController` first load and configure it:
140+
```
141+
ros2 control load_configure_controller forward_position_controller
142+
```
143+
Check if the controller is loaded properly:
144+
```
145+
ros2 control list_controllers
146+
```
147+
You should get the response:
148+
```
149+
joint_state_controller[joint_state_controller/JointStateController] active
150+
forward_position_controller[forward_command_controller/ForwardCommandController] inactive
151+
```
152+
153+
2. Now start the controller:
154+
```
155+
ros2 control switch_controllers --start-controllers forward_position_controller
156+
```
157+
Check if controllers are activated:
158+
```
159+
ros2 control list_controllers
160+
```
161+
You should get `active` in the response:
162+
```
163+
joint_state_controller[joint_state_controller/JointStateController] active
164+
forward_position_controller[forward_command_controller/ForwardCommandController] active
165+
```
166+
167+
**NOTE**: You can do this in only one step by using `load_start_controller` verb instead of `load_configure_controller`.
168+
169+
3. Send command to the controller, either:
170+
171+
a. Manually using ros2 cli interface:
172+
```
173+
ros2 topic pub /forward_position_controller/commands std_msgs/msg/Float64MultiArray "data:
174+
- 0.5
175+
- 0.5"
176+
```
177+
178+
## Result
179+
180+
1. Independently from the controller you should see how the example's output changes.
181+
Look for the following lines
182+
```
183+
[RRBotSystemPositionOnlyHardware]: Got state 0.0 for joint 0!
184+
[RRBotSystemPositionOnlyHardware]: Got state 0.0 for joint 1!
185+
```
186+
187+
2. If you echo the `/joint_states` or `/dynamic_joint_states` topics you should also get similar values.
188+
```
189+
ros2 topic echo /joint_states
190+
ros2 topic echo /dynamic_joint_states
191+
```
192+
193+
3. You should also see the *RRbot* moving in `rviz2`.

ros2_control_demo_hardware/include/ros2_control_demo_hardware/rrbot_system_position_only.hpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,15 @@
2020
#include <string>
2121
#include <vector>
2222

23-
#include "rclcpp/macros.hpp"
24-
2523
#include "hardware_interface/base_interface.hpp"
2624
#include "hardware_interface/system_interface.hpp"
2725
#include "hardware_interface/handle.hpp"
2826
#include "hardware_interface/hardware_info.hpp"
2927
#include "hardware_interface/types/hardware_interface_return_values.hpp"
3028
#include "hardware_interface/types/hardware_interface_status_values.hpp"
29+
#include "rclcpp/macros.hpp"
3130
#include "ros2_control_demo_hardware/visibility_control.h"
3231

33-
using hardware_interface::return_type;
34-
3532
namespace ros2_control_demo_hardware
3633
{
3734
class RRBotSystemPositionOnlyHardware : public
@@ -41,7 +38,7 @@ class RRBotSystemPositionOnlyHardware : public
4138
RCLCPP_SHARED_PTR_DEFINITIONS(RRBotSystemPositionOnlyHardware);
4239

4340
ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
44-
return_type configure(const hardware_interface::HardwareInfo & info) override;
41+
hardware_interface::return_type configure(const hardware_interface::HardwareInfo & info) override;
4542

4643
ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
4744
std::vector<hardware_interface::StateInterface> export_state_interfaces() override;
@@ -50,16 +47,16 @@ class RRBotSystemPositionOnlyHardware : public
5047
std::vector<hardware_interface::CommandInterface> export_command_interfaces() override;
5148

5249
ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
53-
return_type start() override;
50+
hardware_interface::return_type start() override;
5451

5552
ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
56-
return_type stop() override;
53+
hardware_interface::return_type stop() override;
5754

5855
ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
59-
return_type read() override;
56+
hardware_interface::return_type read() override;
6057

6158
ROS2_CONTROL_DEMO_HARDWARE_PUBLIC
62-
return_type write() override;
59+
hardware_interface::return_type write() override;
6360

6461
private:
6562
// Parameters for the RRBot simulation

0 commit comments

Comments
 (0)