Skip to content
Work in progress. This library and its docs are new and still changing, and some parts are not yet tested on a real robot. If something is wrong or unclear,tell us with a short GitHub form.

Set up 4: add the library

Do it once per robot project, usually a mentor or the code lead. After you commit and push it, everyone who clones the project gets the library.

Skip this page if there is already an ftc-helper-lib folder next to TeamCode, with files in it.

The library goes inside your robot project as a git submodule: a project kept inside another project. Your project remembers exactly which version of the library it uses. Why a submodule: it works at events with no internet, you can read the library’s code in Android Studio, and the whole team gets the same version.

  • The robot project open in Android Studio, synced (page 3).
  • Git in Android Studio’s Terminal tab: git --version prints git version 2... (the Terminal).

Type this line and press Enter.

Where: Android Studio’s Terminal tab, in the project folder (a new Terminal tab starts there). (Which folder)

Terminal window
git submodule add https://github.com/crossbotics/ftc-helper-lib.git ftc-helper-lib

A new folder, ftc-helper-lib, is now next to TeamCode.

For a fixed version instead of the newest, read Use a specific version after this page.

  1. Open settings.gradle. It is in the top project folder, not in TeamCode.

  2. At the bottom you see:

    include ':FtcRobotController'
    include ':TeamCode'
  3. Add these two lines under them:

    include ':ftc-helper-lib'
    project(':ftc-helper-lib').projectDir = new File(rootDir, 'ftc-helper-lib/library')

Why the second line: the submodule also holds examples, docs and the simulator. The robot app needs only the library folder.

  1. Open TeamCode/build.gradle.

  2. Find the dependencies { ... } block at the bottom.

  3. Add one line inside it:

    dependencies {
    implementation project(':FtcRobotController')
    implementation project(':ftc-helper-lib') // <- add this line
    }

Click Sync Now in the yellow bar at the top of the editor (or File > Sync Project with Gradle Files). Wait until it finishes with no red errors.

  1. In the teamcode folder, make a new Java file named HelperCheck (right-click teamcode > New > Java Class).

  2. Replace everything in it with this:

    package org.firstinspires.ftc.teamcode;
    import com.qualcomm.robotcore.eventloop.opmode.LinearOpMode;
    import com.qualcomm.robotcore.eventloop.opmode.TeleOp;
    import com.crossbotics.ftchelper.util.Angles;
    @TeleOp(name = "Helper Check")
    public class HelperCheck extends LinearOpMode {
    @Override
    public void runOpMode() {
    telemetry.addData("Library works", Angles.shortestDiff(-170, 170) == 20);
    telemetry.update();
    waitForStart();
    }
    }
  3. Build: Build > Make Project (or the hammer: the buttons). When it builds, the library is in. Why it proves it: the import com.crossbotics... line only works when the library is there.

  4. Delete HelperCheck.java.

Why: teammates get the library only after you commit and push it.

Where: Android Studio’s Terminal tab, in the project folder (a new Terminal tab starts there). (Which folder)

Terminal window
git add .gitmodules ftc-helper-lib settings.gradle TeamCode/build.gradle
git commit -m "Add ftc-helper-lib"
git push

In GitHub Desktop: tick those four, type the message, click Commit to main, then click Push origin.

At each Gradle sync, the library adds three entries to the run list (the buttons):

  • Simulator: a pretend robot on your laptop, in your browser (the simulator).
  • Simulator tests: runs your project’s simulator tests.
  • Update library: gets the newest library version (Keep it up to date).

If they are not in the list, click File > Close Project, then open the project again. To turn them off, write simulatorButtons=false in your project’s gradle.properties.

The test build passed, you deleted HelperCheck.java, and you pushed the change.

Next: Update the hubs.

Look it up: Keep the library up to date and The simulator.

Something wrong on this page? Tell us with a short GitHub form.