Operating System:
Ubuntu 22.04
ROS version:
ROS 2: Humble
Turtlebot3 Model:
Waffle
Bug Description
The Problem
When frame_prefix is left as default (''), this expression evaluates to "/".
As a result, robot_state_publisher publishes frames like /base_link, /base_scan, /imu_link.
However, Gazebo's diff_drive plugin and SLAM (e.g., slam_toolbox) publish odom and map without the leading slash.
In ROS 2 tf2, base_link and /base_link are considered different frames, splitting the TF tree into two unconnected trees. This breaks Nav2 and autonomous exploration.
The Fix
This is a ROS 1 to ROS 2 migration artifact (ROS 1 tf ignored leading slashes).
It should be changed to only add the slash if a prefix is actually provided:
Steps to Reproduce
- Export the simulation environment:
export TURTLEBOT3_MODEL=waffle
- Launch the Gazebo simulation:
ros2 launch turtlebot3_gazebo turtlebot3_world.launch.py
- In a new terminal, launch SLAM (e.g., Cartographer):
ros2 launch turtlebot3_cartographer cartographer.launch.py use_sim_time:=True
- In a new terminal, launch Nav2:
ros2 launch nav2_bringup navigation_launch.py use_sim_time:=True params_file:=/opt/ros/humble/share/nav2_bringup/params/nav2_params.yaml
- Check the TF tree structure:
ros2 run tf2_tools view_frames
- Open the generated
frames.pdf (or run ros2 topic echo /tf_static --once).
Expected behavior:
The TF tree should be a single connected tree: map -> odom -> base_footprint -> base_link -> base_scan (without any leading slashes).
Actual behavior:
The TF tree is split into two unconnected trees:
- Tree 1:
map -> odom -> base_footprint
- Tree 2:
/base_footprint -> /base_link -> /base_scan -> etc.
Nav2 throws TF_SELF_TRANSFORM errors and fails to navigate properly.
### Actual Behavior
_No response_
### What Have You Tried?
```shell
Got resolved by:
IN:
~/workspace/turtlebot3_ws/src/src/turtlebot3_simulations/turtlebot3_gazebo/launch/robot_state_publisher.launch.py
Replace 'frame_prefix' as :
'frame_prefix': PythonExpression(["'", frame_prefix, "/' if '", frame_prefix, "' else ''"]),
Relevant Logs / Terminal Output
Additional Information (Optional)
No response
Operating System:
Ubuntu 22.04
ROS version:
ROS 2: Humble
Turtlebot3 Model:
Waffle
Bug Description
The Problem
When
frame_prefixis left as default (''), this expression evaluates to"/".As a result,
robot_state_publisherpublishes frames like/base_link,/base_scan,/imu_link.However, Gazebo's diff_drive plugin and SLAM (e.g., slam_toolbox) publish
odomandmapwithout the leading slash.In ROS 2
tf2,base_linkand/base_linkare considered different frames, splitting the TF tree into two unconnected trees. This breaks Nav2 and autonomous exploration.The Fix
This is a ROS 1 to ROS 2 migration artifact (ROS 1 tf ignored leading slashes).
It should be changed to only add the slash if a prefix is actually provided:
Steps to Reproduce
export TURTLEBOT3_MODEL=waffleframes.pdf(or runros2 topic echo /tf_static --once).Expected behavior:
The TF tree should be a single connected tree:
map->odom->base_footprint->base_link->base_scan(without any leading slashes).Actual behavior:
The TF tree is split into two unconnected trees:
map->odom->base_footprint/base_footprint->/base_link->/base_scan-> etc.Nav2 throws
TF_SELF_TRANSFORMerrors and fails to navigate properly.Relevant Logs / Terminal Output
Additional Information (Optional)
No response