import os from ament_index_python.packages import get_package_share_directory from launch import LaunchDescription from launch.actions import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription from launch.substitutions import LaunchConfiguration from launch_ros.actions import Node from launch.launch_description_sources import PythonLaunchDescriptionSource def generate_launch_description(): # main package path package_dir=get_package_share_directory('iml_buche') # using package path to find urdf file urdf = os.path.join(package_dir,'camera_lidar_gazebo.urdf') # using package path to find the Custom World file world_file=os.path.join(package_dir,'line_world.world') # Adding path to gazebo_ros package pkg_gazebo_ros = get_package_share_directory('gazebo_ros') # Important rviz file to make life easy rviz_config_file=os.path.join(package_dir,'launch_config.rviz') return LaunchDescription([ #launching gazebo server and our custom world in it IncludeLaunchDescription( PythonLaunchDescriptionSource(os.path.join(pkg_gazebo_ros, 'launch', 'gzserver.launch.py')), launch_arguments={'world': world_file}.items(), ), # Adding the gzclient launch file to run gazebo IncludeLaunchDescription( PythonLaunchDescriptionSource( os.path.join(pkg_gazebo_ros, 'launch', 'gzclient.launch.py') ), ), # publishes TF for links of the robot without joints Node( package='robot_state_publisher', executable='robot_state_publisher', name='robot_state_publisher', output='screen', arguments=[urdf]), # To publish tf for Joints only links Node( package='joint_state_publisher', executable='joint_state_publisher', name='joint_state_publisher', output='screen', ), # to spawn the robot we added gazebo_ros spawn entity node Node( package='gazebo_ros', executable='spawn_entity.py', name='urdf_spawner', output='screen', arguments=["-topic", "/robot_description", "-entity", "buche_robot"] ) ])