Skip to content

Commit a97760f

Browse files
christophfroehlichdestoglsaikishor
authored
[Example 15] Using multiple controller managers under different namespaces (ros-controls#423)
* Add example15 to workflows+packages * Initial commit from old PR Co-authored-by: Denis Štogl <[email protected]> * Convert md to rst syntax * Apply suggestions from code review Co-authored-by: Sai Kishor Kothakota <[email protected]> --------- Co-authored-by: Denis Štogl <[email protected]> Co-authored-by: Sai Kishor Kothakota <[email protected]>
1 parent 6a847e6 commit a97760f

27 files changed

+1838
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ The following examples are part of this demo repository:
7070

7171
* Example 14: ["Modular robots with actuators not providing states and with additional sensors"](example_14)
7272

73+
The example shows how to implement robot hardware with actuators not providing states and with additional sensors.
74+
75+
* Example 15: ["Using multiple controller managers"](example_15)
76+
77+
This example shows how to integrate multiple robots under different controller manager instances.
78+
7379
## Structure
7480

7581
The repository is structured into `example_XY` folders that fully contained packages with names `ros2_control_demos_example_XY`.

doc/index.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,10 @@ Example 12: "Controller chaining"
7979
Example 13: "Multi-robot example (tba.)"
8080

8181
Example 14: "Modular robots with actuators not providing states and with additional sensors"
82+
The example shows how to implement robot hardware with actuators not providing states and with additional sensors.
83+
84+
Example 15: "Using multiple controller managers"
85+
This example shows how to integrate multiple robots under different controller manager instances.
8286

8387

8488
.. _ros2_control_demos_install:
@@ -273,3 +277,4 @@ Examples
273277
Example 11: CarlikeBot <../example_11/doc/userdoc.rst>
274278
Example 12: Controller chaining <../example_12/doc/userdoc.rst>
275279
Example 14: Modular robots with actuators not providing states <../example_14/doc/userdoc.rst>
280+
Example 15: Using multiple controller managers <../example_15/doc/userdoc.rst>

example_15/CMakeLists.txt

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
cmake_minimum_required(VERSION 3.16)
2+
project(ros2_control_demo_example_15 LANGUAGES CXX)
3+
4+
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
5+
add_compile_options(-Wall -Wextra)
6+
endif()
7+
8+
# find dependencies
9+
set(THIS_PACKAGE_INCLUDE_DEPENDS
10+
)
11+
12+
# find dependencies
13+
find_package(ament_cmake REQUIRED)
14+
foreach(Dependency IN ITEMS ${THIS_PACKAGE_INCLUDE_DEPENDS})
15+
find_package(${Dependency} REQUIRED)
16+
endforeach()
17+
18+
# INSTALL
19+
install(
20+
DIRECTORY description/rviz
21+
DESTINATION share/ros2_control_demo_example_15
22+
)
23+
install(
24+
DIRECTORY bringup/launch bringup/config
25+
DESTINATION share/ros2_control_demo_example_15
26+
)
27+
28+
if(BUILD_TESTING)
29+
find_package(ament_cmake_gtest REQUIRED)
30+
find_package(ament_cmake_pytest REQUIRED)
31+
32+
ament_add_pytest_test(test_rrbot_namespace_launch test/test_rrbot_namespace_launch.py)
33+
ament_add_pytest_test(test_multi_controller_manager_launch test/test_multi_controller_manager_launch.py)
34+
35+
endif()
36+
37+
## EXPORTS
38+
ament_export_dependencies(${THIS_PACKAGE_INCLUDE_DEPENDS})
39+
ament_package()

example_15/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# ros2_control_demo_example_15
2+
3+
This example shows how to integrate multiple robots under different controller manager instances.
4+
5+
Find the documentation in [doc/userdoc.rst](doc/userdoc.rst) or on [control.ros.org](https://control.ros.org/master/doc/ros2_control_demos/example_15/doc/userdoc.html).
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/rrbot_1/publisher_forward_position_controller:
2+
ros__parameters:
3+
4+
5+
publish_topic: "forward_position_controller/commands"
6+
wait_sec_between_publish: 5
7+
8+
goal_names: ["pos1", "pos2", "pos3", "pos4"]
9+
pos1: [0.785, 0.785]
10+
pos2: [0.0, 0.0]
11+
pos3: [-0.785, -0.785]
12+
pos4: [0.0, 0.0]
13+
14+
15+
/rrbot_2/publisher_forward_position_controller:
16+
ros__parameters:
17+
18+
publish_topic: "forward_position_controller/commands"
19+
wait_sec_between_publish: 5
20+
21+
goal_names: ["pos1", "pos2", "pos3", "pos4"]
22+
pos1: [-0.785, 0.0]
23+
pos2: [0.0, -0.785]
24+
pos3: [+0.785, -1.57]
25+
pos4: [+1.57, -0.785]
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/rrbot_1/publisher_joint_trajectory_controller:
2+
ros__parameters:
3+
4+
controller_name: "rrbot_1/position_trajectory_controller"
5+
wait_sec_between_publish: 6
6+
7+
goal_names: ["pos1", "pos2", "pos3", "pos4"]
8+
pos1:
9+
positions: [0.785, 0.785]
10+
pos2:
11+
positions: [0.0, 0.0]
12+
pos3:
13+
positions: [-0.785, -0.785]
14+
pos4:
15+
positions: [0.0, 0.0]
16+
17+
joints:
18+
- rrbot_1_joint1
19+
- rrbot_1_joint2
20+
21+
check_starting_point: false
22+
starting_point_limits:
23+
joint1: [-0.1,0.1]
24+
joint2: [-0.1,0.1]
25+
26+
27+
/rrbot_2/publisher_joint_trajectory_controller:
28+
ros__parameters:
29+
30+
controller_name: "rrbot_2/position_trajectory_controller"
31+
wait_sec_between_publish: 6
32+
33+
goal_names: ["pos1", "pos2", "pos3", "pos4"]
34+
pos1:
35+
positions: [-0.785, 0.0]
36+
pos2:
37+
positions: [0.0, -0.785]
38+
pos3:
39+
positions: [+0.785, -1.57]
40+
pos4:
41+
positions: [+1.57, -0.785]
42+
43+
joints:
44+
- rrbot_2_joint1
45+
- rrbot_2_joint2
46+
47+
check_starting_point: false
48+
starting_point_limits:
49+
joint1: [-0.1,0.1]
50+
joint2: [-0.1,0.1]
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/rrbot_1/controller_manager:
2+
ros__parameters:
3+
update_rate: 10 # Hz
4+
5+
joint_state_broadcaster:
6+
type: joint_state_broadcaster/JointStateBroadcaster
7+
8+
forward_position_controller:
9+
type: forward_command_controller/ForwardCommandController
10+
11+
position_trajectory_controller:
12+
type: joint_trajectory_controller/JointTrajectoryController
13+
14+
15+
/rrbot_1/forward_position_controller:
16+
ros__parameters:
17+
joints:
18+
- rrbot_1_joint1
19+
- rrbot_1_joint2
20+
interface_name: position
21+
22+
23+
/rrbot_1/position_trajectory_controller:
24+
ros__parameters:
25+
joints:
26+
- rrbot_1_joint1
27+
- rrbot_1_joint2
28+
29+
command_interfaces:
30+
- position
31+
32+
state_interfaces:
33+
- position
34+
35+
state_publish_rate: 200.0 # Defaults to 50
36+
action_monitor_rate: 20.0 # Defaults to 20
37+
38+
allow_partial_joints_goal: false # Defaults to false
39+
open_loop_control: true
40+
allow_integration_in_goal_trajectories: true
41+
constraints:
42+
stopped_velocity_tolerance: 0.01 # Defaults to 0.01
43+
goal_time: 0.0 # Defaults to 0.0 (start immediately)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/rrbot_2/controller_manager:
2+
ros__parameters:
3+
update_rate: 10 # Hz
4+
5+
joint_state_broadcaster:
6+
type: joint_state_broadcaster/JointStateBroadcaster
7+
8+
forward_position_controller:
9+
type: forward_command_controller/ForwardCommandController
10+
11+
position_trajectory_controller:
12+
type: joint_trajectory_controller/JointTrajectoryController
13+
14+
15+
/rrbot_2/forward_position_controller:
16+
ros__parameters:
17+
joints:
18+
- rrbot_2_joint1
19+
- rrbot_2_joint2
20+
interface_name: position
21+
22+
23+
/rrbot_2/position_trajectory_controller:
24+
ros__parameters:
25+
joints:
26+
- rrbot_2_joint1
27+
- rrbot_2_joint2
28+
29+
command_interfaces:
30+
- position
31+
32+
state_interfaces:
33+
- position
34+
35+
state_publish_rate: 200.0 # Defaults to 50
36+
action_monitor_rate: 20.0 # Defaults to 20
37+
38+
allow_partial_joints_goal: false # Defaults to false
39+
open_loop_control: true
40+
allow_integration_in_goal_trajectories: true
41+
constraints:
42+
stopped_velocity_tolerance: 0.01 # Defaults to 0.01
43+
goal_time: 0.0 # Defaults to 0.0 (start immediately)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/rrbot/controller_manager:
2+
ros__parameters:
3+
update_rate: 10 # Hz
4+
5+
joint_state_broadcaster:
6+
type: joint_state_broadcaster/JointStateBroadcaster
7+
8+
forward_position_controller:
9+
type: forward_command_controller/ForwardCommandController
10+
11+
position_trajectory_controller:
12+
type: joint_trajectory_controller/JointTrajectoryController
13+
14+
15+
/rrbot/forward_position_controller:
16+
ros__parameters:
17+
joints:
18+
- joint1
19+
- joint2
20+
interface_name: position
21+
22+
23+
/rrbot/position_trajectory_controller:
24+
ros__parameters:
25+
joints:
26+
- joint1
27+
- joint2
28+
29+
command_interfaces:
30+
- position
31+
32+
state_interfaces:
33+
- position
34+
35+
state_publish_rate: 200.0 # Defaults to 50
36+
action_monitor_rate: 20.0 # Defaults to 20
37+
38+
allow_partial_joints_goal: false # Defaults to false
39+
open_loop_control: true
40+
allow_integration_in_goal_trajectories: true
41+
constraints:
42+
stopped_velocity_tolerance: 0.01 # Defaults to 0.01
43+
goal_time: 0.0 # Defaults to 0.0 (start immediately)
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
publisher_forward_position_controller:
2+
ros__parameters:
3+
4+
wait_sec_between_publish: 5
5+
6+
publish_topic: /rrbot/forward_position_controller/commands
7+
8+
goal_names: ["pos1", "pos2", "pos3", "pos4"]
9+
pos1: [0.785, 0.785]
10+
pos2: [0, 0]
11+
pos3: [-0.785, -0.785]
12+
pos4: [0, 0]

0 commit comments

Comments
 (0)