Skip to content

Sensors

DIO

The RoboRIO has 10 Digital Input Output (DIO) ports that you may plug basic sensors and devices into. These can be accessed with the DigitalInput class. digitalInputDevice.get() will return some number between zero and one, depending on the sensor you are using.

DigitalInput is a simple solution for sensors like:

  • Infrared beam break sensors
  • Absolute encoders (when using CAN isn't an option)
  • Limit switches

Encoders

Encoders are sensors that measure rotation.

Absolute Encoders

Absolute encoders measure the absolute position of a shaft, meaning they can tell you the exact angle of rotation even after power loss. They are typically used for mechanisms that need to know their position at all times, such as swerve module azimuth or arms.

Relative Encoders

Relative encoders measure the change in position of a shaft, meaning they can tell you how much the shaft has rotated since the last reset. They are typically used for mechanisms that only need to know their position relative to a starting point, such as drivetrain wheels or elevators.

Most motor controllers have built-in relative encoders, such as the TalonFX's integrated encoder.

Oftentimes, it's useful to use them in conjunction with absolute encoders to provide a known starting position for relative encoders. This is because relative encoders are often more precise if a mechanism has a high reduction.

Gyroscopes

Gyroscopes measure the rate of rotation around an axis.

In FRC, most gyroscopes are 3-axis, meaning they can measure rotation around the X, Y, and Z axes. They are typically only used for drivetrains to measure the robot's heading, but can be used to detect other things with the accelerometer data.