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

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

(2)The overall velocity is

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

(4)By combining of equations 1 – 2 we obtain

(5)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)Then to go from the robot’s active coordinate system to a global coordinate system you need to multiply the matrix by

(7)To obtain the final solution of

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

(9)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 2^{N} (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