Odometry and Encoders

The different types of encoders and how
odomety and encoders work. How they are used to get a robot to move around and be able to track where it is and has come from.

# Odometry

Odometry is the use of collecting data from actuators and encoders to determine position and velocity of a robot from its staring position. Odometry is a form of Dead Reckoning. Each new position is based off of the previous position. So any errors developed each time the new position I calculated are accumulated. The farther the robot has to travel the more errors it will accumulate since each new position is based off of its previous one.

## Kinematics of Odometry

Instant center is the point at which while the robot is turning that point will not move and it may or may not be connected to the robot.
The velocity of the left wheel is based off of the distance to the instant center (R), base of the robot (b) and the rate at which the robot is turning in the z direction (Wz).

(1)
$$Vl=(R-b/2)Wz$$

The velocity of the right wheel is based off of the same criteria.

(2)
$$Vr=(R+b/2)Wz$$

The overall velocity is

(3)
$$Vu=Wz*R$$

By placing the combination of equations 1 + 2 in equation 3 we obtain

(4)
$$Vu=(Vr+Vl)/2$$

By combining of equations 1 – 2 we obtain

(5)
$$Wz=(Vr-Vl)/b$$

By combining equations 1, 2 and 3 into a matrix for we achieve and to change the velocity to the angle change of the wheels you multiply the matrix by the wheel radius.

(6)
\begin{bmatrix} Vu\\Vv\\Wz \end{bmatrix} = \begin{bmatrix} 1/2 & 1/2 \\ 0 & 0 \\ -1/b & 1/b \end{bmatrix} * \begin{bmatrix} Vl \\ Vr \end{bmatrix} = \begin{bmatrix} r/2 & r/2 \\ 0 & 0 \\ -r/b & r/b \end{bmatrix} * \begin{bmatrix} thetaDot_l \\ thetaDot_r \end{bmatrix}

Then to go from the robot’s active coordinate system to a global coordinate system you need to multiply the matrix by

(7)
\begin{align} R^0_1= \begin{bmatrix} cos(theta) & -sin(theta) & 0 \\ sin(theta) & cos(theta) & 0 \\ 0 & 0 & 1 \end{bmatrix}\\ \end{align}

To obtain the final solution of

(8)
\begin{bmatrix} Vx\\Vy\\Wz \end{bmatrix} = \begin{bmatrix} cos(theta)*r/2 & cos(theta)*r/2 \\ sin(theta)*r/2 & sin(theta)*r/2 \\ -r/b & r/b \end{bmatrix} * \begin{bmatrix} thetaDot_l \\ thetaDot_r \end{bmatrix}

Then to go from velocity to position you simply integrate the formulas to obtain.

(9)
$$X = integrate Vx*dt = ʃ (cos(theta)*r/2*thetaDot_l + cos(theta)*r/2*thetaDot_r)*dt$$
(10)
$$Y = integrate Vy*dt = ʃ (sin(theta)*r/2*thetaDot_l + sin(theta)*r/2*thetaDot_r)*dt$$
(11)
$$Theta = integrate thetaDot*dt = ʃ (-r/b*thetaDot_l + r/b* thetaDot_r)*dt$$

This solution cannot be integrated normally. The only way to integrate it is to integrate numerically.

## Actuator

Actuator is a device that produces motion or an action. Typical actuators on a robot are electro-motors used to control or move the robot. Produce physical changes such as linear or angular displacement. They also modulate the rate and power associated with the changes

## Rotary Encoder

Rotary Encoder is a transducer that converts angular position of a shaft into a sequence of digital pulses. The main types of encoder are mechanical and optical.

## Mechanical Encoder

Mechanical Encoder is a cylinder that has a metal sheet that is rigidly attached to the rotating shaft. The metal sheet has pieces cut out of it and the cylinder has a pin sticking off of it. Each time the sheet makes contact with the pin and electric circuit is complete and when no touch the circuit is broken. The broken and completed circuit is converted to a binary code of on and off.

## Absolute Optical Encoder

Absolute Optical Encoder disc is made with transparent and opaque areas. A unique digital pattern corresponds to each rotational position. A light source and photo detector array reads the optical pattern that result from the disc's position at any one time. The photo detector when the light strikes it and when it does not and converts that into a binary on and off code.
Is designed for a specific number of distinct positions on the shaft, the equation for determining the positions are 2N (N is the number of tracks).

