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

tfListener can't find frames

asked 2011-08-01 07:10:25 -0500

akhernar gravatar image

updated 2014-01-28 17:10:08 -0500

ngrennan gravatar image

Hello everyone,

in reference to a previous question, I wrote this simple urdf file:

    <robot name="sonar_platform">

    <!-- base link -->
    <link name="base_link" />

    <!-- sonar-ir fixed links -->
    <link name="sonar0_link" />
    <link name="sonar1_link" /> 

    <joint name="sonar0_joint" type="fixed">
        <parent link="base_link" />
        <child link="sonar0_link" />
        <origin xyz="1 1 0" rpy="0 0 0"/>
    </joint>

    <joint name="sonar1_joint" type="fixed">
        <parent link="base_link" />
        <child link="sonar1_link" />
        <origin xyz="1 -1 0" rpy="0 0 1.57"/>
    </joint>
</robot>

Then I use robot_state_publisher to publish the trasforms to tf using a very simple launch file:

    <launch>
    <param name="robot_description" command="cat $(find sonar_array)/platform_urdf.xml" />
        <node name="robot_state_publisher" pkg="robot_state_publisher" type="state_publisher" />
</launch>

Finally, I implemented a tf listener based on the tutorial

#include <ros/ros.h>
#include <tf/transform_listener.h>

int main(int argc, char** argv){
  ros::init(argc, argv, "sonar_array");

  ros::NodeHandle node;

  tf::TransformListener listener;

  ros::Rate rate(10.0);
  while (node.ok()){
    tf::StampedTransform transform;
    try{
        listener.lookupTransform("/base_link", "/sonar0_link",  
                               ros::Time(0), transform);
    }
    catch (tf::TransformException ex){
      ROS_ERROR("%s",ex.what());
    }
}

but when I try to launch it I get the following error:

    [ERROR] [1312225092.766820278]: Frame id /base_link does not exist! When trying to transform between /sonar0_link and /base_link.
terminate called after throwing an instance of 'tf::LookupException'
  what():  Frame id /sonar0_link does not exist! When trying to transform between /sonar0_link and /base_link.
Aborted

While, if I subscribe the /tf topic i can correctly see the transforms I defined:

    transforms: 
  - 
    header: 
      seq: 0
      stamp: 
        secs: 1312225269
        nsecs: 108000004
      frame_id: /base_link
    child_frame_id: /sonar0_link
    transform: 
      translation: 
        x: 1.0
        y: 1.0
        z: 0.0
      rotation: 
        x: 0.0
        y: 0.0
        z: 0.0
        w: 1.0
  - 
    header: 
      seq: 0
      stamp: 
        secs: 1312225269
        nsecs: 108000004
      frame_id: /base_link
    child_frame_id: /sonar1_link
    transform: 
      translation: 
        x: 1.0
        y: -1.0
        z: 0.0
      rotation: 
        x: 0.0
        y: 0.0
        z: 0.706825181105
        w: 0.707388269167
---

Any ideas on what's going on?

edit retag flag offensive close merge delete

Comments

Just a note: You don't need the cat command for the param. Check the ros param syntax for roslaunch, there is an option to load files.
dornhege gravatar image dornhege  ( 2011-08-01 07:50:48 -0500 )edit
One more thing: Is the output you posted just the first output or the total output over time? rosrun tf view_frames can help you get some information.
dornhege gravatar image dornhege  ( 2011-08-01 07:52:10 -0500 )edit
This is just the first output, i checked with view_frames and everything seems ok.
akhernar gravatar image akhernar  ( 2011-08-01 19:29:57 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
2

answered 2011-08-01 09:27:07 -0500

tfoote gravatar image

I would expect it to fail the first couple times through the loop until the transformListener has built up a buffer of data and then start working.

The transformListener subscribes to the /tf topic on construction and cannot provide lookups until it has received enough messages to build up it's tree.

This is at the bottom of this tutorial

edit flag offensive delete link more

Comments

So do I need to insert a delay between the constructor and the call to lookupTransform? Or should I use waitForTansform?
akhernar gravatar image akhernar  ( 2011-08-01 19:29:21 -0500 )edit
waitForTransform
dornhege gravatar image dornhege  ( 2011-08-01 22:00:21 -0500 )edit

Question Tools

Stats

Asked: 2011-08-01 07:10:25 -0500

Seen: 2,220 times

Last updated: Aug 01 '11