44
55from ament_index_python .packages import get_package_share_directory
66from launch import LaunchDescription
7- from launch .actions import DeclareLaunchArgument , ExecuteProcess
7+ from launch .actions import DeclareLaunchArgument , IncludeLaunchDescription
88from launch .conditions import IfCondition
9+ from launch .launch_description_sources import PythonLaunchDescriptionSource
910from launch .substitutions import LaunchConfiguration
1011from ament_index_python .packages import get_package_prefix
1112
1516 choices = ['true' , 'false' ],
1617 description = 'Whether or not to launch gzclient' ),
1718 DeclareLaunchArgument ('world_path' ,
18- default_value = [os .path .join (get_package_share_directory ('drl_agent_bringup' ), 'worlds' , 'TD3 .world' )],
19+ default_value = [os .path .join (get_package_share_directory ('drl_agent_bringup' ), 'worlds' , 'td7 .world' )],
1920 description = 'SDF world file' ),
2021]
2122
2223
2324def generate_launch_description ():
2425
25- # Get packages description and directory
26+ """*************************************************************************************
27+ ** Get package share directories
28+ *************************************************************************************"""
2629 drl_agent_bringup_package_name = 'drl_agent_bringup'
2730 drl_agent_description_package_name = 'drl_agent_description'
2831 velodyne_description_package_name = 'velodyne_description'
2932 drl_agent_bringup_package_directory = get_package_share_directory (drl_agent_bringup_package_name )
3033 drl_agent_description_package_directory = get_package_share_directory (drl_agent_description_package_name )
3134 velodyne_description_package_directory = get_package_share_directory (velodyne_description_package_name )
35+ gazebo_ros_package_directory = get_package_share_directory ('gazebo_ros' )
3236
33- # Set the Path to mesh models. NOTE: should be done before gazebo is 1st launched.
37+ """*************************************************************************************
38+ ** Set the Path to mesh models. NOTE: should be done before gazebo is 1st launched.
39+ *************************************************************************************"""
40+ drl_agent_bringup_install_dir_path = (get_package_prefix (drl_agent_bringup_package_name ) + '/share' )
3441 drl_agent_install_dir_path = (get_package_prefix (drl_agent_description_package_name ) + '/share' )
3542 velodyne_description_install_dir_path = (get_package_prefix (velodyne_description_package_name ) + '/share' )
3643
@@ -39,7 +46,7 @@ def generate_launch_description():
3946 drl_agent_description_models_path = os .path .join (drl_agent_description_package_directory , 'models' )
4047 drl_agent_bringup_models_path = os .path .join (drl_agent_bringup_package_directory , 'models' )
4148
42- gazebo_resource_paths = [drl_agent_install_dir_path , robot_meshes_path , drl_agent_description_models_path ,\
49+ gazebo_resource_paths = [drl_agent_bringup_install_dir_path , drl_agent_install_dir_path , robot_meshes_path , drl_agent_description_models_path ,\
4350 drl_agent_bringup_models_path , velodyne_description_install_dir_path , velodyne_description_meshes_path ]
4451 if 'GAZEBO_MODEL_PATH' in os .environ :
4552 for resource_path in gazebo_resource_paths :
@@ -57,31 +64,30 @@ def generate_launch_description():
5764 # print(str(os.environ['GAZEBO_PLUGIN_PATH']))
5865 print (border )
5966
60- # Launch configurations
67+ """*************************************************************************************
68+ Launch configurations and gazebo launch
69+ *************************************************************************************"""
6170 world_path = LaunchConfiguration ('world_path' )
6271 use_gazebo_gui = LaunchConfiguration ('use_gazebo_gui' )
6372
64- # Gazebo server
65- gazebo_params_yaml_file = os .path .join (
66- drl_agent_bringup_package_directory , 'config' , 'gazebo_params.yaml' )
67- gzserver = ExecuteProcess (
68- cmd = ['gzserver' ,
69- '-s' , 'libgazebo_ros_init.so' ,
70- '-s' , 'libgazebo_ros_factory.so' ,
71- world_path ,
72- 'extra-gazebo-args' , '--ros-args' , '--params-file' , gazebo_params_yaml_file ],
73- output = 'screen' ,
73+ gzserver_cmd = IncludeLaunchDescription (
74+ PythonLaunchDescriptionSource (
75+ os .path .join (gazebo_ros_package_directory , 'launch' , 'gzserver.launch.py' )
76+ ),
77+ launch_arguments = [
78+ ('world' , world_path ),
79+ ]
7480 )
7581
76- # Gazebo client
77- gzclient = ExecuteProcess (
78- cmd = [ 'gzclient' ],
79- output = 'screen' ,
80- condition = IfCondition (use_gazebo_gui ),
82+ gzclient_cmd = IncludeLaunchDescription (
83+ PythonLaunchDescriptionSource (
84+ os . path . join ( gazebo_ros_package_directory , 'launch' , 'gzclient.launch.py' )
85+ ) ,
86+ condition = IfCondition (use_gazebo_gui )
8187 )
8288
8389 ld = LaunchDescription (ARGUMENTS )
84- ld .add_action (gzserver )
85- ld .add_action (gzclient )
90+ ld .add_action (gzserver_cmd )
91+ ld .add_action (gzclient_cmd )
8692
8793 return ld
0 commit comments