Odometry calculated from wheel encoders is used to estimate the position of a robot. Wikipedia has a good definition. Calculating the position of a robot with two main wheels (and a third caster wheel) from the revolutions of the wheels is pretty easy using basic math. With the robot in the following image we want to calculate the new position (x,y) and angle alpha:

We know the distance both wheels traveled which is b_left and b_right. As we can see in the image both values are distances on an arc. To get an angle from them we can use the following formula for each wheel:

More specific for the left and right wheel:

But do we know the radius? No, but we do know the wheelbase (the gap between both wheels):

So now we have three formulas with three unknown variables (b_left, b_right and alpha). Using them we can rearrange them to

and we have our new angle. We can now use the trigonometric functions to calculate our position offset

With the average between the left and and right arc as radius:

By now we have calculated the new position and angle of a two wheeled robot. But my wild thumper has four wheels. So to use the math from above I need to calculate with two virtual wheels instead, which are averaged from the front and aft wheel on each side. This works fine for translation, but not for rotation:

As one can see in the image when turning at least either the two front wheels, the two aft wheels or all wheels have to slip. Vehicles with chains have the same problem. This can also not be calibrated since it changes from surface to surface.

Translation errors have a constant effect on position. 1cm error will be 1cm after driving 1m or 5m. Errors in rotation have an increasing effect on position, only 1° error in angle results in a 2cm error after 1m and nearly 10cm after 5m.

This why an additional IMU is needed for correction of the complete 2d position (x,y, angle). IMU and wheel odometry are merged with a Kalman filter.

## Discussions

## Become a Hackaday.io Member

Create an account to leave a comment. Already have an account? Log In.