Prerequisites: This page assumes you have a decent knowledge of Methods, Classes, Variables, Loops, Conditionals, and Importing things in Java. It also assumes you know what the Control Hub and Driver Station are and that you are using Android Studio. WIP

OpMode and LinearOpMode

When coding for FTC, there are two different "versions" of organizing and running your code. Both have their advantages — for convenience this page uses OpMode, but you can use whichever one you'd like.

OpMode

OpMode is a much more organized way of running through your code. It requires two methods to run:

There are 3 other optional methods:

To create a file using OpMode:

@TeleOp()
public class fileName extends OpMode {
    public void init() {
        // Your code goes here
    }

    public void loop() {
        // Your code goes here
    }
}

You may notice the @TeleOp(). This is crucial — it lets the Driver Station figure out whether your program is a TeleOp or Autonomous program. In other words, a program where a human can use a gamepad and control the robot, or a program where the robot moves on its own to score.

LinearOpMode

LinearOpMode doesn't use multiple methods to differentiate between INIT, START, and STOP. Instead, there is one method and several commands:

@TeleOp()
public class fileName extends LinearOpMode {
    // Variables and anything else goes up here

    public void runOpMode() {
        // Code that would normally go in init() goes here

        waitForStart();
        while (opModeIsActive()) {
            // Code that would normally go in loop() goes here
        }
    }
}
Heads up: The downside to using LinearOpMode is that you are responsible for updating telemetry (FTC's equivalent to System.out.print()) and for ensuring that loops aren't infinite.

Imports

When programming for FTC, you will have to import classes and libraries often. If you write a piece of code like:

if (gamepad1.left_stick_y > 1.0) {
    motor.setPower(1.0);
}

Android Studio will highlight gamepad1.left_stick_y and throw an error. This is because while you can use gamepad1.left_stick_y, you need to import the proper class. If you hover over it, it will ask if you want to import a class — click import! If you are using OnBotJava, it should automatically import classes and libraries for you.

Telemetry

Telemetry is FTC's System.out.print() equivalent. It is used to send human-readable data to the Driver Station.

The most commonly used methods:

int x = 400;
telemetry.addData("", "hi!");
telemetry.addData("x: ", x);
telemetry.update();

Gamepad Input

A key part of the robot is being able to take in human input! Every team does this via a gamepad. You use the gamepad class to check the values of every button on the gamepad.

WIP — More details coming soon.

Motors

WIP — Coming soon.

Servos

WIP — Coming soon.