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

Transformation between two frames from unconnected trees

asked 2012-03-16 14:46:25 -0500

VN gravatar image

updated 2014-01-28 17:11:39 -0500

ngrennan gravatar image

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

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
1

answered 2012-03-18 19:06:50 -0500

tfoote gravatar image

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.

edit flag offensive delete link more
2

answered 2012-03-16 22:15:03 -0500

dornhege gravatar image

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

edit flag offensive delete link more

Question Tools

Stats

Asked: 2012-03-16 14:46:25 -0500

Seen: 3,761 times

Last updated: Mar 18 '12