Skip to content

Commit 2a36f66

Browse files
committed
my_robot_cell_description: Add ur_type option to view_robot.launch.py
1 parent e28d963 commit 2a36f66

File tree

1 file changed

+29
-3
lines changed

1 file changed

+29
-3
lines changed

my_robot_cell/my_robot_cell_description/launch/view_robot.launch.py

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
11
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
34

45
from launch_ros.actions import Node
56
from launch_ros.parameter_descriptions import ParameterValue
67
from launch_ros.substitutions import FindPackageShare
78

89

910
def 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

Comments
 (0)