0
$\begingroup$

Rosanswers logo

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 with reference to base_link (robot), the transform (transform(base_link,base_laser)) is fixed. Hence, given a scan (in base_laser), we obtain its corresponding value in base_link (robot) applying the fixed transform in correct direction.

distance from robot (wrt base_link) <- transform between base_link and base_laser <- laser scan (wrt base_laser)

When it comes to odom tutorial. The odometry is a measure of how far the robot (base_link) has traveled from its initial position (odom frame). Now, as the robot (base_link) moves, the transformation between odom frame and base_link changes. Hence, this transformation is not fixed. That sounds logical, but I am confused with the following code:

//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;

It appears now odom = odom_trans, i.e. the odometry measurement equals the transformation between the odom frame and the base_link. Now, to know the position of the robot (base_link) in the world, do we use odom only without odom_trans? Or, do we use odom_trans to know the position in the world?

position in world <- odom
position in world <- odom_trans (or)
not moving <- odom_trans <- odom (I think)

And where/how will odom_trans be used? Why do we need it, if it is the same as odom message?

The odom tutorial stopped after publishing the transform/odometry and does not show how odom and odom_trans will be used. Other tutorials assumed this fundamental understanding, which sadly I am yet to figure out.

Thanks again.


Originally posted by owh on ROS Answers with karma: 67 on 2012-03-02

Post score: 1

$\endgroup$

2 Answers 2

0
$\begingroup$

Rosanswers logo

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.


Originally posted by ahendrix with karma: 47576 on 2012-03-05

This answer was ACCEPTED on the original site

Post score: 0


Original comments

Comment by owh on 2012-03-05:
@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.

Comment by owh on 2012-03-05:
@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!

$\endgroup$
0
$\begingroup$

Rosanswers logo

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.


Originally posted by DimitriProsser with karma: 11163 on 2012-03-02

This answer was NOT ACCEPTED on the original site

Post score: 1


Original comments

Comment by owh on 2012-03-05:
@DimitriProsser Many thanks for the answer. I further elaborate my doubt in the original question.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.