1- #!/usr/bin/env python3
1+ """
2+ Pick Place Harmonic - Robot Launcher
3+ Wraps spawn_robot_warehouse.launch.py
4+ """
25
36import os
4- import xacro
5-
67from launch import LaunchDescription
7- from launch_ros .actions import Node
8+ from launch .actions import IncludeLaunchDescription
9+ from launch .launch_description_sources import PythonLaunchDescriptionSource
810from ament_index_python .packages import get_package_share_directory
911
1012
1113def generate_launch_description ():
1214
13- pkg = get_package_share_directory ("ros2srrc_ur5_gazebo" )
14-
15- xacro_file = os .path .join (pkg , "urdf" , "ur5_robotiq_2f85.urdf.xacro" )
16-
17- doc = xacro .parse (open (xacro_file ))
18- xacro .process_doc (doc , mappings = {
19- "EE" : "true" ,
20- "EE_name" : "robotiq_2f85"
21- })
15+ try :
16+ ur5_gripper_pkg = get_package_share_directory ("ur5_gripper_description" )
17+ except Exception as e :
18+ print (f"ERROR: Cannot find ur5_gripper_description package: { e } " )
19+ print ("Make sure packages are built in /home/ws" )
20+ raise
2221
23- robot_description = {
24- "robot_description" : doc .toxml ()
25- }
26-
27- robot_state_publisher = Node (
28- package = "robot_state_publisher" ,
29- executable = "robot_state_publisher" ,
30- output = "screen" ,
31- parameters = [robot_description , {"use_sim_time" : True }],
22+ warehouse_launch_file = os .path .join (
23+ ur5_gripper_pkg , "launch" , "spawn_robot_warehouse.launch.py"
3224 )
3325
34- spawn_entity = Node (
35- package = "gazebo_ros" ,
36- executable = "spawn_entity.py" ,
37- arguments = ["-topic" , "robot_description" , "-entity" , "ur5" ],
38- output = "screen" ,
39- )
40-
41- joint_state_broadcaster = Node (
42- package = "controller_manager" ,
43- executable = "spawner" ,
44- arguments = ["joint_state_broadcaster" , "-c" , "/controller_manager" ],
45- )
46-
47- joint_trajectory_controller = Node (
48- package = "controller_manager" ,
49- executable = "spawner" ,
50- arguments = ["joint_trajectory_controller" , "-c" , "/controller_manager" ],
51- )
26+ print (f"Including launch file: { warehouse_launch_file } " )
5227
53- gripper_controller = Node (
54- package = "controller_manager" ,
55- executable = "spawner" ,
56- arguments = ["gripper_controller" , "-c" , "/controller_manager" ],
28+ warehouse_launch = IncludeLaunchDescription (
29+ PythonLaunchDescriptionSource (warehouse_launch_file ),
30+ launch_arguments = {
31+ "launch_rviz" : "false" ,
32+ }.items (),
5733 )
5834
59- return LaunchDescription ([
60- robot_state_publisher ,
61- spawn_entity ,
62- joint_state_broadcaster ,
63- joint_trajectory_controller ,
64- gripper_controller ,
65- ])
35+ return LaunchDescription ([warehouse_launch ])
0 commit comments