Shaft Encoding
Shaft encoders measure the angular rotation of an axle providing position and/or velocity info. To detect a complete or partial rotation, we have to mark the turning element. This is usually done by attaching a round disk to the shaft, and cutting notches into it. A light emitter and detector are placed on each side of the disk, so that as the notch passes between them, the light passes, and is detected; where there is no notch in the disk, no light passes. Usually, many notches are cut into the disk, and the light hits impacting the detector are counted.

An alternative to cutting notches in the disk is to paint the disk with black and white wedges, and measure the reflectance. In this case, the emitter and the detector are on the same side of the disk. In either case, the output of the sensor is going to be a wave function of the light intensity. This can then be processes to produce the speed, by counting the peaks of the waves.

Shaft encoding measures both position and rotational velocity, by subtracting the difference in the position readings after each time interval. Velocity, on the other hand, tells us how fast a robot is moving, or if it is moving at all.

Shaft Encoders
There are multiple ways to use this measure the speed of a driven (active) wheel, use a passive wheel that is dragged by the robot (measure forward progress) We can combine the position and velocity information to do more sophisticated things:
1. move in a straight line
2. rotate by an exact amount.

Note, however, that doing such things is quite difficult, because wheels tend to slip (effector noise and error) and slide and there is usually some slop and backlash in the gearing mechanism. Shaft encoders can provide feedback to correct the errors, but having some error is unavoidable.

Ultrasonic Sensors
Ultrasonic sensors are used in wide range due to some considerations:
• very cheap in compare with other type of detectors.
• relatively have a good sensitivity
• available in different shapes.

Ultrasonic sensors measure the distance or presence of target objects by sending a pulsed ultrasound wave at the object and then measuring the time for the sound echo to return. Knowing the speed of sound, the
sensor can determine the distance of the object.

Ultrasonic Distance Sensing
Ultrasound sensing is based on the time-of-flight principle. The emitter produces a sonar of sound, which travels away from the source, and, if it encounters barriers, reflects from them and returns to the
microphone. The amount of time it takes for the sound beam to come back is tracked and is used to compute the distance the sound traveled.
Sound wave travels with is a constant speed, which varies slightly based on ambient temperature. At room temperature, sound travels at 1.12 feet per millisecond.

Ultrasonic Sensors Applications
*Long sonar readings can be very inaccurate, as they may result from
false rather than accurate reflections For example, a robot approaching a wall at a steep angle may not see the wall at all, and collide with it!
*Sonar sensors have been successfully used for very sophisticated robotics applications, including terrain and indoor mapping, and remain a very popular sensor choice in mobile robotics.

One can find ultrasound used in a variety of other applications; the best known one is ranging in submarines. The sonars there have much more focused and have longer-range beams. Simpler and more mundane applications involve automated “tapemeasures”, height measures, burglar alarms, etc.