Ask Your Question
1

RobotSetup Odemetry tutorial tf confusion

asked 2012-03-02 00:09:02 -0600

owh gravatar image

updated 2012-03-05 19:29:08 -0600

After went through tf tutorial, I thought the transformation between two frames of a shall be fixed.

In the odometry tutorial in navigation/Tutorials/RobotSetup/Odom, the transformation is following the changes in odometry readings (x,y,th). I am lost here. I can't visualise "odometry frame". I was expecting that the odometry readings be used without any transform, i.e. if it says x=2m, y=1m, z=0m, th=1rad, then that indicates the position of the base_link, provided the odometry was initialised at the beginning. I am surely terribly wrong in this. I hope some one can help point me to the right direction.

Thanks.

EDIT 1:

@DimitriProsser Many thanks for the explanation.

If the odom transform was published once at startup, then I might understand it fixes the relationship between the odom measurements and world. However, in the navigation/Tutorials/RobotSetup/Odom, the odom transform is between odom and base_link, and it is in the while loop as below:

  ros::Rate r(1.0);
  while(n.ok()){
    current_time = ros::Time::now();

    //compute odometry in a typical way given the velocities of the robot
    double dt = (current_time - last_time).toSec();
    double delta_x = (vx * cos(th) - vy * sin(th)) * dt;
    double delta_y = (vx * sin(th) + vy * cos(th)) * dt;
    double delta_th = vth * dt;

    x += delta_x;
    y += delta_y;
    th += delta_th;

    //since all odometry is 6DOF we'll need a quaternion created from yaw
    geometry_msgs::Quaternion odom_quat = tf::createQuaternionMsgFromYaw(th);

    //first, we'll publish the transform over tf
    geometry_msgs::TransformStamped odom_trans;
    odom_trans.header.stamp = current_time;
    odom_trans.header.frame_id = "odom";
    odom_trans.child_frame_id = "base_link";

    odom_trans.transform.translation.x = x;
    odom_trans.transform.translation.y = y;
    odom_trans.transform.translation.z = 0.0;
    odom_trans.transform.rotation = odom_quat;

    //send the transform
    odom_broadcaster.sendTransform(odom_trans);

    //next, we'll publish the odometry message over ROS
    nav_msgs::Odometry odom;
    odom.header.stamp = current_time;
    odom.header.frame_id = "odom";

    //set the position
    odom.pose.pose.position.x = x;
    odom.pose.pose.position.y = y;
    odom.pose.pose.position.z = 0.0;
    odom.pose.pose.orientation = odom_quat;

    //set the velocity
    odom.child_frame_id = "base_link";
    odom.twist.twist.linear.x = vx;
    odom.twist.twist.linear.y = vy;
    odom.twist.twist.angular.z = vth;

    //publish the message
    odom_pub.publish(odom);

    last_time = current_time;
    r.sleep();
  }

May be I am unable to clearly explain my doubt (my wrong understanding). I am relating this to the explanation in navigation/Tutorials/RobotSetup/TF. I assume odometry is a sensor (encoder) like a laser range finder, hence a transform from odom frame to the base_link frame should be fixed just like the transform from base_laser to base_link. Where do I go wrong?

Thanks again.

EDIT 2:

@ahendrix Many thanks for the explanation. My understanding of "transform" has been wrong. I am thinking along this way now:

In the tf tutorial, the scan (laser) is a measure of distance (of points) from the robot (base_link). Since scan is with reference to lrf (base_laser), it has to be transformed to with reference to robot position (base_link). Since base_laser (lrf) is always fixed ... (more)

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2012-03-05 17:50:05 -0600

ahendrix gravatar image

updated 2012-03-05 20:08:49 -0600

Transforms are not required to be fixed; they can be variable, such as the relationship between the robot and the world, or the position of a joint in an arm.

The odom frame represents the starting point of the robot, and the transform to base_link represents the current position of the robot as measured by odometry.

[UPDATE 1]

The nav_msgs/Odometry message (odom variable) is used by the base local planner in the navigation stack to plan the next few seconds of the robot's trajectory; it contains additional information about the motion of the robot such as velocity that helps the planner achieve smoother trajectories.

The odom frame (odom_trans variable) can be used when you want to transform sensor measurements into a stationary frame. It is also used as the basis for the map frame when using AMCL for localization.

edit flag offensive delete link more

Comments

@ahendrix Many thanks for the reply. I am slowly getting it, but my sense of direction has been very poor. I further elaborate my doubt in my original question.

owh gravatar imageowh ( 2012-03-05 19:30:22 -0600 )edit

@ahendrix Thank you very much! I kinda get the idea, I hope. I will be learning more on navigation stuff and this initial clarification will help a great deal. Thanks again!

owh gravatar imageowh ( 2012-03-05 22:50:03 -0600 )edit
1

answered 2012-03-02 02:48:45 -0600

DimitriProsser gravatar image

The odometry measurements are a measure of how far the robot has traveled with respect to the /odom frame. The point of odometry messages is to give a measure of the distance the robot has traveled. Using transforms, you can then publish a transform from the odometry frame (typically where the robot was initialized) to some fixed frame (/world or /map) which marks a known, fixed location in space. Thus, you then will have a transform from your fixed point to the initial location of the robot, and then you will publish messages and transforms that will describe the transform from the /odom frame to /base_link frame.

edit flag offensive delete link more

Comments

@DimitriProsser Many thanks for the answer. I further elaborate my doubt in the original question.

owh gravatar imageowh ( 2012-03-05 18:32:10 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2012-03-02 00:09:02 -0600

Seen: 2,152 times

Last updated: Mar 05 '12