RobotSetup Odemetry tutorial tf confusion

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.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

//next, we'll publish the odometry message over ROS
nav_msgs::Odometry 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.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 ...

edit retag close merge delete

Sort by » oldest newest most voted

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.

more

@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.

( 2012-03-05 19:30:22 -0500 )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!

( 2012-03-05 22:50:03 -0500 )edit

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.

more

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

( 2012-03-05 18:32:10 -0500 )edit