Advertisement
Guest User

display.launch.py

a guest
Jul 30th, 2023
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.41 KB | Source Code | 0 0
  1. import launch
  2. from launch.substitutions import Command, LaunchConfiguration
  3. from launch.actions import IncludeLaunchDescription
  4. from launch.launch_description_sources import PythonLaunchDescriptionSource
  5. import launch_ros
  6. import os
  7. from ament_index_python.packages import get_package_share_directory
  8.  
  9. def generate_launch_description():
  10. bringup_dir = get_package_share_directory('nav2_bringup')
  11. default_model_path = os.path.join(bringup_dir, 'urdf', 'arocs_truck.urdf')
  12. default_rviz_config_path = os.path.join(bringup_dir, 'rviz', 'tune_depth_scan.rviz')
  13. param_file_path = os.path.join(bringup_dir, 'params', 'real_depth_scan_param.yaml')
  14. pcd_param_file_path = os.path.join(bringup_dir, 'params', 'pointcloud_to_laserscan.yaml')
  15.  
  16. robot_state_publisher_node = launch_ros.actions.Node(
  17. package='robot_state_publisher',
  18. executable='robot_state_publisher',
  19. parameters=[
  20. {'robot_description': launch_ros.parameter_descriptions.ParameterValue(
  21. Command(['xacro ', LaunchConfiguration('model')]),
  22. value_type=str
  23. )}
  24. ]
  25. )
  26.  
  27. joint_state_publisher_node = launch_ros.actions.Node(
  28. package='joint_state_publisher',
  29. executable='joint_state_publisher',
  30. name='joint_state_publisher',
  31. condition=launch.conditions.UnlessCondition(LaunchConfiguration('gui'))
  32. )
  33. rviz_node = launch_ros.actions.Node(
  34. package='rviz2',
  35. executable='rviz2',
  36. name='rviz2',
  37. output='screen',
  38. arguments=['-d', LaunchConfiguration('rvizconfig')],
  39. )
  40. spawn_entity = launch_ros.actions.Node(
  41. package='gazebo_ros',
  42. executable='spawn_entity.py',
  43. arguments=['-entity', 'sam_bot', '-topic', 'robot_description'],
  44. output='screen'
  45. )
  46. robot_localization_node = launch_ros.actions.Node(
  47. package='robot_localization',
  48. executable='ekf_node',
  49. name='ekf_filter_node',
  50. output='screen',
  51. parameters=[os.path.join(bringup_dir, 'params/ekf.yaml'), {'use_sim_time': LaunchConfiguration('use_sim_time')}]
  52. )
  53.  
  54. #This TF was already done in xacro file (real_kinect_depth_joint)
  55.  
  56. # static_transform_node = launch_ros.actions.Node(
  57. # package='tf2_ros',
  58. # executable='static_transform_publisher',
  59. # arguments=['1', '-1', '0', '0', '0', '0', 'left_lidar_link', 'real_kinect_depth_frame']
  60. # )
  61.  
  62.  
  63.  
  64. depth_to_laser_scan_node = launch_ros.actions.Node(
  65. package='depthimage_to_laserscan',
  66. executable='depthimage_to_laserscan_node',
  67. name='depthimage_to_laserscan',
  68. parameters=[param_file_path],
  69. remappings=[
  70. ("depth", "/depth/image_raw"),
  71. ("depth_camera_info", "/depth/camera_info"),
  72. ("scan", "/real_kinect_sensor/scan")
  73. ]
  74. )
  75.  
  76. point_cloud_to_laser_scan_node = launch_ros.actions.Node(
  77. package='pointcloud_to_laserscan',
  78. executable='pointcloud_to_laserscan_node',
  79. name='pointcloud_to_laserscan',
  80. parameters=[pcd_param_file_path],
  81. remappings=[
  82. ("cloud_in", "/points"),
  83. ("scan", "/real_kinect_sensor/scan")
  84. ]
  85. )
  86.  
  87.  
  88. return launch.LaunchDescription([
  89. launch.actions.DeclareLaunchArgument(name='gui', default_value='True',
  90. description='Flag to enable joint_state_publisher_gui'),
  91. launch.actions.DeclareLaunchArgument(name='model', default_value=default_model_path,
  92. description='Absolute path to robot urdf file'),
  93. launch.actions.DeclareLaunchArgument(name='rvizconfig', default_value=default_rviz_config_path,
  94. description='Absolute path to rviz config file'),
  95. launch.actions.DeclareLaunchArgument(name='use_sim_time', default_value='True',
  96. description='Flag to enable use_sim_time'),
  97. launch.actions.ExecuteProcess(cmd=['gazebo', '--verbose', '-s', 'libgazebo_ros_init.so', '-s', 'libgazebo_ros_factory.so'], output='screen'),
  98. joint_state_publisher_node,
  99. robot_state_publisher_node,
  100. spawn_entity,
  101. robot_localization_node,
  102. rviz_node,
  103. #static_transform_node,
  104. depth_to_laser_scan_node,
  105. #point_cloud_to_laser_scan_node
  106. ])
  107.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement