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

tf tutorials: static TransformBroadcaster [closed]

asked 2014-07-02 19:54:10 -0500

emacsd gravatar image

updated 2014-07-02 20:04:10 -0500

Hi everyone

I'm trying to understand the reasons of using 'static' tf transformBroadcaster (static tf::TransformBroadcaster br;) in the tf tutorials page ( ). I understand what does a static member do, but I really cannot understand the reasons of using it in that example!

Thank you in advance!

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by emacsd
close date 2014-07-05 00:00:05.292746

1 Answer

Sort by ยป oldest newest most voted

answered 2014-07-03 03:30:06 -0500

Tom Moore gravatar image

Without knowing for certain, there may be some initialization procedures in the TransformBroadcaster that require a non-trivial amount of time. In that event, you don't want to initialize the TransformBroadcaster every time poseCallback is called. You therefore can either declare the TransformBroadcaster as a global variable (or a class member, if using a class), or you can just make it static.

edit flag offensive delete link more


@tom: Thank you for your answer, I was thinking, somehow, similar to what you mentioned. However, I tried to remove the 'static' keyword and declare it as a global object, but I keep getting this error: > [ERROR] [1404402091.015426379]: "turtle2" passed to lookupTransform argument target_frame does not exist.

emacsd gravatar image emacsd  ( 2014-07-03 10:46:01 -0500 )edit

It takes time to initialize the ROS topics which is why you don't want it to be dynamically created every time. The recommended pattern is to make the broadcaster a member of a class.

tfoote gravatar image tfoote  ( 2014-07-03 12:27:31 -0500 )edit

@tfoote; Thank you very much! I cannot believe it that I didn't think about the initialization time. Thanks again and I really appreciate your answer. I spent so much time to figure it out.

emacsd gravatar image emacsd  ( 2014-07-03 12:40:02 -0500 )edit

Question Tools

1 follower


Asked: 2014-07-02 19:54:10 -0500

Seen: 568 times

Last updated: Jul 03 '14