1414# limitations under the License.
1515
1616import os
17- from pathlib import Path
1817
1918from ament_index_python .packages import get_package_share_directory
2019
2120from launch import LaunchDescription
22- from launch .actions import AppendEnvironmentVariable
2321from launch .actions import DeclareLaunchArgument
2422from launch .conditions import IfCondition
2523from launch .substitutions import LaunchConfiguration
2927
3028def generate_launch_description ():
3129 sim_dir = get_package_share_directory ('nav2_minimal_tb4_sim' )
32- desc_dir = get_package_share_directory ('nav2_minimal_tb4_description' )
3330
3431 use_sim_time = LaunchConfiguration ('use_sim_time' )
3532 namespace = LaunchConfiguration ('namespace' )
@@ -65,15 +62,11 @@ def generate_launch_description():
6562 default_value = 'turtlebot4' ,
6663 description = 'name of the robot' )
6764
68- # declare_robot_sdf_cmd = DeclareLaunchArgument(
69- # 'robot_sdf',
70- # default_value=os.path.join(desc_dir, 'urdf', 'standard', 'turtlebot4.urdf.xacro'),
71- # description='Full path to robot sdf file to spawn the robot in gazebo')
72-
7365 bridge = Node (
7466 package = 'ros_gz_bridge' ,
7567 executable = 'parameter_bridge' ,
7668 name = 'bridge_ros_gz' ,
69+ namespace = namespace ,
7770 parameters = [
7871 {
7972 'config_file' : os .path .join (
@@ -89,6 +82,7 @@ def generate_launch_description():
8982 package = 'ros_gz_image' ,
9083 executable = 'image_bridge' ,
9184 name = 'bridge_gz_ros_camera_image' ,
85+ namespace = namespace ,
9286 output = 'screen' ,
9387 parameters = [{
9488 'use_sim_time' : use_sim_time ,
@@ -99,6 +93,7 @@ def generate_launch_description():
9993 package = 'ros_gz_image' ,
10094 executable = 'image_bridge' ,
10195 name = 'bridge_gz_ros_camera_depth' ,
96+ namespace = namespace ,
10297 output = 'screen' ,
10398 parameters = [{
10499 'use_sim_time' : use_sim_time ,
@@ -109,31 +104,23 @@ def generate_launch_description():
109104 condition = IfCondition (use_simulator ),
110105 package = 'ros_gz_sim' ,
111106 executable = 'create' ,
107+ namespace = namespace ,
112108 output = 'screen' ,
113109 arguments = [
114- '-entity ' , robot_name ,
110+ '-name ' , robot_name ,
115111 '-topic' , 'robot_description' ,
116- # '-file', Command(['xacro', ' ', robot_sdf]), # TODO SDF file is unhappy, not sure why
117- '-robot_namespace' , namespace ,
118112 '-x' , pose ['x' ], '-y' , pose ['y' ], '-z' , pose ['z' ],
119113 '-R' , pose ['R' ], '-P' , pose ['P' ], '-Y' , pose ['Y' ]],
120114 parameters = [{'use_sim_time' : use_sim_time }]
121115 )
122116
123- set_env_vars_resources = AppendEnvironmentVariable (
124- 'GZ_SIM_RESOURCE_PATH' ,
125- str (Path (os .path .join (desc_dir )).parent .resolve ()))
126-
127117 # Create the launch description and populate
128118 ld = LaunchDescription ()
129119 ld .add_action (declare_namespace_cmd )
130120 ld .add_action (declare_robot_name_cmd )
131- # ld.add_action(declare_robot_sdf_cmd)
132121 ld .add_action (declare_use_simulator_cmd )
133122 ld .add_action (declare_use_sim_time_cmd )
134123
135- ld .add_action (set_env_vars_resources )
136-
137124 ld .add_action (bridge )
138125 ld .add_action (camera_bridge_image )
139126 ld .add_action (camera_bridge_depth )
0 commit comments