11from launch import LaunchDescription
2- from launch .substitutions import Command , PathJoinSubstitution
2+ from launch .actions import DeclareLaunchArgument
3+ from launch .substitutions import Command , PathJoinSubstitution , LaunchConfiguration
34
45from launch_ros .actions import Node
56from launch_ros .parameter_descriptions import ParameterValue
67from launch_ros .substitutions import FindPackageShare
78
89
910def generate_launch_description ():
11+ ur_type = LaunchConfiguration ("ur_type" )
1012 description_package = FindPackageShare ("my_robot_cell_description" )
1113 description_file = PathJoinSubstitution (
1214 [description_package , "urdf" , "my_robot_cell.urdf.xacro" ]
1315 )
1416 rvizconfig_file = PathJoinSubstitution ([description_package , "rviz" , "urdf.rviz" ])
1517
1618 robot_description = ParameterValue (
17- Command (["xacro " , description_file , " " , "ur_type:=" , "ur20" ]), value_type = str
19+ Command (["xacro " , description_file , " " , "ur_type:=" , ur_type ]), value_type = str
1820 )
1921
2022 robot_state_publisher_node = Node (
@@ -36,6 +38,30 @@ def generate_launch_description():
3638 arguments = ["-d" , rvizconfig_file ],
3739 )
3840
41+ declared_arguments = [
42+ DeclareLaunchArgument (
43+ "ur_type" ,
44+ description = "Typo/series of used UR robot." ,
45+ choices = [
46+ "ur3" ,
47+ "ur3e" ,
48+ "ur5" ,
49+ "ur5e" ,
50+ "ur10" ,
51+ "ur10e" ,
52+ "ur16e" ,
53+ "ur20" ,
54+ "ur30" ,
55+ ],
56+ default_value = "ur20" ,
57+ )
58+ ]
59+
3960 return LaunchDescription (
40- [joint_state_publisher_gui_node , robot_state_publisher_node , rviz_node ]
61+ declared_arguments
62+ + [
63+ joint_state_publisher_gui_node ,
64+ robot_state_publisher_node ,
65+ rviz_node ,
66+ ]
4167 )
0 commit comments