Tully,

Thanks for the info, now is working, I was using ros::Time::now() because the tf tutorial says this is better.

Nicolas


From: tfoote@willowgarage.com
Date: Tue, 11 Jan 2011 11:44:10 -0800
To: ros-users@code.ros.org
Subject: Re: [ros-users] tf to get robot position

Hi Nicolas,

If you print out the exception string we can help you more.  I suspect that it might show you that your query is too early instead of too late. 

If you are not particular about exactly when the transform is looked up I would suggest that you use ros::Time(0), this is a special value which will lookup to the latest available time.  Instead of ros::Time::now() which forces a value. 

Tully

2011/1/11 Nicolás Alvarez Picco <nicolasapicco@hotmail.com>
Hi!

I am using this code to get the position of my robo:

pose2d_t ROS_Link::get_robot_pose(){
  pose2d_t ret;
 
  tf::StampedTransform transform;
  geometry_msgs::TransformStamped msg;

  std::string source_frame("/base_link");//!!este y el de abajo van!!!
  std::string target_frame("/map"); //!! Ver q va bien aca!

  try{
     ros::Time now = ros::Time::now();
    
     tl->waitForTransform(target_frame, source_frame, now, ros::Duration(1.0));

     tl->lookupTransform(target_frame, source_frame, ros::Time::now(), transform);
  }
  catch(...){
    ROS_ERROR("Error obtaining robot pose");
    return ret;
  }

  tf::transformStampedTFToMsg(transform, msg);

  ret.x = msg.transform.translation.x;
  ret.y = msg.transform.translation.y;
  ret.yaw = tf::getYaw(msg.transform.rotation);//!! WHY??

  return ret;
}

the robot is a a model from videre erratic simulated in gazebo. I am attaching the tf tree with the frecuencies. But every time I run my program I have the ROS_ERROR("Error obtaining robot pose"); and the time to time I get the position.
So as I can see it is a problem of the speed of the transfomation. What can I do I have tried with more time in the wait for transform line?

Thanks

Nicolas

_______________________________________________
ros-users mailing list
ros-users@code.ros.org
https://code.ros.org/mailman/listinfo/ros-users




--
Tully Foote
Systems Engineer
Willow Garage, Inc.
tfoote@willowgarage.com
(650) 475-2827

_______________________________________________ ros-users mailing list ros-users@code.ros.org https://code.ros.org/mailman/listinfo/ros-users