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

Publishing every frame of a turtlebot3 waffle under a namespace

asked 2021-05-31 00:53:52 -0500

gts_63 gravatar image

Hello,

I'm working on ros noetic on Ubuntu 20.04, and I'm trying to get my robot_state_publisher node to have each frame published with "/tb3_0" before it. For example, instead of the frames being /odom, /base_footprint, /base_link, etc.. it would be /tb3_0/odom, /tb3_0/base_footprint, and /tb3_0/base_link. Below is my launch file:

<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="third_tb3"  default="tb3_2"/>

  <arg name="first_tb3_x_pos" default="-7.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"/>

  <include file="$(find gazebo_ros)/launch/empty_world.launch">
    <arg name="world_name" value="$(find turtlebot3_gazebo)/worlds/turtlebot3_house.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> 

  <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)" />
    <remap from="tf" to="tf_old"/>
  </node>

  <node pkg="tf" type="tf_remap" name="tf_remapper" output="screen">
    <rosparam param="mappings">
      [{old: odom, new: tb3_0/odom}, {old: base_footprint, new: tb3_0/base_footprint},
       {old: base_link, new: tb3_0/base_link}, {old: base_scan, new: tb3_0/base_scan}, 
       {old: caster_left_link, new: tb3_0/caster_left_link}, 
       {old: caster_right_link, new: tb3_0/caster_right_link},
       {old: imu_link, new: tb3_0/imu_link}, 
       {old: wheel_left_link, new: tb3_0/wheel_left_link}, 
       {old: wheel_right_link, new: tb3_0/wheel_right_link},
       {old: camera_link, new: tb3_0/camera_link}, 
       {old: camera_depth_frame, new: tb3_0/camera_depth_frame},
       {old: camera_depth_optical_frame, new: tb3_0/camera_depth_optical_frame},
       {old: camera_rgb_frame, new: tb3_0/camera_rgb_frame}, 
       {old: camera_rgb_optical_frame, new: tb3_0/camera_rgb_optical_frame}]
    </rosparam>
  </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" />

</launch>

From the tf wiki(http://wiki.ros.org/tf#tf_remap), it says for to remap tf frames from an old name to a new name, it subscribes to /tf_old, so in my /robot_state_publisher node, I remap from "tf" to "tf_old" so the tf_remap can listen to this topic and rename the frames. However, when I provide the list of frames to rename, my tf tree output looks like the following:

output of $ rosrun tf view_frames

It seems to only rename base_link to tb3_0/base_link renamed by the tf_remapper node but all the other frames have the same name and only have the wheel links attached to it(without their names changed). I was wondering how I can solve this issue.

I also wanted to do this in a group namespace, because I ultimately want 3 robots all publishing their unique frames under namespaces, and I also want to include a robot that has non-static joints added(will use a joint_state_publisher for each). However, if I try this ... (more)

edit retag flag offensive close merge delete

Comments

I'm new to this community and I'm wondering how long it takes for the posts to get approved. I asked this two days ago but it still says it's awaiting moderation.

gts_63 gravatar image gts_63  ( 2021-06-01 21:11:41 -0500 )edit

Sorry about this! The process is like this: All posts by new users have to be approved by a moderator (to fight spam). I've just done that for your post. From now on, your posts will automatically skip the moderation queue. Unfortunately, there is no coordination between the moderators. Apparently, there used to be someone (I don't know who, but I have a guess) that used to approve all the posts regularly, and they seem to have stopped doing that a couple of weeks ago. I'll see if I can work it into my daily schedule.

Martin Günther gravatar image Martin Günther  ( 2021-06-02 02:48:28 -0500 )edit

1 Answer

Sort by » oldest newest most voted
1

answered 2021-06-02 02:41:30 -0500

In the original tf library, there was an easy way to do this: All you had to do was set the parameter tf_prefix, and all nodes would automatically respect that (or at least were supposed to respect it). Unfortunately, tf_prefix is deprecated, and there is no replacement for it.

This means that you have to put the prefix in everything yourself. In particular, you have to update your *.urdf.xacro file so that the links are already renamed in the URDF. Here's an example how I did it for my robot:

https://github.com/DFKI-NI/mobipick/b...

https://github.com/DFKI-NI/mobipick/b...

https://github.com/DFKI-NI/mobipick/b...

Unfortunately, I don't see an easy way to do it with the official turtlebot3_description. I might be missing something, so you'll have to keep on searching.

edit flag offensive delete link more

Comments

Thank you, this was a little tedious but it did resolve my issue by adding a prefix to every link name in the urdf files.

gts_63 gravatar image gts_63  ( 2021-06-03 20:45:21 -0500 )edit

Great! Don't forget to mark the answer as "correct" (green checkmark button) if it resolved your question.

Martin Günther gravatar image Martin Günther  ( 2021-06-04 02:45:04 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2021-05-31 00:53:52 -0500

Seen: 304 times

Last updated: Jun 02 '21