## Incremental Optical Encoder

Incremental Optical Encoder also referred to as a relative encoder, produces digital pulses as the shaft rotates, allowing relative measurement displacement. It consists of 2 sensors that are slightly offset, whose outputs are A and B. As the shaft rotates it creates lead-lag trails from the pulses and the direction the shaft is rotating can be determined. The angular speed can be determined from the sensor offset, number of pulses, and resolution of encoder.
With A=1 and B=↑ implies a clockwise rotation, and B=↓ and A=1 implies counterclockwise rotation. Incremental encoder can provide more resolution at a cheaper cost than absolute encoders. They only measure distance and cannot provide absolute position.

## Quadrature

By counting the number of pulses and knowing the resolution of the disk the angular motion can be measured. An INDEX is also a 3rd output that is used to define a full revolution and a zero point. The pulses come out for either clockwise or counterclockwise direction. As describe in Incremental Optical Encoder. There are 3 different resolutions: 1X, 2X and 4X. The 1X resolution pulses at the negative edge of the first offset encoder. The 2X resolution pulses at the positive and negative edge of the first offset encoder. The 4X resolution pulses at the positive and negative edge of the first and second offset encoder. The higher the resolution of the encoder the more accurate they become.

## Coding

Gray code is where each track of the encoder only changes one state between each count.

Binary Code is where multiple tracks can change between each count.

The gray code decreases the amount of uncertainty during transition. If the counts are not perfectly aligned then the sensor will read one changing before the other and will miss count.

## Example

How encoders work with calculating odometry on differential steer robot.
This example works with traveling over small distances. The father you go the more possible paths your able to have.

First assume our robot dimensions are:
(1/2) foot wheel diameter
3 foot wheel base
88 count encoder
Say the robot traveled 1000 counts on the right encoder and 700 on the left encoder.
Total travel time is 5 seconds

Each turn of the wheel can be calculated into a distance traveled by $2*pi*radius$ of the wheel (2*pi*(1/2)) = 3.14 feet

The right encoder made (1000/88) = 11.36
That is 11 full revolutions for 11*3.14 = 34.54 feet and .36 of a full revolution so (.36*2*pi) = 2.26 feet. Combine those 2 for a total distance traveled
Dr = 34.54+2.26 = 36.8 feet.
Velocity of the wheel
$Vr = distance/time$ = 36.8/5=7.36 feet per second

The left encoder made (700/88) = 7.95
That is 7 full revolutions for 7*3.14=21.98 feet and .95 of a full revolution so .95*2*pi=5.97 feet. Combine those 2 for a total distance traveled
DL = 21.98+5.97=27.95 feet.
Velocity of the wheel
$Vl = distance/time$ = 27.95/5=5.59 feet per second

The total distance travel then is just the average of the 2 distances
$Dt = (DL + Dr)/2$
Dt = 27.95+36.8)/2=32.375 feet
Average velocity of the robot
$V = distance/time$ = 32.375/5=6.475 feet per second

As you can tell the right wheel has traveled farther than the left wheel so the robot has turned to the left.

The average angle the robot has traveled
$theta=(RightEncoderDistance-LeftEncoderGistance)/wheel_base$
theta = (36.8-27.97)/3 = 2.95 radians

Then the distance traveled in the $x direction = Dt*sin(theta)$ and the distance traveled in the $y direction = Dt*cos(theta)$

X=32.375*sin(2.95)=6.16 feet
Y=32.375*cos(2.95)=31.78 feet

Bibliography
1. Alciatore David G., Histand Michael B. "Introduction to Mechatronics and measurement systems 3rd ed" New York: McGraw-Hill, 2007.
2. Spong Mark W., Hutchinson Seth, Vidyasagar M. "Robot Modeling and Control" John Wiley & Son, 2006.
3. "Odometry" (Jan 22 2010) Retrieved January 26, 2010 from http://en.wikipedia.org/wiki/Odometry
4. "Rotary Encoders" (Jan 25 2010) Retrieved January 26, 2010 from http://en.wikipedia.org/wiki/Rotary_encoder
Add a New Comment
page revision: 17, last edited: 05 May 2010 16:05
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License