22
22
23
23
from launch_ros .actions import Node
24
24
from launch_ros .substitutions import FindPackageShare
25
+ from controller_manager .launch_utils import generate_controllers_spawner_launch_description
25
26
26
27
27
28
def generate_launch_description ():
@@ -87,7 +88,10 @@ def generate_launch_description():
87
88
control_node = Node (
88
89
package = "controller_manager" ,
89
90
executable = "ros2_control_node" ,
90
- parameters = [robot_description , robot_controllers ],
91
+ parameters = [robot_controllers ],
92
+ remappings = [
93
+ ("~/robot_description" , "/robot_description" ),
94
+ ],
91
95
)
92
96
robot_state_pub_node = Node (
93
97
package = "robot_state_publisher" ,
@@ -104,73 +108,44 @@ def generate_launch_description():
104
108
condition = IfCondition (gui ),
105
109
)
106
110
107
- # Separate robot state publishers for each robot
108
-
109
- # Global joint state broadcaster
110
- joint_state_broadcaster_spawner = Node (
111
- package = "controller_manager" ,
112
- executable = "spawner" ,
113
- arguments = ["joint_state_broadcaster" ],
111
+ # global broadcaster and initially active controllers from RRBot
112
+ general_ctrl_spawner = generate_controllers_spawner_launch_description (
113
+ [
114
+ # Global joint state broadcaster
115
+ "joint_state_broadcaster" ,
116
+ # RRBot controllers
117
+ "rrbot_joint_state_broadcaster" ,
118
+ "rrbot_position_controller" ,
119
+ # External FTS broadcaster
120
+ "rrbot_external_fts_broadcaster" ,
121
+ ],
122
+ controller_params_files = [robot_controllers ],
114
123
)
115
124
116
- # RRBot controllers
117
- rrbot_joint_state_broadcaster_spawner = Node (
118
- package = "controller_manager" ,
119
- executable = "spawner" ,
120
- arguments = ["rrbot_joint_state_broadcaster" ],
121
- )
122
- rrbot_position_controller_spawner = Node (
123
- package = "controller_manager" ,
124
- executable = "spawner" ,
125
- arguments = ["rrbot_position_controller" ],
126
- )
127
- # External FTS broadcaster
128
- rrbot_external_fts_broadcaster_spawner = Node (
129
- package = "controller_manager" ,
130
- executable = "spawner" ,
131
- arguments = ["rrbot_external_fts_broadcaster" ],
125
+ # RRBot with sensors controllers, initially active
126
+ rrbot_sensor_ctrl_spawner_active = generate_controllers_spawner_launch_description (
127
+ ["rrbot_with_sensor_joint_state_broadcaster" , "rrbot_with_sensor_fts_broadcaster" ],
128
+ controller_params_files = [robot_controllers ],
132
129
)
133
130
134
- # RRBot controllers
135
- rrbot_with_sensor_joint_state_broadcaster_spawner = Node (
136
- package = "controller_manager" ,
137
- executable = "spawner" ,
138
- arguments = ["rrbot_with_sensor_joint_state_broadcaster" ],
139
- )
140
- rrbot_with_sensor_position_controller_spawner = Node (
141
- package = "controller_manager" ,
142
- executable = "spawner" ,
143
- arguments = [
131
+ # RRBot with sensors controllers, initially inactive
132
+ rrbot_sensor_ctrl_spawner_inactive = generate_controllers_spawner_launch_description (
133
+ [
144
134
"rrbot_with_sensor_position_controller" ,
145
- "--inactive" ,
146
135
],
147
- )
148
- rrbot_with_sensor_fts_broadcaster_spawner = Node (
149
- package = "controller_manager" ,
150
- executable = "spawner" ,
151
- arguments = ["rrbot_with_sensor_fts_broadcaster" ],
136
+ controller_params_files = [robot_controllers ],
137
+ extra_spawner_args = ["--inactive" ],
152
138
)
153
139
154
- # ThreeDofBot controllers
155
- threedofbot_joint_state_broadcaster_spawner = Node (
156
- package = "controller_manager" ,
157
- executable = "spawner" ,
158
- arguments = [
140
+ # ThreeDofBot controllers, initially inactive
141
+ threedofbot_ctrl_spawner = generate_controllers_spawner_launch_description (
142
+ [
159
143
"threedofbot_joint_state_broadcaster" ,
160
- "-c" ,
161
- "/controller_manager" ,
162
- "--inactive" ,
144
+ "threedofbot_position_controller" ,
145
+ "threedofbot_pid_gain_controller" ,
163
146
],
164
- )
165
- threedofbot_position_controller_spawner = Node (
166
- package = "controller_manager" ,
167
- executable = "spawner" ,
168
- arguments = ["threedofbot_position_controller" , "--inactive" ],
169
- )
170
- threedofbot_pid_gain_controller_spawner = Node (
171
- package = "controller_manager" ,
172
- executable = "spawner" ,
173
- arguments = ["threedofbot_pid_gain_controller" , "--inactive" ],
147
+ controller_params_files = [robot_controllers ],
148
+ extra_spawner_args = ["--inactive" ],
174
149
)
175
150
176
151
# Command publishers
@@ -197,16 +172,10 @@ def generate_launch_description():
197
172
control_node ,
198
173
robot_state_pub_node ,
199
174
rviz_node ,
200
- joint_state_broadcaster_spawner ,
201
- rrbot_joint_state_broadcaster_spawner ,
202
- rrbot_position_controller_spawner ,
203
- rrbot_external_fts_broadcaster_spawner ,
204
- rrbot_with_sensor_joint_state_broadcaster_spawner ,
205
- rrbot_with_sensor_position_controller_spawner ,
206
- rrbot_with_sensor_fts_broadcaster_spawner ,
207
- threedofbot_joint_state_broadcaster_spawner ,
208
- threedofbot_position_controller_spawner ,
209
- threedofbot_pid_gain_controller_spawner ,
175
+ general_ctrl_spawner ,
176
+ rrbot_sensor_ctrl_spawner_active ,
177
+ rrbot_sensor_ctrl_spawner_inactive ,
178
+ threedofbot_ctrl_spawner ,
210
179
rrbot_position_command_publisher ,
211
180
rrbot_with_sensor_position_command_publisher ,
212
181
threedofbot_position_command_publisher ,
0 commit comments