Skip to content

Commit 3dfe077

Browse files
destogllivanov93bmagyar
authored
Add first example robot (rrbot as system) (#37)
* Implementation of RRBot System Headless Hardware with only position joints. * rrbot system position only after first testing. * Added description of rrbot and example ros2_control_manager. * ROS2 Managers are moved to controller_interface package * Update README.md * Change package names to represent the actual state. * Describe connection to the example URDFs * Add controlle to example 1 and adapt the hardware to provide more sensible example. * Added controller to install path * Change parameter names because deprecated * Reorganize controller's yaml to have correct parameters' namespace. Comment out the name of the node from the roslaunch file to avoid issue with LifecycleNode-Names. Add better robot's movement simulation. * Corrected licence header and add explicit type instead of auto * Update README.md * Update parameter and launch * Update README.md * Reorganize to new RM structure * Update README.md * Updated to new status * Adapt brances and additional output * Add parsing robot_description via xacro. (#45) * Add parsing robot_description via xacro. Co-authored-by: Denis Štogl <denis@stogl.de> * Remove URDF file * Update description * Update linters.yaml * Update ci.yml * Add dependencies * Update ci.yml * Update CMakeLists.txt * Update package.xml * Delete code_coverage.yml * Update ci.yml * Update ci.yml * Update linters.yaml * Update linters.yaml * Update ros2_control_demo_hardware/include/ros2_control_demo_hardware/rrbot_system_position_only.hpp Co-authored-by: Bence Magyar <bence.magyar.robotics@gmail.com> * Update ros2_control_demo_hardware/src/rrbot_system_position_only.cpp Co-authored-by: Bence Magyar <bence.magyar.robotics@gmail.com> * Address review comments. Co-authored-by: livanov93 <lovro.ivanov@gmail.com> Co-authored-by: Bence Magyar <bence.magyar.robotics@gmail.com>
1 parent 7b4968d commit 3dfe077

19 files changed

+1062
-52
lines changed

.github/workflows/ci.yml

Lines changed: 38 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,49 @@ on:
99
- cron: '28 6 * * *'
1010

1111
jobs:
12-
industrial_ci:
12+
ci_binary:
13+
name: Foxy binary job
14+
runs-on: ubuntu-latest
1315
strategy:
1416
matrix:
1517
env:
16-
- {ROS_DISTRO: foxy, ROS_REPO: testing}
1718
- {ROS_DISTRO: foxy, ROS_REPO: main}
18-
runs-on: ubuntu-latest
19+
- {ROS_DISTRO: foxy, ROS_REPO: testing}
20+
env:
21+
UPSTREAM_WORKSPACE: ros2_control_demos/ros2_control_demos.repos
1922
steps:
23+
- run: sudo apt-get update -qq && sudo apt-get upgrade
2024
- uses: actions/checkout@v1
2125
- uses: 'ros-industrial/industrial_ci@master'
2226
env: ${{matrix.env}}
27+
28+
ci_source:
29+
name: Foxy source job
30+
runs-on: ubuntu-20.04
31+
strategy:
32+
fail-fast: false
33+
steps:
34+
- uses: ros-tooling/setup-ros@0.0.26
35+
with:
36+
required-ros-distributions: foxy
37+
- uses: ros-tooling/action-ros-ci@0.1.0
38+
with:
39+
target-ros2-distro: foxy
40+
# build all packages listed in the meta package
41+
package-name:
42+
ros2_control_demo_hardware
43+
ros2_control_demo_robot
44+
ros2_control_demos
45+
vcs-repo-file-url: |
46+
https://raw.githubusercontent.com/${{ github.repository }}/${{ github.sha }}/ros2_control_demos/ros2_control_demos.repos
47+
colcon-mixin-name: coverage-gcc
48+
colcon-mixin-repository: https://raw.githubusercontent.com/colcon/colcon-mixin-repository/master/index.yaml
49+
- uses: codecov/codecov-action@v1.0.14
50+
with:
51+
file: ros_ws/lcov/total_coverage.info
52+
flags: unittests
53+
name: codecov-umbrella
54+
- uses: actions/upload-artifact@v1
55+
with:
56+
name: colcon-logs-${{ matrix.os }}
57+
path: ros_ws/log

.github/workflows/code_coverage.yml

Lines changed: 0 additions & 34 deletions
This file was deleted.

.github/workflows/linters.yaml

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,35 @@
11
name: Linters
22
on:
33
pull_request:
4-
push:
5-
branches:
6-
- master
74

85
jobs:
96
ament_copyright:
107
name: ament_copyright
118
runs-on: ubuntu-18.04
129
steps:
1310
- uses: actions/checkout@v1
14-
- uses: ros-tooling/setup-ros@0.0.13
15-
- uses: ros-tooling/action-ros-lint@0.0.5
11+
- uses: ros-tooling/setup-ros@0.0.26
12+
- uses: ros-tooling/action-ros-lint@0.0.6
1613
with:
1714
linter: copyright
18-
package-name: ros2_control_demo_communication_gazebo ros2_control_demo_communication_headless ros2_control_demo_hardware ros2_control_demo_robot
15+
package-name:
16+
ros2_control_demo_hardware
17+
ros2_control_demo_robot
18+
ros2_control_demos
1919

2020
ament_xmllint:
2121
name: ament_xmllint
2222
runs-on: ubuntu-18.04
2323
steps:
2424
- uses: actions/checkout@v1
25-
- uses: ros-tooling/setup-ros@0.0.13
26-
- uses: ros-tooling/action-ros-lint@0.0.5
25+
- uses: ros-tooling/setup-ros@0.0.26
26+
- uses: ros-tooling/action-ros-lint@0.0.6
2727
with:
2828
linter: xmllint
29-
package-name: ros2_control_demo_communication_gazebo ros2_control_demo_communication_headless ros2_control_demo_hardware ros2_control_demo_robot
29+
package-name:
30+
ros2_control_demo_hardware
31+
ros2_control_demo_robot
32+
ros2_control_demos
3033

3134
ament_lint_cpp:
3235
name: ament_${{ matrix.linter }}
@@ -37,8 +40,11 @@ jobs:
3740
linter: [cppcheck, cpplint, uncrustify]
3841
steps:
3942
- uses: actions/checkout@v1
40-
- uses: ros-tooling/setup-ros@0.0.13
41-
- uses: ros-tooling/action-ros-lint@0.0.5
43+
- uses: ros-tooling/setup-ros@0.0.26
44+
- uses: ros-tooling/action-ros-lint@0.0.6
4245
with:
4346
linter: ${{ matrix.linter }}
44-
package-name: ros2_control_demo_communication_gazebo ros2_control_demo_communication_headless ros2_control_demo_hardware ros2_control_demo_robot
47+
package-name:
48+
ros2_control_demo_hardware
49+
ros2_control_demo_robot
50+
ros2_control_demos

README.md

Lines changed: 123 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,127 @@ This repository provides templates for the development of `ros2_control`-enabled
1111

1212
## Goals
1313

14-
The repository has two goals:
14+
The repository has three goals:
15+
1. Implements the example configuration described in the `ros-controls/roadmap` repository file [components_architecture_and_urdf_examples](https://github.com/ros-controls/roadmap/blob/master/design_drafts/components_architecture_and_urdf_examples.md).
16+
2. It provides templates for faster start of implementing own hardware and controllers;
17+
3. The repository is a validation environment for `ros2_control` concepts, which can only be tested during run-time (e.g., execution of controllers by the controller manager, communication between robot hardware and controllers).
1518

16-
1. It provides templates for faster start of implementing own hardware and controllers;
17-
2. The repository is a validation environment for `ros2_control` concepts, which can only be tested during run-time (e.g., execution of controllers by the controller manager, communication between robot hardware and controllers).
19+
20+
## Description
21+
22+
The repository is inspired by [ros_control_boilerplate](https://github.com/PickNikRobotics/ros_control_boilerplate) repository from Dave Coleman.
23+
The simulation has three parts/packages:
24+
1. The first package, `ros2_control_demo_hardware`, implements the hardware interfaces described in the roadmap.
25+
This implemented examples simulate *RRbot* internally to provide sufficient test and demonstration data, but to reduce amount of package dependencies.
26+
This package does not have any dependencies except on the `ros2` core packages and can, therefore, be used on SoC-hardware of headless systems.
27+
2. The second package, `ros2_control_demo_hardware_gazebo`, uses a gazebo simulator to simulate the *RRBot* and its physics.
28+
This package is useful to test the connection of `ros2_control` to the gazebo simulator and to detect any missing plugins.
29+
3. The third package `ros2_control_demo_robot` holds examples for *RRbot* URDF-description, launch files and controllers.
30+
The intention of those files is to simplify start with `ros2_control` and to enable faster integration of new robots and controllers.
31+
32+
This repository demonstrates the following `ros2_control` concepts:
33+
34+
* Creating of `*HardwareInterface` for a System, Sensor, and Actuator.
35+
* Creating a robot description in the form of URDF files
36+
* Loading configuration and starting robot using launch files
37+
* Control of two joints of *RRBot*
38+
* Using simulated robots and starting `ros_control` with gazebo simulator
39+
* Implementing of controller switching strategy for a robot
40+
* Using joint limits and transmission concepts in `ros2_control`
41+
* TBD...
42+
43+
# Test of the Scenario Before the First Release
44+
* Checkout [ros-controls/ros2_control](https://github.com/ros-controls/ros2_control) to get the core.
45+
* Checkout [ros-controls/ros2_controllers](https://github.com/ros-controls/ros2_controllers) to get all the controllers.
46+
* Checkout [ros-controls/ros2_control_demos](https://github.com/ros-controls/ros2_control_demos) to get example hardware and robot launch files.
47+
48+
* Install dependencies (maybe you need `sudo`):
49+
```
50+
apt install ros-foxy-realtime-tools ros-foxy-xacro ros-foxy-angles
51+
```
52+
53+
* Build everything, e.g. with:
54+
```
55+
colcon build --symlink-install
56+
```
57+
58+
* Do not forget to source `setup.bash` from the `install` folder!
59+
60+
61+
# Getting Started with ROS2 Control
62+
63+
Each of the described example cases from the roadmap has its own launch and URDF file.
64+
65+
## Example 1: "Industrial Robots with only one interface"
66+
67+
1. Start the roslaunch file:
68+
```
69+
ros2 launch ros2_control_demo_robot rrbot_system_position_only.launch.py
70+
```
71+
72+
2. Open another terminal and check if `RRBotSystemPositionOnlyHardware` is loaded properly:
73+
```
74+
ros2 control list_hardware_interfaces
75+
```
76+
You should get something like:
77+
```
78+
command interfaces
79+
joint1/position [unclaimed]
80+
joint2/position [unclaimed]
81+
state interfaces
82+
joint1/position
83+
joint2/position
84+
```
85+
86+
3. Open another terminal and load controllers:
87+
```
88+
ros2 control load joint_state_controller
89+
ros2 control load forward_command_controller_position
90+
```
91+
92+
Check if controller is loaded properly:
93+
```
94+
ros2 control list
95+
```
96+
You should get the response:
97+
```
98+
joint_state_controller[joint_state_controller/JointStateController] inactive
99+
forward_command_controller_position[forward_command_controller/ForwardCommandController] inactive
100+
```
101+
102+
4. Starting controller:
103+
```
104+
ros2 control switch --start-controllers joint_state_controller forward_command_controller_position
105+
```
106+
107+
Check if controllers are activated:
108+
```
109+
ros2 control list
110+
```
111+
You should get `active` in the response:
112+
```
113+
joint_state_controller[joint_state_controller/JointStateController] active
114+
forward_command_controller_position[forward_command_controller/ForwardCommandController] active
115+
```
116+
117+
5. Open another terminal and send a message to the controller:
118+
```
119+
ros2 topic pub /forward_command_controller_position/commands std_msgs/msg/Float64MultiArray "data:
120+
- 0.5
121+
- 0.5"
122+
```
123+
124+
You should see how the example output changes. Look for the following lines
125+
```
126+
[RRBotSystemPositionOnlyHardware]: Got state 0.0 for joint 0!
127+
[RRBotSystemPositionOnlyHardware]: Got state 0.0 for joint 1!
128+
```
129+
130+
If you echo the `/joint_states` or `/dynamic_joint_states` topics you should also get similar values.
131+
```
132+
ros2 topic echo /joint_states
133+
ros2 topic echo /dynamic_joint_states
134+
```
135+
136+
The other launch-files have corresponding names to their coresponding example.
137+
The URDF files can be found in the `description` folder.

ros2_control_demo_hardware/CMakeLists.txt

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,35 @@ endif()
1212

1313
# find dependencies
1414
find_package(ament_cmake REQUIRED)
15+
find_package(hardware_interface REQUIRED)
16+
find_package(pluginlib REQUIRED)
17+
find_package(rclcpp REQUIRED)
1518

19+
## COMPILE
20+
add_library(
21+
${PROJECT_NAME}
22+
SHARED
23+
src/rrbot_system_position_only.cpp
24+
)
25+
target_include_directories(
26+
${PROJECT_NAME}
27+
PRIVATE
28+
include
29+
)
30+
ament_target_dependencies(
31+
${PROJECT_NAME}
32+
hardware_interface
33+
pluginlib
34+
rclcpp
35+
)
36+
37+
pluginlib_export_plugin_description_file(hardware_interface ros2_control_demo_hardware.xml)
38+
39+
# INSTALL
40+
install(
41+
TARGETS ${PROJECT_NAME}
42+
DESTINATION lib
43+
)
1644
install(
1745
DIRECTORY include/
1846
DESTINATION include
@@ -22,10 +50,16 @@ if(BUILD_TESTING)
2250
find_package(ament_cmake_gtest REQUIRED)
2351
endif()
2452

53+
## EXPORTS
2554
ament_export_include_directories(
2655
include
2756
)
2857
ament_export_libraries(
2958
${PROJECT_NAME}
3059
)
60+
ament_export_dependencies(
61+
hardware_interface
62+
pluginlib
63+
rclcpp
64+
)
3165
ament_package()

0 commit comments

Comments
 (0)