1717
1818from ament_index_python .packages import get_package_share_directory
1919from launch import LaunchDescription
20- from launch .actions import ExecuteProcess , IncludeLaunchDescription , OpaqueFunction , RegisterEventHandler
20+ from launch .actions import (
21+ ExecuteProcess ,
22+ IncludeLaunchDescription ,
23+ OpaqueFunction ,
24+ RegisterEventHandler ,
25+ )
2126from launch .event_handlers import OnShutdown
2227from launch .launch_description_sources import PythonLaunchDescriptionSource
2328from launch_ros .actions import Node
2429
2530
2631def generate_launch_description ():
27- nav2_bringup_dir = get_package_share_directory (' nav2_bringup' )
28- coverage_demo_dir = get_package_share_directory (' opennav_coverage_demo' )
29- rviz_config_file = os .path .join (coverage_demo_dir , ' rviz_config.rviz' )
32+ nav2_bringup_dir = get_package_share_directory (" nav2_bringup" )
33+ coverage_demo_dir = get_package_share_directory (" opennav_coverage_demo" )
34+ rviz_config_file = os .path .join (coverage_demo_dir , " rviz_config.rviz" )
3035 sim_dir = get_package_share_directory ("nav2_minimal_tb3_sim" )
3136
32- world = os .path .join (coverage_demo_dir , ' blank.world' )
33- param_file_path = os .path .join (coverage_demo_dir , ' demo_params.yaml' )
37+ world = os .path .join (coverage_demo_dir , " blank.world" )
38+ param_file_path = os .path .join (coverage_demo_dir , " demo_params.yaml" )
3439 robot_sdf = os .path .join (sim_dir , "urdf" , "gz_waffle.sdf.xacro" )
3540
3641 # start the simulation
@@ -41,20 +46,22 @@ def generate_launch_description():
4146 output = "screen" ,
4247 )
4348
44- urdf = os .path .join (sim_dir , ' urdf' , ' turtlebot3_waffle.urdf' )
45- with open (urdf , 'r' ) as infp :
49+ urdf = os .path .join (sim_dir , " urdf" , " turtlebot3_waffle.urdf" )
50+ with open (urdf , "r" ) as infp :
4651 robot_description = infp .read ()
4752
4853 start_robot_state_publisher_cmd = Node (
49- package = ' robot_state_publisher' ,
50- executable = ' robot_state_publisher' ,
51- name = ' robot_state_publisher' ,
52- output = ' screen' ,
53- parameters = [{' use_sim_time' : True ,
54- 'robot_description' : robot_description }] )
54+ package = " robot_state_publisher" ,
55+ executable = " robot_state_publisher" ,
56+ name = " robot_state_publisher" ,
57+ output = " screen" ,
58+ parameters = [{" use_sim_time" : True , "robot_description" : robot_description }] ,
59+ )
5560
5661 remove_temp_sdf_file = RegisterEventHandler (
57- event_handler = OnShutdown (on_shutdown = [OpaqueFunction (function = lambda _ : os .remove (world_sdf ))])
62+ event_handler = OnShutdown (
63+ on_shutdown = [OpaqueFunction (function = lambda _ : os .remove (world_sdf ))]
64+ )
5865 )
5966
6067 gazebo_client = IncludeLaunchDescription (
@@ -65,48 +72,53 @@ def generate_launch_description():
6572 )
6673
6774 start_gazebo_spawner_cmd = IncludeLaunchDescription (
68- PythonLaunchDescriptionSource (
69- os .path .join (sim_dir , 'launch' , 'spawn_tb3.launch.py' )),
70- launch_arguments = {'namespace' : '' ,
71- 'robot_name' : 'turtlebot3_waffle' ,
72- 'robot_sdf' : robot_sdf ,
73- 'x_pose' : str (6.23 ),
74- 'y_pose' : str (15.0 ),
75- 'z_pose' : str (0.1 ),
76- 'roll' : str (0.0 ),
77- 'pitch' : str (0.0 ),
78- 'yaw' : str (- 1.5708 )}.items ())
75+ PythonLaunchDescriptionSource (os .path .join (sim_dir , "launch" , "spawn_tb3.launch.py" )),
76+ launch_arguments = {
77+ "namespace" : "" ,
78+ "robot_name" : "turtlebot3_waffle" ,
79+ "robot_sdf" : robot_sdf ,
80+ "x_pose" : str (6.23 ),
81+ "y_pose" : str (15.0 ),
82+ "z_pose" : str (0.1 ),
83+ "roll" : str (0.0 ),
84+ "pitch" : str (0.0 ),
85+ "yaw" : str (- 1.5708 ),
86+ }.items (),
87+ )
7988
8089 # start the visualization
8190 rviz_cmd = IncludeLaunchDescription (
82- PythonLaunchDescriptionSource (
83- os . path . join ( nav2_bringup_dir , 'launch' , 'rviz_launch.py' ) ),
84- launch_arguments = { 'namespace' : '' , 'rviz_config' : rviz_config_file }. items () )
91+ PythonLaunchDescriptionSource (os . path . join ( nav2_bringup_dir , "launch" , "rviz_launch.py" )),
92+ launch_arguments = { "namespace" : "" , "rviz_config" : rviz_config_file }. items ( ),
93+ )
8594
8695 # start navigation
8796 bringup_cmd = IncludeLaunchDescription (
88- PythonLaunchDescriptionSource (
89- os . path . join ( coverage_demo_dir , 'row_bringup_launch.py' ) ),
90- launch_arguments = { 'params_file' : param_file_path }. items () )
97+ PythonLaunchDescriptionSource (os . path . join ( coverage_demo_dir , "row_bringup_launch.py" )),
98+ launch_arguments = { "params_file" : param_file_path }. items ( ),
99+ )
91100
92101 # Demo GPS->map->odom transform, no localization. For visualization & controller transform
93102 fake_localization_cmd = Node (
94- package = 'tf2_ros' ,
95- executable = 'static_transform_publisher' ,
96- output = 'screen' ,
97- arguments = ['6.23' , '15' , '0' , '0' , '0' , '0' , 'map' , 'odom' ])
103+ package = "tf2_ros" ,
104+ executable = "static_transform_publisher" ,
105+ output = "screen" ,
106+ arguments = ["6.23" , "15" , "0" , "0" , "0" , "0" , "map" , "odom" ],
107+ )
98108 fake_gps_cmd = Node (
99- package = 'tf2_ros' ,
100- executable = 'static_transform_publisher' ,
101- output = 'screen' ,
102- arguments = ['0' , '0' , '0' , '0' , '0' , '0' , 'EPSG:4258' , 'map' ])
109+ package = "tf2_ros" ,
110+ executable = "static_transform_publisher" ,
111+ output = "screen" ,
112+ arguments = ["0" , "0" , "0" , "0" , "0" , "0" , "EPSG:4258" , "map" ],
113+ )
103114
104115 # start the demo task
105116 demo_cmd = Node (
106- package = ' opennav_coverage_demo' ,
107- executable = ' demo_row_coverage' ,
117+ package = " opennav_coverage_demo" ,
118+ executable = " demo_row_coverage" ,
108119 emulate_tty = True ,
109- output = 'screen' )
120+ output = "screen" ,
121+ )
110122
111123 ld = LaunchDescription ()
112124 ld .add_action (world_sdf_xacro )
0 commit comments