17 from ament_index_python.packages
import get_package_share_directory
19 from launch
import LaunchDescription
20 from launch.actions
import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
21 from launch.conditions
import IfCondition
22 from launch.launch_description_sources
import PythonLaunchDescriptionSource
23 from launch.substitutions
import LaunchConfiguration, PythonExpression
24 from launch_ros.actions
import Node
27 def generate_launch_description():
28 warehouse_dir = get_package_share_directory(
'aws_robomaker_small_warehouse_world')
29 nav2_bringup_dir = get_package_share_directory(
'nav2_bringup')
30 python_commander_dir = get_package_share_directory(
'nav2_simple_commander')
32 map_yaml_file = os.path.join(warehouse_dir,
'maps',
'005',
'map.yaml')
33 world = os.path.join(python_commander_dir,
'warehouse.world')
36 use_rviz = LaunchConfiguration(
'use_rviz')
37 headless = LaunchConfiguration(
'headless')
40 declare_use_rviz_cmd = DeclareLaunchArgument(
43 description=
'Whether to start RVIZ')
45 declare_simulator_cmd = DeclareLaunchArgument(
47 default_value=
'False',
48 description=
'Whether to execute gzclient)')
51 start_gazebo_server_cmd = ExecuteProcess(
52 cmd=[
'gzserver',
'-s',
'libgazebo_ros_factory.so', world],
53 cwd=[warehouse_dir], output=
'screen')
55 start_gazebo_client_cmd = ExecuteProcess(
56 condition=IfCondition(PythonExpression([
'not ', headless])),
58 cwd=[warehouse_dir], output=
'screen')
60 urdf = os.path.join(nav2_bringup_dir,
'urdf',
'turtlebot3_waffle.urdf')
61 start_robot_state_publisher_cmd = Node(
62 package=
'robot_state_publisher',
63 executable=
'robot_state_publisher',
64 name=
'robot_state_publisher',
69 rviz_cmd = IncludeLaunchDescription(
70 PythonLaunchDescriptionSource(
71 os.path.join(nav2_bringup_dir,
'launch',
'rviz_launch.py')),
72 condition=IfCondition(use_rviz),
73 launch_arguments={
'namespace':
'',
74 'use_namespace':
'False'}.items())
77 bringup_cmd = IncludeLaunchDescription(
78 PythonLaunchDescriptionSource(
79 os.path.join(nav2_bringup_dir,
'launch',
'bringup_launch.py')),
80 launch_arguments={
'map': map_yaml_file}.items())
84 package=
'nav2_simple_commander',
85 executable=
'example_nav_through_poses',
89 ld = LaunchDescription()
90 ld.add_action(declare_use_rviz_cmd)
91 ld.add_action(declare_simulator_cmd)
92 ld.add_action(start_gazebo_server_cmd)
93 ld.add_action(start_gazebo_client_cmd)
94 ld.add_action(start_robot_state_publisher_cmd)
95 ld.add_action(rviz_cmd)
96 ld.add_action(bringup_cmd)
97 ld.add_action(demo_cmd)