17
17
18
18
from ament_index_python .packages import get_package_share_directory
19
19
from 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
+ )
21
26
from launch .event_handlers import OnShutdown
22
27
from launch .launch_description_sources import PythonLaunchDescriptionSource
23
28
from launch_ros .actions import Node
@@ -27,18 +32,18 @@ def generate_launch_description():
27
32
nav2_bringup_dir = get_package_share_directory ('nav2_bringup' )
28
33
coverage_demo_dir = get_package_share_directory ('opennav_coverage_demo' )
29
34
rviz_config_file = os .path .join (coverage_demo_dir , 'rviz_config.rviz' )
30
- sim_dir = get_package_share_directory (" nav2_minimal_tb3_sim" )
35
+ sim_dir = get_package_share_directory (' nav2_minimal_tb3_sim' )
31
36
32
37
world = os .path .join (coverage_demo_dir , 'blank.world' )
33
38
param_file_path = os .path .join (coverage_demo_dir , 'demo_params.yaml' )
34
- robot_sdf = os .path .join (sim_dir , " urdf" , " gz_waffle.sdf.xacro" )
39
+ robot_sdf = os .path .join (sim_dir , ' urdf' , ' gz_waffle.sdf.xacro' )
35
40
36
41
# start the simulation
37
- world_sdf = tempfile .mktemp (prefix = " nav2_" , suffix = " .sdf" )
38
- world_sdf_xacro = ExecuteProcess (cmd = [" xacro" , "-o" , world_sdf , " headless:=false" , world ])
42
+ world_sdf = tempfile .mktemp (prefix = ' nav2_' , suffix = ' .sdf' )
43
+ world_sdf_xacro = ExecuteProcess (cmd = [' xacro' , '-o' , world_sdf , ' headless:=false' , world ])
39
44
gazebo_server = ExecuteProcess (
40
- cmd = ["gz" , " sim" , "-r" , "-s" , world_sdf ],
41
- output = " screen" ,
45
+ cmd = ['gz' , ' sim' , '-r' , '-s' , world_sdf ],
46
+ output = ' screen' ,
42
47
)
43
48
44
49
urdf = os .path .join (sim_dir , 'urdf' , 'turtlebot3_waffle.urdf' )
@@ -50,63 +55,70 @@ def generate_launch_description():
50
55
executable = 'robot_state_publisher' ,
51
56
name = 'robot_state_publisher' ,
52
57
output = 'screen' ,
53
- parameters = [{'use_sim_time' : True ,
54
- 'robot_description' : robot_description }] )
58
+ parameters = [{'use_sim_time' : True , 'robot_description' : robot_description }],
59
+ )
55
60
56
61
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
+ )
58
65
)
59
66
60
67
gazebo_client = IncludeLaunchDescription (
61
68
PythonLaunchDescriptionSource (
62
- os .path .join (get_package_share_directory (" ros_gz_sim" ), " launch" , " gz_sim.launch.py" )
69
+ os .path .join (get_package_share_directory (' ros_gz_sim' ), ' launch' , ' gz_sim.launch.py' )
63
70
),
64
- launch_arguments = {" gz_args" : [" -v4 -g " ]}.items (),
71
+ launch_arguments = {' gz_args' : [' -v4 -g ' ]}.items (),
65
72
)
66
73
67
74
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
+ )
79
88
80
89
# start the visualization
81
90
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
+ )
85
94
86
95
# start navigation
87
96
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
+ )
91
100
92
101
# Demo GPS->map->odom transform, no localization. For visualization & controller transform
93
102
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
+ )
98
108
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
+ )
103
114
104
115
# start the demo task
105
116
demo_cmd = Node (
106
117
package = 'opennav_coverage_demo' ,
107
118
executable = 'demo_row_coverage' ,
108
119
emulate_tty = True ,
109
- output = 'screen' )
120
+ output = 'screen' ,
121
+ )
110
122
111
123
ld = LaunchDescription ()
112
124
ld .add_action (world_sdf_xacro )
0 commit comments