ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

No world frame in tf tree

asked 2021-10-11 08:58:58 -0500

Roshan gravatar image

Hello, I'm working on two turtlebots and I have managed to make them run in the same simulation. I have gotten a TF tree that looks like this:

image description

and now I want a /world frame to connect these two robots so that I can get a better visual representation of their frames in Rviz. Wondering how I'd get a /world frame, I have seen that you can create a /map frame by using SLAM and making the turtlebot explore a map/ use localization, but is there no simpler way of doing this? I'd like to have an empty world with just a fixed frame.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2021-10-11 10:39:48 -0500

tryan gravatar image

updated 2021-10-11 10:41:10 -0500

You can publish a static transform for each robot relative to an arbitrary world frame like so:

rosrun tf2_ros static_transform_publisher 0 0 0 0 0 0 world tb3_1/odom

where 0 0 0 0 0 0 is x y z yaw pitch roll. See the bottom of the Writing a tf2 static broadcaster (C++) tutorial for more information. These transforms will anchor the odometry frames to the shared world frame, connecting the two tf trees.

edit flag offensive delete link more

Comments

Thank you for your answer. I tried doing it like this in my launch file:

  <node pkg="tf2_ros" type="static_transform_publisher" name="world_broadcast" args="1 0 0 0 0 0 1 world tb3_1/odom" />
  <node pkg="tf2_ros" type="static_transform_publisher" name="world_broadcast2" args="1 0 0 0 0 0 1 world tb3_0/odom" />

And while it does work, I got some of these warnings:

[ WARN] [1633970165.290385117, 111.748000000]: TF_REPEATED_DATA ignoring data with redundant timestamp for frame tb3_0/base_footprint at time 111,705000 according to authority /gazebo
[ WARN] [1633970165.292532905, 111.748000000]: TF_REPEATED_DATA ignoring data with redundant timestamp for frame tb3_1/base_footprint at time 111,705000 according to authority /gazebo
[ WARN] [1633970165.293894016, 111.753000000]: TF_REPEATED_DATA ignoring data with redundant timestamp for frame tb3_0/base_footprint at time 111,705000 according to authority unknown_publisher
[ WARN] [1633970165.293965629, 111.75300000
Roshan gravatar image Roshan  ( 2021-10-11 11:38:26 -0500 )edit

They appear unrelated to the static_transform_publisher nodes as the warnings reference gazebo and base_footprint transforms. Here's a geometry2 issue discussing the warning. It may indicate you have multiple publishers of the same transforms, or one publisher publishing the same transform multiple times. Unless you suspect that the warnings are due to the static publishers, I would open a new question to address them.

tryan gravatar image tryan  ( 2021-10-11 12:48:29 -0500 )edit

I think there has to be something with the static publisher that's causing it, I've had issues like these before and they were due to problems with the tf prefixes. I fixed those by updating the ros_state_publisher and editing some files in the turtlebot gazebo model xacro to let it handle mutiple turtlebots, and the issue was completely fixed until I added the static publisher. But I'll open a new one because it could be related to the older issue and that it wasn't completely resolved

Edit: Saw that I had 1 0 0 0 0 0 1 instead of 0 0 0 0 0 0 0 (even though that didn't work so I used 0 0 0 0 0 0 1` ). For some reason I didn't get the warnings now.

Roshan gravatar image Roshan  ( 2021-10-11 12:59:47 -0500 )edit

I'm glad it's working! static_transform_publisher can take the transform as 6 numbers (x y z yaw pitch roll) or 7 numbers (x y z qx qy qz qw). 0 0 0 0 0 0 0 (7 zeros) would be invalid because it indicates a zero quaternion, but 0 0 0 0 0 0 (6 zeros) is valid because it indicates zero angles. That said, I'm not sure why 0 0 0 0 0 0 1 is fine but 1 0 0 0 0 0 1 produces warnings.

tryan gravatar image tryan  ( 2021-10-11 13:54:26 -0500 )edit

From the warning messages it does sound like gazebo and the static transform were publishing at the same time. What I noticed is that the warnings don't show up immedietly, only after a while, and it's not spamming like it usually does with the TF_REPEATED_DATA warnings, just 4 warning messages and that's it. But in Rviz all the frames seemed right so not sure what was wrong

Roshan gravatar image Roshan  ( 2021-10-11 14:00:26 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-10-11 08:58:58 -0500

Seen: 1,346 times

Last updated: Oct 11 '21