Ask Your Question
0

tf2 buffer length setting problem

asked 2019-02-14 20:38:29 -0600

Dutch gravatar image

I'm using Kinetic on Ubuntu 16.04 and met a problem with extending tf2 buffer (roscpp).

In my header file, I defined like this:

Class A
{
private: 
    std::unique_ptr<tf2_ros::Buffer> buffer_ptr;
    std::unique_ptr<tf2_ros::TransformListener> listener_ptr;
}

Then in the source file, I have initialized them in the constructor:

A::A
{
    buffer_ptr.reset(new tf2_ros::Buffer(ros::Duration(30.0)));
    listener_ptr.reset(new tf2_ros::TransformListener(*tf_buffer_ptr));
}

When I use the rqt tf_tree to view the transformation info, I noticed that the cached buffer length is still around 10 seconds, not extended to 30 seconds as I set here...

I tried to print out the buffer length out at runtime (via GetCacheLength method), and the value is correct.

I searched a lot but found very few info on this, and I checked the tf2_ros buffer related source code didn't get any luck as well..

edit retag flag offensive close merge delete

Comments

1

I'm 99% sure that the "buffer length" shown by tf_tree is the buffer that tf_tree itself uses. It does not reflect the state of the node broadcasting the frame.

So in your case: nothing outside A would know that you're using a 30 sec long buffer.

gvdhoorn gravatar imagegvdhoorn ( 2019-02-15 05:02:21 -0600 )edit

Ahh, I misunderstood the meaning of the cache length in the tf_tree then. My program is having some network delay issue, so I would like to keep a long buffer to lower the risk of extrapolation exception, however it didn't work out and that's why I thought the parameter wasn't effective. Thank you!

Dutch gravatar imageDutch ( 2019-02-15 05:37:24 -0600 )edit

As I wrote: I'm 99% sure (from a cursory look at the code). You may want to verify yourself.

gvdhoorn gravatar imagegvdhoorn ( 2019-02-15 05:53:45 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-02-15 11:41:34 -0600

tfoote gravatar image

The tf_tree and your class are separate processes and as such have different Buffers with independent timeouts. Thus as @gvdhoorn mentions changing one does not effect the other.

Often if you are having extrapolation errors on a high latency system the most likely issue is not that the buffer is not long enough, but that the data has not arrived. Unless you have network delays longer than 10 seconds. Then increasing your buffer length will help.

But assuming that's not the case you need to make sure that transforms are available when data arrives to be processed. There's a tool called the tf2::MessageFilter that will help with this. A tutorial is here

edit flag offensive delete link more

Comments

Got it! Thank you!

Dutch gravatar imageDutch ( 2019-02-16 19:52:07 -0600 )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

Stats

Asked: 2019-02-14 20:35:25 -0600

Seen: 189 times

Last updated: Feb 15