[ros-users] tf to get robot position

Forside
Vedhæftede filer:
Indlæg som e-mail
+ (text/plain)
+ (text/html)
+ frames.pdf (application/pdf)
Slet denne besked
Besvar denne besked
Skribent: User discussions
Dato:  
Til: ros-users
Emne: [ros-users] tf to get robot position

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