14
14
# limitations under the License.
15
15
16
16
import os
17
- from pathlib import Path
18
17
19
18
from ament_index_python .packages import get_package_share_directory
20
19
21
20
from launch import LaunchDescription
22
- from launch .actions import AppendEnvironmentVariable
23
21
from launch .actions import DeclareLaunchArgument
24
22
from launch .conditions import IfCondition
25
23
from launch .substitutions import LaunchConfiguration
29
27
30
28
def generate_launch_description ():
31
29
sim_dir = get_package_share_directory ('nav2_minimal_tb4_sim' )
32
- desc_dir = get_package_share_directory ('nav2_minimal_tb4_description' )
33
30
34
31
use_sim_time = LaunchConfiguration ('use_sim_time' )
35
32
namespace = LaunchConfiguration ('namespace' )
@@ -65,15 +62,11 @@ def generate_launch_description():
65
62
default_value = 'turtlebot4' ,
66
63
description = 'name of the robot' )
67
64
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
-
73
65
bridge = Node (
74
66
package = 'ros_gz_bridge' ,
75
67
executable = 'parameter_bridge' ,
76
68
name = 'bridge_ros_gz' ,
69
+ namespace = namespace ,
77
70
parameters = [
78
71
{
79
72
'config_file' : os .path .join (
@@ -89,6 +82,7 @@ def generate_launch_description():
89
82
package = 'ros_gz_image' ,
90
83
executable = 'image_bridge' ,
91
84
name = 'bridge_gz_ros_camera_image' ,
85
+ namespace = namespace ,
92
86
output = 'screen' ,
93
87
parameters = [{
94
88
'use_sim_time' : use_sim_time ,
@@ -99,6 +93,7 @@ def generate_launch_description():
99
93
package = 'ros_gz_image' ,
100
94
executable = 'image_bridge' ,
101
95
name = 'bridge_gz_ros_camera_depth' ,
96
+ namespace = namespace ,
102
97
output = 'screen' ,
103
98
parameters = [{
104
99
'use_sim_time' : use_sim_time ,
@@ -109,31 +104,23 @@ def generate_launch_description():
109
104
condition = IfCondition (use_simulator ),
110
105
package = 'ros_gz_sim' ,
111
106
executable = 'create' ,
107
+ namespace = namespace ,
112
108
output = 'screen' ,
113
109
arguments = [
114
- '-entity ' , robot_name ,
110
+ '-name ' , robot_name ,
115
111
'-topic' , 'robot_description' ,
116
- # '-file', Command(['xacro', ' ', robot_sdf]), # TODO SDF file is unhappy, not sure why
117
- '-robot_namespace' , namespace ,
118
112
'-x' , pose ['x' ], '-y' , pose ['y' ], '-z' , pose ['z' ],
119
113
'-R' , pose ['R' ], '-P' , pose ['P' ], '-Y' , pose ['Y' ]],
120
114
parameters = [{'use_sim_time' : use_sim_time }]
121
115
)
122
116
123
- set_env_vars_resources = AppendEnvironmentVariable (
124
- 'GZ_SIM_RESOURCE_PATH' ,
125
- str (Path (os .path .join (desc_dir )).parent .resolve ()))
126
-
127
117
# Create the launch description and populate
128
118
ld = LaunchDescription ()
129
119
ld .add_action (declare_namespace_cmd )
130
120
ld .add_action (declare_robot_name_cmd )
131
- # ld.add_action(declare_robot_sdf_cmd)
132
121
ld .add_action (declare_use_simulator_cmd )
133
122
ld .add_action (declare_use_sim_time_cmd )
134
123
135
- ld .add_action (set_env_vars_resources )
136
-
137
124
ld .add_action (bridge )
138
125
ld .add_action (camera_bridge_image )
139
126
ld .add_action (camera_bridge_depth )
0 commit comments