Rosanswers logo


I'm trying to move my robot to some position. So I made a frame in some random postition named /posicao_objectivo and I made a simple broadcaster to set this position in reference to the frame /odom that gets set by Gazebo.

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

int main(int argc, char** argv){
  ros::init(argc, argv, "tf_broadcaster_posicaoRobot");
  ros::NodeHandle node;

  tf::TransformBroadcaster br;
  tf::Transform transform;
  ros::Rate rate(1.0);
        transform.setOrigin(  tf::Vector3(5, 0.0, 0.0) );
        transform.setRotation(tf::Quaternion(0, 0, 0, 1)       );

        br.sendTransform(tf::StampedTransform(transform, ros::Time::now(),"/odom", "/posicao_objectivo"));
  return 0;

After this I made a listener that uses the function lookuptransform to calculate the transform from the robot /base_link to my set position /posicao_objectivo created by my broadcaster.

#include <ros/ros.h>

#include <tf/transform_listener.h> #include <geometry_msgs/Twist.h>

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

ros::NodeHandle node;

ros::Publisher robot_vel =  node.advertise<geometry_msgs::Twist>("p3dx/cmd_vel", 10);

tf::TransformListener listener;

ros::Rate rate(1.0); while (node.ok()){

    tf::StampedTransform transform;
              listener.waitForTransform("/base_link", "/posicao_objectivo",
                          ros::Time(0), ros::Duration(3.0));
              listener.lookupTransform("/base_link", "/posicao_objectivo",
                                       ros::Time(0), transform);
            catch (tf::TransformException &ex) {
         geometry_msgs::Twist vel_msg;
                    vel_msg.angular.z = 0.2 * atan2(transform.getOrigin().y(),
                    vel_msg.linear.x = 0.5 * sqrt(pow(transform.getOrigin().x(), 2) +
                                                      pow(transform.getOrigin().y(), 2));

return 0;


The problem is that when I run the listener I get this error:

[ERROR] [1425495472.170621190, 132.992000000]: "posicao_objectivo" passed to lookupTransform argument source_frame does not exist.

I tried using the command: rosrun tf tf_echo odom posicao_objectivo

And it says:

Exception thrown:"posicao_objectivo" passed to lookupTransform argument source_frame does not exist. 
The current list of frames is:
Frame base_link exists with parent odom.
Frame front_sonar exists with parent base_link.
Frame p3dx_left_hubcap exists with parent p3dx_left_wheel.
Frame p3dx_right_hubcap exists with parent p3dx_right_wheel.
Frame top_plate exists with parent base_link.
Frame camera_link exists with parent Arucos.
Frame Arucos exists with parent top_plate.
Frame center_hubcap exists with parent center_wheel.
Frame lms100 exists with parent base_link.

What is confusing me Is that went I start the broadcast of my frame /posicao_objectivo the frame appears in RVIZ tree and it appears in rosrun rqt_tf_tree rqt_tf_tree. So the frame does exist, don't understand how it does not work with rosrun tf tf_echo odom posicao_objectivo.

Originally posted by End-Effector on ROS Answers with karma: 162 on 2015-03-04

Post score: 0

Original comments

Comment by End-Effector on 2015-03-05:
I did what you said, I think the problem is that the publish rate of the transform posicao_objectivo is too low. It is 1hz and the base_link has a rate of 100hz. I think this is the problem. I'm still testing. Thx you.

Comment by gpldecha on 2015-03-05:
Ok, did you manage to get it working.. also the lookupTransform take some time to pic up the transformation from /tf topic. I had the same problem before. I also changed ROS_ERROR to ROS_WARNING.

Comment by End-Effector on 2015-03-05:
I set the rate to 1000hz and I stop having problems, I was also giving was too much velocity and angle to my robot. Now it moves to a point. Thx you so much for the help.


2 Answers 2


Rosanswers logo

Hi, make sure you have no naming problem with your frames. Run: rosrun tf view_frames (/tf/Debugging). It will listen to all tf frames being published and then create a pdf. Check the pdf and make sure your target_frame and fixed_frame are present.

Originally posted by gpldecha with karma: 285 on 2015-03-05

This answer was NOT ACCEPTED on the original site

Post score: 1


Rosanswers logo

The problem was the rate of publication of the broadcasted frame. I had it to 1hz. I increased it to 1000hz and lookup started to work normally. I lowered it to 150hz I get a Warning sometimes in lookup function warning,but it works know.

Thx you all for the help.

Originally posted by End-Effector with karma: 162 on 2015-03-05

This answer was ACCEPTED on the original site

Post score: 2


Your Answer

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