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

Rebroadcast tf transforms with different frame_id on the fly

asked 2014-09-25 21:20:18 -0500

Mehdi. gravatar image

updated 2014-09-25 21:44:34 -0500

Due to some nomenclature difference between some packages and some simulator (especially considering tf transforms) I am looking for a nice way to change the frame_id and child_frame_id of some tf transforms and republish them directly, without having to touch the source code of any package. I thought about subscribing to /tf and then checking frame_id of each incoming transform. If it is the frame_id i need then create a new transform with the same translation and rotation data but with different frames and broadcast it. For example I have a transform being published by STDR (new 2d simulator)

map_static-> robot0

I want to rebroadcast it to


Is there something already implemented in ROS to do this?

edit retag flag offensive close merge delete



You'll probably have to write that yourself, or reconfigure the frame names in the navigation stack.

ahendrix gravatar image ahendrix  ( 2014-09-25 22:54:04 -0500 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2014-09-26 02:06:37 -0500

Rabe gravatar image

Here is my Code, which takes a transform A=>B and republishes it to B=>A_new. I used it to make markers, which appear as children of the camera, a parent of the camera.

Just change the values.



#!/usr/bin/env python

import rospy
import tf

if __name__ == '__main__':

    child_frame = rospy.get_param("~child_frame")
    parent_frame = rospy.get_param("~parent_frame")
    new_parent_name = rospy.get_param("~new_parent_frame")

    listener = tf.TransformListener()
    broadcaster = tf.TransformBroadcaster()
    rate = rospy.Rate(100)

    while not rospy.is_shutdown():
            listener.waitForTransform(parent_frame, child_frame,, rospy.Duration(2.0))
            (trans, rot) = listener.lookupTransform(child_frame, parent_frame, rospy.Time(0))
            broadcaster.sendTransform(trans,rot,, parent_frame, new_parent_name)
        except (tf.LookupException, tf.ConnectivityException, tf.ExtrapolationException, tf.Exception):
            rospy.loginfo("Couldn't find a transform")
edit flag offensive delete link more

answered 2014-10-01 07:57:26 -0500

andreasBihlmaier gravatar image

Node for this job, I have in daily use:

edit flag offensive delete link more

Question Tools



Asked: 2014-09-25 21:20:18 -0500

Seen: 609 times

Last updated: Oct 01 '14