Ask Your Question
0

Difference in CPU% between static_transform_publisher and tf::TransformBroadcaster?

asked 2017-06-06 10:00:49 -0500

dieg0- gravatar image

updated 2017-06-06 10:02:03 -0500

Hi everyone! When broadcasting tfs, is there a difference between running static_transform_publisher or broadcasting via tf::TransformBroadcaster in terms of computational resources? When directly running the static_transform_publisher, the period parameter defines how often the transform is sent, but I don’t think something similar is possible when using the sendTransform() method in code.

I have certain launch file that uses three static_transform_publishers. I have tried broadcasting them via code instead, but when doing this, my CPU usage spikes quite notoriously.

For some practical reasons I would like to do this in code rather than in the launch file. Though if the same behaviour is not achievable, I would of course settle for the latter.

PS. I am using rospy.

Thank you very much in advance! Diego

edit retag flag offensive close merge delete

Comments

Can you show the code doing the tf broadcasting?

lucasw gravatar image lucasw  ( 2017-06-06 15:26:34 -0500 )edit

1 Answer

Sort by » oldest newest most voted
2

answered 2017-06-06 17:53:48 -0500

tfoote gravatar image

sendTransform does not have a parameter for the period because it only sends once immediately. If you want to publish a constant frame you need to do so inside a loop. However even if you're doing that it should not cause CPU usage spikes. It's just sending a relatively small message. And if as your question implies it's only being sent once. It definitely isn't the cause of your CPU spikes.

Quite possibly your problem is actually that the transform becomes unavailable and some code is trying to buffer or try to transform when the tf information is unavailable.

There's also a tf::StaticTransformBroadcaster. However, I'd strongly recommend moving to the tf2 static transform publisher. In tf2 static transforms are sent in a separate channel and designed to send only once using a latched publisher. So they incur as little CPU as possible. This is exactly what they were designed for.

edit flag offensive delete link more

Comments

Thank you! You made me realize the incredibly silly problem with my code. My Broadcasters were running in a 'while not rospy.is_shutdown()' loop without a fixed rate, and were therefore being sent very, very often.. Now it works fine. And I am now reading about tf2_ros::StaticTransformBroadcaster.

dieg0- gravatar image dieg0-  ( 2017-06-07 03:17:45 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2017-06-06 10:00:49 -0500

Seen: 606 times

Last updated: Jun 06 '17