0
$\begingroup$

Rosanswers logo

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?


Originally posted by akhernar on ROS Answers with karma: 3 on 2011-08-01

Post score: 0


Original comments

Comment by akhernar on 2011-08-01:
This is just the first output, i checked with view_frames and everything seems ok.

Comment by dornhege on 2011-08-01:
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.

Comment by dornhege on 2011-08-01:
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.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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


Originally posted by tfoote with karma: 58457 on 2011-08-01

This answer was ACCEPTED on the original site

Post score: 2


Original comments

Comment by dornhege on 2011-08-01:
waitForTransform

Comment by akhernar on 2011-08-01:
So do I need to insert a delay between the constructor and the call to lookupTransform? Or should I use waitForTansform?

$\endgroup$

Your Answer

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