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

Rebroadcast tf transforms with different frame_id on the fly

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

Mehdi. gravatar image

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

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

odom->base_footprint

Is there something already implemented in ROS to do this?

edit retag flag offensive close merge delete

Comments

2

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 -0600 )edit

2 Answers

Sort by ยป oldest newest most voted
2

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

andreasBihlmaier gravatar image

Node for this job, I have in daily use: https://github.com/andreasBihlmaier/a...

edit flag offensive delete link more
2

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

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.

Cheers,

Rabe

#!/usr/bin/env python

import rospy
import tf

if __name__ == '__main__':
    rospy.init_node("transform_inverter")
    rospy.sleep(0.5)

    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():
        try:
            listener.waitForTransform(parent_frame, child_frame, rospy.Time.now(), rospy.Duration(2.0))
            (trans, rot) = listener.lookupTransform(child_frame, parent_frame, rospy.Time(0))
            broadcaster.sendTransform(trans,rot, rospy.Time.now(), parent_frame, new_parent_name)
        except (tf.LookupException, tf.ConnectivityException, tf.ExtrapolationException, tf.Exception):
            rospy.loginfo("Couldn't find a transform")
            continue
edit flag offensive delete link more

Question Tools

2 followers

Stats

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

Seen: 649 times

Last updated: Oct 01 '14