I am converting laser Scan points from laser frame to map frame(occupancy grid).The tf between them changes as the robot moves so I need to listen to TF every time the laser callback is called. But the tf doesn't get called every time.It is only listened to once.the code is here. the waitforTransform doesnt get called at all.
Originally posted by balakumar-s on ROS Answers with karma: 137 on 2013-11-26
Post score: 2
Original comments
Comment by BennyRe on 2013-11-26:
Do the transforms get published? Check the output of rostopic echo /tf
Comment by balakumar-s on 2013-11-26:
Tf gets published. The problem is as the mobile robot moves, the tf changes and hence during very laser callback, the tf must be listened to get the current tf. The code is using the tf which was present at the launch of the program and tf doesnt listen to it after that.
Comment by tfoote on 2013-11-27:
tf is used all the time on mobile robots. Please provide the error outputs and what you are expecting. As well as a way to reproduce the problem so we can help you.
Comment by balakumar-s on 2013-11-27:
I just had to put the tf listener inside the callback and it works. But it caches for sometime and then uses that cached tf to convert the laserscan to map. Is there a way to listen to tf in realtime? I am attaching the text file here: http://textuploader.com/d8ma
Comment by balakumar-s on 2013-11-27:
I found a solution and the problem is solved. @tfoote I am new to this, so should I close this question or type the solution as an answer and tick it?
Comment by tfoote on 2013-11-27:
You can put the answer below if you've solved it yourself. However your linked solution with the TransformListener constructed inside the callback function is very fragile and likely not to generalize. It forces the cache to rebuild in every callback. And the incoming data is in a different thead in either implementation. You will need to debug deeper to understand what is actually your problem. You're just masking it with this solution.
Comment by balakumar-s on 2013-11-27:
I forgot the basics of tf of using stamped time from laserscan. i fixed it. I will post it as an answer. Thanks !