# Odometry

### From Simreal

Assuming that you have wrestled the various technical issues of getting a good reading out of the encoder, you can use those readings for use in the fine art of odometry. Though odometry and mapping were mentioned in Applied Robotics, it is a topic worthy of a quick reprise here.

Odometry is the art of translating the individual wheel motions of differential (i.e. tank) drive robots into the change in position and orientation of those robots. As in all things mathematical, the odometry equations describe the behavior of an idealized robot (as shown to the right). In this ideal robot there are two infinitesimal contact points, one on each wheel where it touches the ground. In the real world, our wheels are several inches wide and there is no telling where the actual contact point is. Anyway, the space between the contact points is the width W of the robot. At the midpoint between these contacts is the center of the robot (at least, as far as the odometry is concerned).

To calculate the change in position and orientation of the robot across a given
span of time, you merely take the linear distance D_{R} and D_{L}
each wheel has traveled (calculated from the number of ticks from the encoders
and the diameter of the wheels; you figure it out!) and plug it into the
following equations.

The new orientation (which is in radians) is calculated by:

O_{T+1}= O_{T}+ (D_{R}- D_{L}) / W

The distance traveled during this time span is:

D_{T,T+1}= (D_{R}+ D_{L}) / 2

In the case of the distance traveled, we are calculating a linear approximation of a curved path. As such, the longer the interval between calculations the worse this approximation is going to be.

If you are working with a map (or are trying to build one as you travel), the new Cartesian coordinate of the robot is calculated as:

X_{T+1}= X_{T}+ D_{T,T+1}cos(O_{T+1})

Y_{T+1}= Y_{T}+ D_{T,T+1}sin(O_{T+1})

The internal ticking (from time T to time T+1, T+2, and onward into infinity) that drives the odometry can also be used to collect other impressions from the senses. These can be correlated with the robot's position in space and time, to build up a map of space and the events that occur in it.

Of course, this is all easier said than done.