Just like how humans can sense the environment around them using their hands, eyes, ears, etc., robots use sensors to detect and react to their environment. Sensors can tell a robot where its different components are (is the arm vertical? which way is the turret facing?), how fast it is moving, if it is falling over, how far away something is, how much pressure it has in its air tanks, etc. Knowing these things allows the robot to behave smarter and automate specific tasks.
Encoders are sensors that can measure the velocity or position of anything that spins, such as a wheel, winch, or driveshaft. Since almost everything on a robot is powered by an electric motor, and electric motors spin, encoders can used to sense the motion of most parts of a robot, making them some of the most useful and commonly used sensors. They can be used to measure how far the robot has driven, what angle on arm is at, or how fast a flywheel is spinning.
There are several different types of encoders, but they are all attached to something that spins, such as the output from a motor, and measure how many times it has spun, or how fast it is spinning (or both!). Encoders can be mostly divided into two classifications: absolute and relative. Relative encoders give an angle or number of rotations relative to their position when they turn on, and absolute encoders give an angle relative to the actual position of the encoder. Most encoders can also be classified as either quadrature encoders or potentiometers. Quadrature encoders are relative encoders, and can track extremely high speed rotations but don't know what direction they are facing when they first turn on. Potentiometers generally are less precise and can't handle as high of speeds, but always know what direction they are facing, even if they are turned off, moved, and turned back on. We primarily use SRX Mag Encoders, which combine a precise relative encoder with an absolute encoder. VEX sells the VersaPlanetary Integrated Encoder, which is a SRX Mag Encoder built into a gearbox stage, making it very easy to install.
Distance sensors are used to measure the distance to an object. They can be used to slow down a robot before it collides with the field, detect whether the robot successfully grabbed a game piece, among many other applications. The two primary varieties of distance sensors are infrared and ultrasonic. Ultrasonic sensors measure the time it takes for a pulse of sound to bounce off an object, and use the speed of sound to calculate the distance to that object. Infrared sensors measure how much infrared (a type of light that can't be seen by the human eye) light is reflecting off a target - the closer an object is the more light is reflected. Other types used include TOF (time of flight) sensors that have incredibly precise clocks, and work similarly to ultrasonic sensors, but using light pulses instead of sound pulses. The Sharp GP2Y0A41SK0F infrared sensor is the most commonly used.
Ultrasonic sensors are relatively inexpensive, but suffer from "noise" - they detect objects in a wide cone rather than a straight line directly in front of the sensor. When trying to detect something in front of the sensor, they will often pick up on objects off to the side, making them finicky and unreliable in the tight confines of a robot.
Infrared sensors are somewhat more expensive, but are generally more accurate and less finicky than ultrasonic sensors. However, they have one main drawback: since they measure amount of reflective light, they can measure different distances to very reflective objects, particularly white colored ones. Because of this, they work best if they can be calibrated for a specific object.
Time of flight sensors are often considerably more expensive than infrared or ultrasonic ones, but offer several benefits. They generally have a tight beam meaning they only measure the object directly in front, and you don't need to worry about whether they will be picking up on other objects nearby. Additionally they are quite accurate, even over relatively large distances. Finally, unlike infrared sensors, they are unaffected by the reflectivity of the object they are measuring.
An IMU, or inertial measurement unit, is a device that measures translational and/or rotational acceleration. The most common configuration is a 3 axis accelerometer, 3 axis gyroscope, and 3 axis magnetometer. In FRC robotics, the gyroscope is the most commonly used component of IMUs. The gyroscope allows the robot to align itself to specific angles, detect when it's tipping over, and turn precise angle for autonomous driving. The accelerometer is mainly used to detect when the robot collides with something, although it can be used for other purposes. The magnetometer can detect the direction of the Earth's magnetic field, but is almost never used by itself. Once the motors on the robot turn on, the motors' magnetic fields are so strong detect the Earth's becomes next to impossible. However, before the motors turn on but after the robot has turned on, the magnetometer can be used to keep the gyroscope calibrated.
The robot's computer, the roboRIO, comes with a built-in IMU, although it is not very good. The most common IMUs are Kauai Lab's navX-MXP and the VEX Pigeon IMU. Both are quite good, and have similar functionality.
Limit switches are sensors are trigger when something gets close to them, and are often used in pairs to mark the limits of an arm or elevator on the robot. When the limit switch sensor activates, the robot knows the arm/elevator has reached that end of its range of motion. Limit switches come in two main types: contact switches and Hall effect sensors.
Contact limit switches have a metal tab that turns on the limit switch when pressed down. They are quite cheap and easy to install, but the metal tab tends to get bent over time, and the limit switch can only be placed at the very end of the range of motion.
Hall effect sensors use the (surprise!) Hall effect to detect when a magnet is nearby. They are more expensive than contact switches, but don't wear out, and can be placed anywhere. For example, rather than using a contact switch to detect when an arm is at the very end of its range of motion, they can tell the robot when the arm is near the end and should definitely start slowing down. This makes them very useful as a backup sensor for encoders, and as a sensor to calibrate relative encoders to the right position.