Tf tree for multiple turtlebots
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/turtle....
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> ...
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.
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
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 ...(more)
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 eachjoint 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 eachrobot_state_publisher
have non-conflicting frame names and should avoid the clashing you're experiencingThank you for your answer, but it seems that the tf_prefix was recently added according to this: https://github.com/ros/robot_state_pu... 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?
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)?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:
Assuming you're using ubuntu and you've installed
robot_state_publisher
usingapt
, then you can typeapt 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.2If you've built
robot_state_publisher
from source, then runninggit 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 thenoetic-devel
branch checked out andgit pull
I did
sudo apt update && sudo apt upgrade
, but when I doapt list ros-noetic-robot-state-publisher
, I get:Meaning that it did not update?