A rotary encoder is a device that is used to measure rotational motion. It can give out information about the angle and velocity of rotation. Based on the principle of operation, there are a few major types.
Uses a magnet that rotates along with the motor, and a hall effect sensor to calculate the angle and angular velocity.