TransformListener not working in nodelet
Hi,
I am porting a node to a nodelet and having trouble with the TransformListener. In the node it works, but not in the nodelet.
Overview:
- TransformListener is a member variable of the nodelet class
- after receiving the first pointcloud the TransformListener is tested:
if( !tfListener->waitForTransform(target_frame_id, cloud->header.frame_id, cloud->header.stamp, ros::Duration(10.0), ros::Duration(0.1), error) ) ...
No exception is thrown, it does simply fail. If I try a tfListener->lookupTransform afterwards it will throw an exception: Unable to lookup transform, cache is empty, when looking up transform from frame [/velodyne] to frame [/world] A call to tfListener->getCacheLength() return 10 seconds, a tfPrefix is not set, an tfListener->getAllFrames() also returns all frames correctly.
The things I tried so far:
making the tfListener a boost shared pointer initialized in onInit() with different NodeHandles an Cache lengths.
Inserting a sleep() for 5-10 seconds after creating the Listener and before testing the Listener
- Making a loop with intermitting ros::spinOnce()-Calls for 5-10 seconds
- Different Durations for timeout and polling intervall in the waitForTransform()
As stated above, a node with a TransformListener() running parallel to the nodelets has no problem looking up the transform an all calls of getCacheLength(), getAllFrames() give identical results to the nodelet-TransformListener.
Anyone any suggestions?
Regards, Torsten Fiolka
Try setting the time stamp to 0 instead of using
cloud->header.stamp
to check if there is any transform between your source frame and target frame.