Dear All, I am asking a weired question about the transform listener.
I have tried the following two code, one with lookup base_link to odom and one to look up base_link to map. The result is I can get the transform to odom but can not get the transform to map with error:
Unable to lookup transform, cache is empty, when looking up transform from frame [/base_link] to frame [/map]
For base_link to odom:
try {
listener.waitForTransform("odom", "base_link", ros::Time(0), ros::Duration(10.0) );
listener.lookupTransform("odom", "base_link", ros::Time(0), transform);
} catch (tf::TransformException ex) {
ROS_ERROR("%s",ex.what());
}
For base_link to map:
try {
listener.waitForTransform("map", "base_link", ros::Time(0), ros::Duration(10.0) );
listener.lookupTransform("map", "base_link", ros::Time(0), transform);
} catch (tf::TransformException ex) {
ROS_ERROR("%s",ex.what());
}
I have checked using the tf view_frames and the /map frame does exist and is connected with base_link. And I have also tried another method from costmap_2d_ros which can successfully loop up the map frame. See below the getRobotPose function actually did the same thing as above only without the waitForTransform, but I don't think this is the issue.
tf::Stamped robot_pose;
tf::TransformListener tf;
costmap_2d::Costmap2DROS lcr("costmap", tf);
lcr.**getRobotPose**(robot_pose);
Can anyone help advise on this why I can not use my code to look up the transformation to /map frame? I am using Groovy under Ubuntu 12.04.4 64bit
Thanks.
Edit: Attached code and tf tree


↧