Skip to content

Programming basics

Programming basics

FRC robots are typically programmed in Java, C++, or LabVIEW using the WPILib libraries provided by FIRST.

Control loops and modes

The robot program usually includes:

  • Disabled – robot is not allowed to move.
  • Autonomous – robot runs pre-programmed routines without driver input.
  • Teleoperated (teleop) – drivers control the robot with gamepads/joysticks.

Many teams structure code around:

  • Subsystems – code modules for mechanisms (drivetrain, intake, arm, etc.).
  • Commands – actions that use one or more subsystems (drive, shoot, follow path).

Sensors and feedback

Common sensors:

  • Encoders – measure wheel or joint rotation, used for distance and position.
  • Gyros/IMUs – measure heading and orientation, used for driving straight and path following.
  • Limit switches / beam breaks – detect end stops or game pieces.
  • Cameras – used with vision libraries (e.g., PhotonVision, Limelight) for target tracking.

Feedback control (like PID) helps mechanisms reach and hold positions, speeds, or angles.

Safety and reliability

Good practices:

  • Always honor safety interlocks (e.g., disable shooter when doors are open).
  • Add current limits and software limits to protect hardware.
  • Log important data (sensor readings, states) to help debug problems at events.