demo_2robots.launch.py
Go to the documentation of this file.
1 
2 # ROS2 launch file
3 
4 from launch import LaunchDescription
5 from launch.substitutions import TextSubstitution
6 from launch.substitutions import LaunchConfiguration
7 from launch_ros.actions import Node
8 from launch.actions import DeclareLaunchArgument
9 from ament_index_python import get_package_share_directory
10 import os
11 
12 
14  mvsimDir = get_package_share_directory("mvsim")
15  # print('mvsimDir: ' + mvsimDir)
16 
17  # args that can be set from the command line or a default will be used
18  world_file_launch_arg = DeclareLaunchArgument(
19  "world_file", default_value=TextSubstitution(
20  text=os.path.join(mvsimDir, 'mvsim_tutorial', 'demo_2robots.world.xml')))
21  do_fake_localization_arg = DeclareLaunchArgument(
22  "do_fake_localization", default_value='True', description='publish tf odom -> base_link')
23 
24  mvsim_node = Node(
25  package='mvsim',
26  executable='mvsim_node',
27  name='mvsim',
28  output='screen',
29  parameters=[
30  os.path.join(mvsimDir, 'mvsim_tutorial', 'mvsim_ros2_params.yaml'),
31  {
32  "world_file": LaunchConfiguration('world_file'),
33  "do_fake_localization": LaunchConfiguration('do_fake_localization'),
34  }]
35  )
36 
37  rviz2_r1_node = Node(
38  package='rviz2',
39  executable='rviz2',
40  name='rviz2',
41  namespace='r1',
42  arguments=[
43  '-d', [os.path.join(mvsimDir, 'mvsim_tutorial', 'demo_2robots_r1_ros2.rviz')]],
44  output='screen',
45  remappings=[('/map', 'map'),
46  ('/tf', 'tf'),
47  ('/tf_static', 'tf_static'),
48  ('/goal_pose', 'goal_pose'),
49  ('/clicked_point', 'clicked_point'),
50  ('/initialpose', 'initialpose')]
51  )
52 
53  rviz2_r2_node = Node(
54  package='rviz2',
55  executable='rviz2',
56  name='rviz2',
57  namespace='r2',
58  arguments=[
59  '-d', [os.path.join(mvsimDir, 'mvsim_tutorial', 'demo_2robots_r2_ros2.rviz')]],
60  output='screen',
61  remappings=[('/map', 'map'),
62  ('/tf', 'tf'),
63  ('/tf_static', 'tf_static'),
64  ('/goal_pose', 'goal_pose'),
65  ('/clicked_point', 'clicked_point'),
66  ('/initialpose', 'initialpose')]
67  )
68 
69  return LaunchDescription([
70  world_file_launch_arg,
71  do_fake_localization_arg,
72  mvsim_node,
73  rviz2_r1_node,
74  rviz2_r2_node
75  ])
demo_2robots.generate_launch_description
def generate_launch_description()
Definition: demo_2robots.launch.py:13


mvsim
Author(s):
autogenerated on Wed May 28 2025 02:13:07