Advertisement
marichan022

mbanov_1_1.launch.py

Nov 14th, 2021
811
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.52 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. #
  3. # Copyright 2019 ROBOTIS CO., LTD.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. #
  9. #     http://www.apache.org/licenses/LICENSE-2.0
  10. #
  11. # Unless required by applicable law or agreed to in writing, software
  12. # distributed under the License is distributed on an "AS IS" BASIS,
  13. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. # See the License for the specific language governing permissions and
  15. # limitations under the License.
  16. #
  17. # Authors: Ryan Shim
  18.  
  19. import os
  20.  
  21. from ament_index_python.packages import get_package_share_directory
  22. from launch import LaunchDescription
  23. from launch_ros.actions import Node
  24. from launch.actions import IncludeLaunchDescription
  25. from launch.launch_description_sources import PythonLaunchDescriptionSource
  26. from launch.substitutions import LaunchConfiguration
  27.  
  28. TURTLEBOT3_MODEL = os.environ['TURTLEBOT3_MODEL']
  29.  
  30.  
  31. def generate_launch_description():
  32.     use_sim_time = LaunchConfiguration('use_sim_time', default='true')
  33.     world_file_name = 'turtlebot3_dqn_stage1/' + TURTLEBOT3_MODEL + '.model'
  34.     world = os.path.join(get_package_share_directory('turtlebot3_gazebo'),
  35.                          'worlds', world_file_name)
  36.     launch_file_dir = os.path.join(get_package_share_directory('turtlebot3_gazebo'), 'launch')
  37.     pkg_gazebo_ros = get_package_share_directory('gazebo_ros')
  38.     rviz_config_dir = os.path.join(get_package_share_directory('mbanov_1_1'), 'rviz', 'rviz.rviz')
  39.  
  40.     return LaunchDescription([
  41.         Node(
  42.             name='position_listener',
  43.             package='mbanov_1_1',
  44.             executable='position_listener',
  45.             namespace='',
  46.             output='screen',
  47.         ),
  48.    
  49.         IncludeLaunchDescription(
  50.             PythonLaunchDescriptionSource(
  51.                 os.path.join(pkg_gazebo_ros, 'launch', 'gzserver.launch.py')
  52.             ),
  53.             launch_arguments={'world': world}.items(),
  54.         ),
  55.  
  56.         Node(
  57.             name='rviz2',
  58.             package='rviz2',
  59.             executable='rviz2',
  60.             output = 'screen',
  61.             arguments=['-d', rviz_config_dir],
  62.             parameters=[{'use_sim_time': False}]
  63.         ),
  64.  
  65.         IncludeLaunchDescription(
  66.             PythonLaunchDescriptionSource([launch_file_dir, '/robot_state_publisher.launch.py']),
  67.             launch_arguments={'use_sim_time': use_sim_time}.items(),
  68.         ),
  69.     ])
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement