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

Listening to multiple tf transforms in bag file

asked 2013-03-13 06:21:52 -0600

updated 2014-01-28 17:15:39 -0600

ngrennan gravatar image

Hi everybody,

My setup : Ubuntu 12.10, ROS Groovy, laptop with i7 CPU, and 6GB of RAM.

My goal : from a rosbag, being able to write certain transforms (currently, the ones from the openni_tracker (a modified version)) into a txt file, with timestamps.

My problem : based on the tf tutorial on a TfListener, I listened to tf, and tried to write only the part interesting me. Moreover, all the frame I want to write are not always published.

My code snipet si something like that :

In main,

  • initialize the ros node
  • create the Tf Listener
  • while the node is ok

    for all the possible users I am looking to

    if listener.canTransform,

    time_of_my_user = ros::Time::now();

    for all joints

    waitforTransform(time_of_my_user),lookupTransform(time_of_my_user), Write in a txt file

The problem is that I am missing a LOT of transforms. I was thinking it might be because my loops doesn't go fast enought. Thus I tried, when playing the bag file, to use the option "-r 0.1". But in this case, I don't have anything written at all.

May someone enlighten me of his/her knowledge about tf, as I am quite sure I am missing something (maybe about the lookupTransform ?). Or give me another solution in order to be able to write a list of transformations into a txt file (I was maybe thinking about a subscriber to tf ?)...

If needed, I can provide the exact code.

Thanks in advance, Bests regards,

Steph

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2013-03-13 06:51:57 -0600

Ben_S gravatar image

(I was maybe thinking about a subscriber to tf ?)

That would be my suggestion and should be the easiest way to do it. If you are using multiple waitForTransform in a serial fashion, i would guess, that you will miss all messages published in the meantime, until the desired transform arrives.

Think about the following case: Transforms are published in order of a, b, c, a, b, c, ... You start with waitForTransform(c) -> you will miss a, b and finaly get c. Next you wait for b and miss one a transform. After that you will listen for a, but miss another c in the meantime.

Hope my understanding of this matter is correct, cant give you any guaranty. ;)

edit flag offensive delete link more

Comments

Yes, I though about the fact of "missing", so I removed the "waitForTransform". But even if it was filling my txt file with incoherent data (I mean that c was having the same values as a and b), I did not have that much more data. However, I guess the Subscriber would be a better way. Thanks :-)

Stephane.M gravatar image Stephane.M  ( 2013-03-13 06:54:53 -0600 )edit

But I have a last questio nfor you then : In my case, except from the waitForTransform, what is the main difference between listener and subscriber ? I guess it is linked to the callBack function, but my knowledge in that matter is quite poor, thus my understanding poorer... Thanks in advance !

Stephane.M gravatar image Stephane.M  ( 2013-03-13 06:56:24 -0600 )edit
1

I think the transform listener processes all the tf messages in the background and does some internal caching and processing, that allows you to lookup particluar transforms at any given timestamp (within the caching period). A subscriber lets you do all the work for yourself. :)

Ben_S gravatar image Ben_S  ( 2013-03-13 07:02:37 -0600 )edit

Ok, I though in the same way. But thus any idea why in my case the subscriber would be "faster" than the listener ? (In fact I was starting to program with the subscriber when I told myself : no the listener should be better for tf...)

Stephane.M gravatar image Stephane.M  ( 2013-03-13 07:04:55 -0600 )edit

With a custom subscriber you will get every tf message exactly once. No need to manually test for specific transforms. I dont think that the listener allows you to access single messages. So you have to do some sampling with very high frequencies to not miss any messages.

Ben_S gravatar image Ben_S  ( 2013-03-13 07:24:05 -0600 )edit
0

answered 2013-03-13 06:51:41 -0600

updated 2013-03-13 06:52:10 -0600

Ok,

so an easy solution someone just gave me :

rostopic echo -p /tf > output.txt

Then use Matlab/Octave to sort out the transforms I am really interested in.

(But I am still interested if anyone has a solution for why my previous idea was not working well).

Bests,

Steph

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-03-13 06:21:52 -0600

Seen: 1,293 times

Last updated: Mar 13 '13