demo_road_circuit1.launch.py
Go to the documentation of this file.
1 # ROS2 launch file
2 
3 from launch import LaunchDescription
4 from launch.substitutions import TextSubstitution
5 from launch.substitutions import LaunchConfiguration
6 from launch_ros.actions import Node
7 from launch.actions import DeclareLaunchArgument
8 from ament_index_python import get_package_share_directory
9 from launch.conditions import IfCondition
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_road_circuit1.world.xml')))
21 
22  headless_launch_arg = DeclareLaunchArgument(
23  "headless", default_value='False')
24 
25  do_fake_localization_arg = DeclareLaunchArgument(
26  "do_fake_localization", default_value='True', description='publish tf odom -> base_link')
27 
28  mvsim_node = Node(
29  package='mvsim',
30  executable='mvsim_node',
31  name='mvsim',
32  output='screen',
33  parameters=[
34  os.path.join(mvsimDir, 'mvsim_tutorial',
35  'mvsim_ros2_params.yaml'),
36  {
37  "world_file": LaunchConfiguration('world_file'),
38  "headless": LaunchConfiguration('headless'),
39  "do_fake_localization": LaunchConfiguration('do_fake_localization'),
40  }]
41  )
42 
43  # rviz
44  use_rviz = LaunchConfiguration('use_rviz')
45 
46  declare_use_rviz_cmd = DeclareLaunchArgument(
47  'use_rviz',
48  default_value='True',
49  description='Whether to start RVIZ')
50 
51  rviz2_nodes = [
52  Node(
53  condition=IfCondition(use_rviz),
54  package='rviz2',
55  executable='rviz2',
56  name='rviz2',
57  # namespace=f"veh{idx}",
58  arguments=[
59  '-d', [os.path.join(mvsimDir, 'mvsim_tutorial', 'demo_road_circuit1_ros2.rviz')]],
60  output='screen',
61  remappings=[
62  ("/map", f"/r{idx}/map"),
63  ("/tf", f"/r{idx}/tf"),
64  ("/tf_static", f"/r{idx}/tf_static"),
65  ("/goal_pose", f"/r{idx}/goal_pose"),
66  ("/clicked_point", f"/r{idx}/clicked_point"),
67  ("/vehs/cmd_vel", f"/r{idx}/cmd_vel"),
68  ("/vehs/lidar1_points", f"/r{idx}/lidar1_points"),
69  ("/vehs/camera1/image_raw", f"/r{idx}/camera1/image_raw"),
70  ("/vehs/chassis_markers", f"/r{idx}/chassis_markers"),
71  ("/vehs/scanner1", f"/r{idx}/scanner1"),
72  ],
73  )
74  for idx in range(1, 2)
75  ]
76 
77  rviz2_node = Node(
78  package='rviz2',
79  executable='rviz2',
80  name='rviz2',
81  arguments=[
82  '-d', [os.path.join(mvsimDir, 'mvsim_tutorial', 'demo_warehouse_ros2.rviz')]]
83  )
84 
85  return LaunchDescription([
86  world_file_launch_arg,
87  declare_use_rviz_cmd,
88  headless_launch_arg,
89  do_fake_localization_arg,
90  mvsim_node
91  ]
92  + rviz2_nodes
93  )
demo_road_circuit1.generate_launch_description
def generate_launch_description()
Definition: demo_road_circuit1.launch.py:13


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