0
$\begingroup$

Rosanswers logo

Hi: I want to transform a point from /map frame to /base_link.

I used the following method but it didn't work out:-

tf::TransformListener listener(ros::Duration(10));
geometry_msgs::PoseStamped map_pose, base_link_pose;
<---Input map_pose here-->
listener.transformPose("base_link", map_pose, base_link_pose);

Got the following error:-

terminate called after throwing an instance of 'tf::LookupException'
  what():  Frame id /base_link does not exist! Frames (1): 
Aborted

I double checked with tf tools and my tree is well connected, only thing is /map and /base_link are from two unconnected trees, I don't know why it says "Frame /base_footprint exists with parent NO_PARENT." although it exists (checked with rviz and "rosrun tf view_frames"), suddenly it starts publishing transformation (you can see below):

$ rosrun tf tf_echo map base_link
Failure at 450.800000000
Exception thrown:Could not find a connection between '/map' and '/base_link' because they are not part of the same tree.Tf has two or more unconnected trees.
The current list of frames is:

Frame /top_plate exists with parent /base_link.
Frame /back_sonar exists with parent /base_link.
Frame /base_link exists with parent /base_footprint.
Frame /front_sonar exists with parent /base_link.
Frame /base_link_left_hubcap exists with parent /base_link_left_wheel_link.
Frame /base_link_left_wheel_link exists with parent /base_link.
Frame /base_link_right_hubcap exists with parent /base_link_right_wheel_link.
Frame /base_link_right_wheel_link exists with parent /base_link.
Frame /base_scan_link exists with parent /laser_base_link.
Frame /laser_base_link exists with parent /top_plate.
Frame /odom exists with parent /map.
Frame /map exists with parent NO_PARENT.
Frame /base_caster_support_link exists with parent /base_link.
Frame /caster_wheel_link exists with parent /base_caster_support_link.
Frame /base_footprint exists with parent NO_PARENT.

At time 451.374
- Translation: [2.048, 0.805, 0.000]
- Rotation: in Quaternion [0.000, 0.000, -0.678, 0.735]
            in RPY [0.000, 0.000, -1.491]
At time 451.924
- Translation: [2.048, 0.805, 0.000]
- Rotation: in Quaternion [0.000, 0.000, -0.678, 0.735]
            in RPY [0.000, 0.000, -1.491]
At time 452.274
- Translation: [2.048, 0.805, 0.000]
- Rotation: in Quaternion [0.000, 0.000, -0.678, 0.735]
            in RPY [0.000, 0.000, -1.491]
At time 452.874
- Translation: [2.048, 0.805, 0.000]
- Rotation: in Quaternion [0.000, 0.000, -0.678, 0.735]
            in RPY [0.000, 0.000, -1.491]
At time 453.524
- Translation: [2.048, 0.805, 0.000]
- Rotation: in Quaternion [0.000, 0.000, -0.678, 0.735]
            in RPY [0.000, 0.000, -1.491]

I googled this before asking on forum thinking that it is a basic question, should have been answered by now but no success.

Looking for help please. Thanks


Originally posted by VN on ROS Answers with karma: 373 on 2012-03-16

Post score: 2

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

When you create the TransformListener as in your code snippet, it creates a buffer and starts to listen to tf messages on the /tf topic. If you query it immediately before any tf messages are received it will report that it cannot complete the transform since it only has data from since it started listening. You need to give the buffer time to fill.

There are two common solutions to this problem. One is to use the waitForTransform method, and wait for the buffer to fill. And the second is to create the TransformListener as a member of a persistent class such that it persists the buffer.

Any way you do it, your code should be ready to catch the exception which might be caused by any number of other nodes not doing what you expect.

I highly recommend you read through the tf Tutorials They explicitly cover this sort of problem.


Originally posted by tfoote with karma: 58457 on 2012-03-18

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$
0
$\begingroup$

Rosanswers logo

You are missing odometry, i.e. /odom -> /base_footprint transforms.


Originally posted by dornhege with karma: 31395 on 2012-03-16

This answer was NOT ACCEPTED on the original site

Post score: 2

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.