18 from ament_index_python.packages
import get_package_share_directory
20 from launch
import LaunchDescription
21 from launch.actions
import DeclareLaunchArgument, ExecuteProcess, IncludeLaunchDescription
22 from launch.conditions
import IfCondition
23 from launch.launch_description_sources
import PythonLaunchDescriptionSource
24 from launch.substitutions
import LaunchConfiguration, PythonExpression
25 from launch_ros.actions
import Node
28 def generate_launch_description():
29 warehouse_dir = get_package_share_directory(
'aws_robomaker_small_warehouse_world')
30 nav2_bringup_dir = get_package_share_directory(
'nav2_bringup')
31 python_commander_dir = get_package_share_directory(
'nav2_simple_commander')
33 map_yaml_file = os.path.join(warehouse_dir,
'maps',
'005',
'map.yaml')
34 world = os.path.join(python_commander_dir,
'warehouse.world')
37 use_rviz = LaunchConfiguration(
'use_rviz')
38 headless = LaunchConfiguration(
'headless')
41 declare_use_rviz_cmd = DeclareLaunchArgument(
44 description=
'Whether to start RVIZ')
46 declare_simulator_cmd = DeclareLaunchArgument(
48 default_value=
'False',
49 description=
'Whether to execute gzclient)')
52 start_gazebo_server_cmd = ExecuteProcess(
53 cmd=[
'gzserver',
'-s',
'libgazebo_ros_factory.so', world],
54 cwd=[warehouse_dir], output=
'screen')
56 start_gazebo_client_cmd = ExecuteProcess(
57 condition=IfCondition(PythonExpression([
'not ', headless])),
59 cwd=[warehouse_dir], output=
'screen')
61 urdf = os.path.join(nav2_bringup_dir,
'urdf',
'turtlebot3_waffle.urdf')
62 start_robot_state_publisher_cmd = Node(
63 package=
'robot_state_publisher',
64 executable=
'robot_state_publisher',
65 name=
'robot_state_publisher',
70 rviz_cmd = IncludeLaunchDescription(
71 PythonLaunchDescriptionSource(
72 os.path.join(nav2_bringup_dir,
'launch',
'rviz_launch.py')),
73 condition=IfCondition(use_rviz),
74 launch_arguments={
'namespace':
'',
75 'use_namespace':
'False'}.items())
78 bringup_cmd = IncludeLaunchDescription(
79 PythonLaunchDescriptionSource(
80 os.path.join(nav2_bringup_dir,
'launch',
'bringup_launch.py')),
81 launch_arguments={
'map': map_yaml_file}.items())
85 package=
'nav2_simple_commander',
86 executable=
'example_assisted_teleop',
90 ld = LaunchDescription()
91 ld.add_action(declare_use_rviz_cmd)
92 ld.add_action(declare_simulator_cmd)
93 ld.add_action(start_gazebo_server_cmd)
94 ld.add_action(start_gazebo_client_cmd)
95 ld.add_action(start_robot_state_publisher_cmd)
96 ld.add_action(rviz_cmd)
97 ld.add_action(bringup_cmd)
98 ld.add_action(demo_cmd)