2020
2121from launch_ros .actions import Node
2222from launch_ros .substitutions import FindPackageShare
23+ from launch_ros .parameter_descriptions import ParameterFile
2324
2425
2526def generate_launch_description ():
@@ -30,14 +31,19 @@ def generate_launch_description():
3031 default_value = "true" ,
3132 description = "Start RViz2 automatically with this launch file." ,
3233 ),
34+ DeclareLaunchArgument (
35+ "joint_prefix" ,
36+ default_value = "joint" ,
37+ description = "Prefix for joint names (used with allow_substs in spawner)." ,
38+ ),
3339 # Control node
3440 Node (
3541 package = "controller_manager" ,
3642 executable = "ros2_control_node" ,
3743 parameters = [
3844 PathSubstitution (FindPackageShare ("ros2_control_demo_example_1" ))
3945 / "config"
40- / "rrbot_controllers .yaml"
46+ / "controller_manager .yaml"
4147 ],
4248 output = "both" ,
4349 ),
@@ -75,17 +81,28 @@ def generate_launch_description():
7581 Node (
7682 package = "controller_manager" ,
7783 executable = "spawner" ,
78- arguments = ["joint_state_broadcaster" ],
84+ arguments = [
85+ "joint_state_broadcaster" ,
86+ "--param-file" ,
87+ PathSubstitution (FindPackageShare ("ros2_control_demo_example_1" ))
88+ / "config"
89+ / "rrbot_controllers.yaml" ,
90+ ],
7991 ),
8092 Node (
8193 package = "controller_manager" ,
8294 executable = "spawner" ,
95+ parameters = [
96+ {"joint_prefix" : LaunchConfiguration ("joint_prefix" )},
97+ ParameterFile (
98+ PathSubstitution (FindPackageShare ("ros2_control_demo_example_1" ))
99+ / "config"
100+ / "rrbot_controllers.yaml" ,
101+ allow_substs = True ,
102+ ),
103+ ],
83104 arguments = [
84105 "forward_position_controller" ,
85- "--param-file" ,
86- PathSubstitution (FindPackageShare ("ros2_control_demo_example_1" ))
87- / "config"
88- / "rrbot_controllers.yaml" ,
89106 ],
90107 ),
91108 ]
0 commit comments