1
1
from launch import LaunchDescription
2
- from launch .substitutions import Command , PathJoinSubstitution
2
+ from launch .actions import DeclareLaunchArgument
3
+ from launch .substitutions import Command , PathJoinSubstitution , LaunchConfiguration
3
4
4
5
from launch_ros .actions import Node
5
6
from launch_ros .parameter_descriptions import ParameterValue
6
7
from launch_ros .substitutions import FindPackageShare
7
8
8
9
9
10
def generate_launch_description ():
11
+ ur_type = LaunchConfiguration ("ur_type" )
10
12
description_package = FindPackageShare ("my_robot_cell_description" )
11
13
description_file = PathJoinSubstitution (
12
14
[description_package , "urdf" , "my_robot_cell.urdf.xacro" ]
13
15
)
14
16
rvizconfig_file = PathJoinSubstitution ([description_package , "rviz" , "urdf.rviz" ])
15
17
16
18
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
18
20
)
19
21
20
22
robot_state_publisher_node = Node (
@@ -36,6 +38,30 @@ def generate_launch_description():
36
38
arguments = ["-d" , rvizconfig_file ],
37
39
)
38
40
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
+
39
60
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
+ ]
41
67
)
0 commit comments