[ros-users] tf to get robot position

Nicolás Alvarez Picco nicolasapicco at hotmail.com
Tue Jan 11 16:34:53 UTC 2011


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

 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osuosl.org/pipermail/ros-users/attachments/20110111/3f8c8b77/attachment-0002.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: frames.pdf
Type: application/pdf
Size: 13668 bytes
Desc: not available
URL: <http://lists.osuosl.org/pipermail/ros-users/attachments/20110111/3f8c8b77/attachment-0004.pdf>


More information about the ros-users mailing list