Hello, I am trying to run two turtlebots in a gazebo simulation. I'm wondering about the tf tree for the robots. This is what I get:
Sometimes if I refresh this I get:
so the wheel_right_link and wheel_left_link switch between tb3_0/robot_state_publisher and tb3_1/robot_state_publisher.
The launch file I am using is an edited version of the gazebo_simulations file found here: https://github.com/ROBOTIS-GIT/turtlebot3_simulations/blob/master/turtlebot3_gazebo/launch/multi_turtlebot3.launch.
When running the unedited version you get the same tf tree, just that it the wheel links switch between tb3_0/robot_state_publisher, tb3_1/robot_state_publisher and tb3_2/robot_state_publisher. Here is the tf tree for the unedited launch file:
This is the launch file I'm using:
<launch>
<arg name="model" default="$(env TURTLEBOT3_MODEL)" doc="model type [burger, waffle, waffle_pi]"/>
<arg name="first_tb3" default="tb3_0"/>
<arg name="second_tb3" default="tb3_1"/>
<arg name="first_tb3_x_pos" default="0.0"/>
<arg name="first_tb3_y_pos" default="1.0"/>
<arg name="first_tb3_z_pos" default=" 0.0"/>
<arg name="first_tb3_yaw" default=" 1.57"/>
<arg name="second_tb3_x_pos" default=" 0.0"/>
<arg name="second_tb3_y_pos" default="0.0"/>
<arg name="second_tb3_z_pos" default=" 0.0"/>
<arg name="second_tb3_yaw" default=" 1.57"/>
<include file="$(find gazebo_ros)/launch/empty_world.launch">
<arg name="world_name" value="$(find turtlebot3_gazebo)/worlds/custom_world2.world"/>
<arg name="paused" value="false"/>
<arg name="use_sim_time" value="true"/>
<arg name="gui" value="true"/>
<arg name="headless" value="false"/>
<arg name="debug" value="false"/>
</include>
<!-- Start marker detector-->
<node name="aruco_detect" pkg="aruco_detect" type="aruco_detect">
<param name="image_transport" value="compressed" />
<param name="publish_images" value="true" />
<param name="fiducial_len" value="0.15" />
<param name="dictionary" value="0" />
<param name="do_pose_estimation" value="true" />
<param name="ignore_fiducials" value="" />
<param name="fiducial_len_override" value="" />
<remap from="/camera/compressed" to="/tb3_1/camera/rgb/image_raw/compressed"/>
<remap from="/camera_info" to="/tb3_1/camera/rgb/camera_info"/>
</node>
<group ns = "$(arg first_tb3)">
<param name="robot_description" command="$(find xacro)/xacro --inorder $(find turtlebot3_description)/urdf/turtlebot3_$(arg model).urdf.xacro" />
<node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher" output="screen">
<param name="publish_frequency" type="double" value="50.0" />
<param name="tf_prefix" value="$(arg first_tb3)" />
</node>
<node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-urdf -model $(arg first_tb3) -x $(arg first_tb3_x_pos) -y $(arg first_tb3_y_pos) -z $(arg first_tb3_z_pos) -Y $(arg first_tb3_yaw) -param robot_description" />
</group>
<group ns = "$(arg second_tb3)">
<param name="robot_description" command="$(find xacro)/xacro --inorder $(find turtlebot3_description)/urdf/turtlebot3_$(arg model).urdf.xacro" />
<node pkg="robot_state_publisher" type="robot_state_publisher" name="robot_state_publisher" output="screen">
<param name="publish_frequency" type="double" value="50.0" />
<param name="tf_prefix" value="$(arg second_tb3)" />
</node>
<node name="spawn_urdf" pkg="gazebo_ros" type="spawn_model" args="-urdf -model $(arg second_tb3) -x $(arg second_tb3_x_pos) -y $(arg second_tb3_y_pos) -z $(arg second_tb3_z_pos) -Y $(arg second_tb3_yaw) -param robot_description" />
</group>
</launch>
and this is my world file:
<sdf version='1.6'>
<world name='default'>
<!-- A global light source -->
<include>
<uri>model://sun</uri>
</include>
<!-- A ground plane -->
<include>
<uri>model://ground_plane</uri>
</include>
<!--
<include>
<uri>model://marker</uri>
</include>
-->
<plugin name="ros_link_attacher_plugin" filename="libgazebo_ros_link_attacher.so" />
<physics type="ode">
<real_time_update_rate>1000.0</real_time_update_rate>
<max_step_size>0.001</max_step_size>
<real_time_factor>1</real_time_factor>
<ode>
<solver>
<type>quick</type>
<iters>150</iters>
<precon_iters>0</precon_iters>
<sor>1.400000</sor>
<use_dynamic_moi_rescaling>1</use_dynamic_moi_rescaling>
</solver>
<constraints>
<cfm>0.00001</cfm>
<erp>0.2</erp>
<contact_max_correcting_vel>2000.000000</contact_max_correcting_vel>
<contact_surface_layer>0.01000</contact_surface_layer>
</constraints>
</ode>
</physics>
<!-- Load world -->
<include>
<uri>model://turtlebot3_square</uri>
</include>
<scene>
<ambient>0.4 0.4 0.4 1</ambient>
<background>0.7 0.7 0.7 1</background>
<shadows>true</shadows>
</scene>
<gui fullscreen='0'>
<camera name='user_camera'>
<pose>0.0 0.0 17.0 0 1.5708 0</pose>
<view_controller>orbit</view_controller>
</camera>
</gui>
</world>
</sdf>
The reason why I'm asking is because when I try using anything related to tf, for example rosrun rqt_tf_tree rqt_tf_tree, I get spammed with warnings like these:
Warning: TF_REPEATED_DATA ignoring data with redundant timestamp for frame wheel_right_link at time 705,364000 according to authority /tb3_1/robot_state_publisher
at line 278 in /tmp/binarydeb/ros-noetic-tf2-0.7.5/src/buffer_core.cpp
However, this warning does not show up when trying to use the unedited version of the launch file. This question is related to a previous question: https://answers.ros.org/question/387984/tf_repeated_data-issue/
Thank you in advance.
Edit: I have been making gradual changes to the launch file. I started with the original and worked my way from there. First I removed one robot, making it so I only have 2. No warnings when running rqt. Then I changed their positions so that one robot was behind the other. No warnings when running rqt. Now I've changed the world from /worlds/turtlebot3_house.world to /worlds/empty_world.world. This is where I start getting warnings
After having worked my way from the original launch file to my own fully edited version I can with high certainty say that there is something in the two world files that is causing this issue. And checking this further it seems to have something to do with the house model:
<!-- A turtlebot symbol -->
<include>
<uri>model://turtlebot3_house</uri>
</include>
In the turtlebot3_house.world file. If this is removed, I get the warnings.
Edit 2: I have now tested this with every world file available in the turtlebot3_gazebo repository: https://github.com/ROBOTIS-GIT/turtlebot3_simulations/tree/master/turtlebot3_gazebo/worlds But the only one I do not get warnings on is the turtlebot3_house.world file. And as previously mentioned, if the turtlebot3_house model is removed from the world file you start getting warnings.
Edit 3: Still having issues, this time the warnings look a little different:
Warning: TF_REPEATED_DATA ignoring data with redundant timestamp for frame base_footprint at time 284,759000 according to authority /gazebo at line 278 in /tmp/binarydeb/ros-noetic-tf2-0.7.5/src/buffer_core.cpp
This time it's gazebo that's complaining, not the robot_state_publisher. The tf tree looks like this:
Edit 4: Because this issue has been partially solved and because the thread is getting messy a new question has been opened regarding the new warning: https://answers.ros.org/question/388195/tf_repeated_data-warnings/
Originally posted by Roshan on ROS Answers with karma: 51 on 2021-10-06
Post score: 0
Original comments
Comment by tfoote on 2021-10-06:
The launch file looks correct. You've removed references to the 3rd turtlebot and added the aruco detector. My best guess now is that you're launching using an alternative version of the file from the one you're editing or something like that. If you know the original file works. Start with that and incrementally make changes until it stops working to isolate the problem.
Comment by Roshan on 2021-10-06:
Does the tf tree look correct for the unedited file? The thing that has me a little worried is if the file I'm working off is also not doing things correctly, and especially the wheel links switching between the different tb3s has me worried. But I will incrementally add changes and see what causes the issue as you said.
Edit:
I have been making gradual changes to the launch file. I started with the original and worked my way from there. If I use an empty world file I get the warnings, but if I use the turtlebot3_house file I don't get the warnings. In addition, removing the
<!-- A turtlebot symbol -->
<include>
<uri>model://turtlebot3_house</uri>
</include>
from the house file also gives the warnings. It seems that this model has to be in the world file or else you start getting warnings. More details in the edit on the post because of character constraints.
Comment by shonigmann on 2021-10-06:
Related discussions in #360480 seem to suggest that Noetic no longer supports tf_prefix
(but since I haven't worked with Noetic much I can't verify). This would not explain why the one world file you mentioned does not give the warning... but would explain why, in most cases, the transforms from each robot are getting published to the same tf frame name.
but as a sanity check, you could consider the somewhat tedious task of either adding a prefix
argument to each joint name
field in the turtlebot's xacro file (e.g. <joint name="$(arg prefix)*original_joint_name*" ...
. This would guarantee that the URDF passed to each robot_state_publisher
have non-conflicting frame names and should avoid the clashing you're experiencing
Comment by Roshan on 2021-10-06:
Thank you for your answer, but it seems that the tf_prefix was recently added according to this: https://github.com/ros/robot_state_publisher/pull/169
So I can understand that the person in the related discussion would have a problem, but it does not explain why the problem is still occurring. But does the tf tree look reasonable to you?
Comment by shonigmann on 2021-10-06:
As it was just merged 6 days ago, can you confirm that you are indeed using a version of robot_state_publisher
that includes the fix (>=1.15.2)?
Comment by Roshan on 2021-10-06:
Of course, excuse me for sounding like a noob but how would I do that?
Edit: Went into the package.xml of the robot_state_publisher package. It's:
<version>1.15.0</version>
Comment by shonigmann on 2021-10-06:
Assuming you're using ubuntu and you've installed robot_state_publisher
using apt
, then you can type apt list ros-noetic-robot-state-publisher
in your terminal and it should tell you the version installed. sudo apt update && sudo apt upgrade
should bring it up to date with the latest version, which indeed looks like 1.15.2
If you've built robot_state_publisher
from source, then running git rev-parse --short HEAD
in the package folder would tell you what commit you're currently using, but the simpler approach would be to just make sure you have the noetic-devel
branch checked out and git pull
Comment by Roshan on 2021-10-06:
I did sudo apt update && sudo apt upgrade
, but when I do apt list ros-noetic-robot-state-publisher
, I get:
apt list ros-noetic-robot-state-publisher
Listing... Done
ros-noetic-robot-state-publisher/focal,now 1.15.0-1focal.20210922.194208 amd64 [installed,automatic]
Meaning that it did not update?
Comment by shonigmann on 2021-10-06:
apologies - I was looking at master
instead of the releases on rosdistro. Looks like the last noetic sync was 13 days ago, so the newest changes to robot_state_publisher
have not yet been released as debians. The workaround would be to do a source install to use the newer version, while waiting for the next noetic sync (usually ever 2 weeks or so, so should be soon).
Comment by Roshan on 2021-10-06:
Alright, no problem. According to this the next sync should be in a week: https://discourse.ros.org/t/preparing-for-noetic-sync-2021-09-23/22378/2
How would I properly install robot_state_publisher from source?
Comment by shonigmann on 2021-10-06:
Something to the tune of:
cd ~/my_workspace/src
git clone https://github.com/ros/robot_state_publisher.git -b noetic-devel
cd ~/my_workspace
catkin_make
source devel/setup.bash
Comment by Roshan on 2021-10-06:
Thank you so much! It seems to finally be working without warnings and the new tf tree has three seperate trees, one that branches out from tb3_0/base_footprint, one from tb3_1/base_footprint and one from odom.
Thank you for your time, and big thanks to tfoote too.
Comment by shonigmann on 2021-10-06:
For the sake of closing out this question, I've put the relevant details in an answer below. If you can accept it and close the question, that would be appreciated