Skip to content

Commit 17325d5

Browse files
committed
fix(demos/ota): bypass turtlebot3_gazebo's hardcoded frame_prefix slash
turtlebot3_gazebo's robot_state_publisher.launch.py builds the frame_prefix parameter with PythonExpression(["'", frame_prefix, "/'"]), which appends a literal "/" even when the launch arg is empty. The result was a tf tree where AMCL / odometry broadcast frames as "base_link" (no slash) and robot_state_publisher published joint transforms as "/base_link" (with slash). Two disjoint subgraphs - so Foxglove rendered the URDF as a pile of disconnected meshes scattered around the origin instead of a robot model attached to base_footprint. Spawn robot_state_publisher directly from this launch with frame_prefix='' (empty, no PythonExpression mutilation), reading the turtlebot3 URDF off disk the same way the upstream launch does. Result: tf_static now reports "base_link", "base_footprint" without leading slashes, the URDF renders as one connected robot, and "map -> base_link" resolves end-to-end.
1 parent f48cbba commit 17325d5

1 file changed

Lines changed: 26 additions & 5 deletions

File tree

  • demos/ota_nav2_sensor_fix/ros2_packages/ota_nav2_sensor_fix_demo/launch

demos/ota_nav2_sensor_fix/ros2_packages/ota_nav2_sensor_fix_demo/launch/demo.launch.py

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,32 @@ def generate_launch_description():
132132
condition=IfCondition(headless),
133133
)
134134

135-
robot_state_publisher = IncludeLaunchDescription(
136-
PythonLaunchDescriptionSource(
137-
os.path.join(turtlebot3_gazebo_dir, 'launch', 'robot_state_publisher.launch.py'),
138-
),
139-
launch_arguments={'use_sim_time': use_sim_time}.items(),
135+
# We deliberately do NOT include turtlebot3_gazebo's
136+
# robot_state_publisher.launch.py - it hardcodes
137+
# `frame_prefix=PythonExpression(["'", frame_prefix, "/'"])`, which
138+
# appends a leading "/" to every link name even when the launch arg
139+
# is empty. The result was a tf tree where odom / amcl frames are
140+
# `base_link` (no slash) and URDF link frames are `/base_link`
141+
# (with slash) - two disjoint subgraphs, so Foxglove rendered the
142+
# robot as a pile of disconnected meshes. Spawn robot_state_publisher
143+
# directly with an empty frame_prefix.
144+
turtlebot3_model = os.environ.get('TURTLEBOT3_MODEL', 'burger')
145+
urdf_path = os.path.join(
146+
turtlebot3_gazebo_dir, 'urdf', f'turtlebot3_{turtlebot3_model}.urdf'
147+
)
148+
with open(urdf_path, 'r') as f:
149+
robot_desc = f.read()
150+
151+
robot_state_publisher = Node(
152+
package='robot_state_publisher',
153+
executable='robot_state_publisher',
154+
name='robot_state_publisher',
155+
output='screen',
156+
parameters=[{
157+
'use_sim_time': use_sim_time,
158+
'robot_description': robot_desc,
159+
'frame_prefix': '',
160+
}],
140161
condition=IfCondition(headless),
141162
)
142163

0 commit comments

Comments
 (0)