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

Error tf2_ros StaticTransformBroadcaster API in Python

asked 2015-02-17 22:17:57 -0600

rnunziata gravatar image

updated 2015-02-24 15:52:53 -0600

demmeln gravatar image

Update: In an attempt to get around losing the ability to pub latch transforms in the API in python I have tried doing the following which does not seem to work. Anyone have a way to do this? And in general does anyone know why there is no StaticTransformBroadcaster.py in Indigo why was this not implemented?

def publishLatchTransforms(self):
     self.pub_tf = rospy.Publisher("/tf_static", TFMessage , queue_size=1)

     # Send static link transforms
     msg = TransformStamped()

     msg.header.stamp = rospy.Time.now()
     msg.transform.rotation.x =  0.0
     msg.transform.rotation.y =  0.0
     msg.transform.rotation.z =  0.0
     msg.transform.rotation.w =  1 
     msg.header.frame_id = "base_footprint"   
     msg.transform.translation.x = 0.
      msg.transform.translation.y = 0.0
     msg.transform.translation.z = 0.1
     msg.child_frame_id = "base_link"
     self.pub_tf.publish([msg])

How do you call static transform broadcaster in Python? I can do this in cpp but I can not seem to get this to work in python.

thanks.

#include <tf2_ros/static_transform_broadcaster .h>

ok in cpp but

from tf2_ros import static_transform_broadcaster

fails in python unable to find import
   Static_Transform_Broadcaster()  fails invalid gobal

OR

How can I send a transform to the tf/static topic using sendTransform as a work around. Rather then using the static transform broadcaster in the launch file.

edit retag flag offensive close merge delete

3 Answers

Sort by » oldest newest most voted
0

answered 2015-02-24 02:42:41 -0600

updated 2015-02-24 02:43:49 -0600

You code looks okay. Did you try adding latch=true to your rospy.Publisher() ? If that doesn't work, maybe this is the problem: http://answers.ros.org/question/84336... . Try adding a sleep between creating the publisher and sending the msg.

edit flag offensive delete link more

Comments

Putting a sleep between did not work. The latch worked but it only transmits the last transform on the topic so if I send two the first is ignored even if I use separate publishers. Would sending an array work?

rnunziata gravatar image rnunziata  ( 2015-02-24 08:32:04 -0600 )edit

So publishing array with latch = yes works fine. thanks

rnunziata gravatar image rnunziata  ( 2015-02-24 18:43:56 -0600 )edit
0

answered 2015-02-24 15:06:33 -0600

tfoote gravatar image

Publishing an array of tf_messages on a latched topic is the correct way to publish multiple static transforms.

edit flag offensive delete link more

Comments

yup...thanks works just fine.

rnunziata gravatar image rnunziata  ( 2015-02-24 18:42:50 -0600 )edit
0

answered 2015-02-21 14:59:37 -0600

rnunziata gravatar image

This code works ...though it is not a direct solution to the missing API.

   node = roslaunch.core.Node("tf", "static_transform_publisher",  "tran_4",   args="-0.13 0.13 0.1 0 0 0 1 base_link right_wheel 100")
     launch = roslaunch.scriptapi.ROSLaunch()
     launch.start()
     process = launch.launch(node)
edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-02-17 22:17:57 -0600

Seen: 2,928 times

Last updated: Feb 24 '15