This is a crash course on how to get started programming FRC. This guide is best understood if you have at least a high-level understanding of another programming language. It’s also a work in progress!

Getting Started

WPILib is a set of utilities and tools for writing robot code for FRC. It can be used from Java or C++, but bindings exist for Python and possibly other languages. This guide covers the Java version.

Install WPI with these instructions, this will install everything you need to write robot code. You may have to disable your antivirus, it will likely prevent WPI from installing properly. If you are on windows, you should also (but don’t have to) install the driver station from NI, which will allow you to control your robot and can also be used with simulation tools.

Note: Linux and Mac

If you are using Linux or Mac you cannot install the standard driver station. There are reverse-engineered driver stations available on GitHub, but these might not work and certainly are not competition legal.

Basic Programming

Quick Reference

If you need a refresher on Java syntax, see this cheat sheet.

Useful Functions

SignatureRemarksExample

WPILib uses Java 171. WPILib’s VS Code comes with tools for building and running Java programs. They can be accessed with the play button in the top right corner of the screen. If you are new to Java, Oracle provides a getting started guide, and an online playground at https://learn.java.

ALL robotis using the First Control System have 5 states:

  • Disabled: The robot is powered, but inactive.
    • A-Stopped: Identical to disabled, however the robot cannot be re-enabled until the autonomous period ends. You can trigger this state by pressing the red and yellow A-STOP button on the field.
    • E-Stopped: Identical to disabled, however the robot cannot be re-enabled. It must be power cycled to become functional again. You can trigger this state by pressing the space bar in the driver station, or by pressing the red E-STOP button on the field.
  • Autonomous: The robot will execute commands, but will not accept input. After 15 seconds the robot will transition to teleoperated state.

Command Based Programming

TODO

(Advanced) AdvantageKit Programming

TODO

Sources

  1. https://docs.wpilib.org/en/latest/docs/yearly-overview/yearly-changelog.html ↩︎