Class RobotDefinition

java.lang.Object
com.crossbotics.ftchelper.robot.RobotDefinition

public abstract class RobotDefinition extends Object
What is on the robot, written once in the team's Robot.java: the drive and one line per mechanism, with each part's name in the robot configuration. TeleOp (ControlMap) and every autonomous (Auto) use it, so a renamed motor is changed in one place.

 public class Robot extends RobotDefinition {
     public Intake intake;
     public Lift lift;
     public Claw claw;

     @Override protected void define() {
         drive(Drive.mecanum("front_left", "front_right", "back_left", "back_right")
                 .motor("gobilda-5203-312").wheelMm(96)
                 .imu("imu", LogoFacingDirection.UP, UsbFacingDirection.FORWARD));
         intake = add(Intake.motor("intake"));
         lift = add(Lift.slide("lift").bottomSwitch("lift_bottom"));
         claw = add(Claw.servo("claw"));
     }
 }
 

The numbers live in Tunables.java next to this file (one section per module), the buttons in Controls.java, steps that use several parts in Actions.java.

Nothing moves in INIT: the modules make their hardware then, and move only after START. Docs: docs/reference/robot-java.md. Tutorial: docs/five-files/README.md

  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final <T extends Module<?>>
    T
    add(T module)
    Adds a mechanism and hands it back, so it can go in a field: lift = add(Lift.slide("lift"));
    final <T extends Subsystem>
    T
    addOwn(T part)
    Your own part, run with the library's parts: its update() every loop after START (after the library's parts, so it sees this loop's commands), and its stop() at STOP and whenever the robot pauses (BACK, see pauseAll()): so a motor in it stops with the rest.
    final Aim
    aim()
    Where the goal is (the camera first, the odometry as a backup), whole-robot aim and how far off the aim is.
    final Mode
    Whole-robot aim (for a robot with no turret): while on, TeleOp turns the robot toward the goal and the driver keeps forward and sideways (the turn stick still wins).
    all()
    Every part, for one update() per loop (the OpMode classes do this).
    final Alliance
    The alliance for this match (chosen in autonomous; TeleOp remembers it).
    final void
    Code of your own that runs once in INIT, right after the library made every part's hardware (for example: reset a counter, read a switch, set the lights).
    final void
    An action that runs once, right after START, in autonomous and in TeleOp (for example a servo that pushes the intake into place).
    final void
    Code of your own that runs once when the OpMode ends: STOP, the end of an autonomous, or an error.
    protected final void
    cameraFix(Camera camera)
    ALPHA, NOT TESTED ON A ROBOT. Corrects the odometry's x and y with the field position this Limelight works out from AprilTags (MegaTag2).
    final Camera
    The camera given to cameraFix(...) (alpha), or null.
    final void
    cancel(Action action)
    Stops an action.
    final void
    Stops every running action.
    static List<String>
    The Tunables values changed on this robot (tuning menu) that differ from Tunables.java, as lines to copy back into the code: "Tunables.Lift.kP = 0.0050 (code 0.004)".
    protected final void
    chassisMm(double length, double width, double height)
    The chassis box for the simulator (it bumps into the field and the game pieces): length front to back, width side to side, height from the tiles to its top, in mm.
    final List<String>
    checkConfiguration(HardwareMap) with any Devices (tests use pretend ones).
    final List<String>
    checkConfiguration(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap)
    Robot.java against a robot configuration (the Hardware Check shows it): one line for each device Robot.java names that is NOT in the configuration, and what that means.
    final List<String>
    Checks Tunables.java the way INIT does, without a robot (the simulator's :sim:fromRobot runs it): a field no part reads (INIT stops on it) and a section that looks meant for a part but is read by none (INIT warns).
    protected abstract void
    Describe the robot here: one drive line and one add(T) line per mechanism.
    Runs define() once (no hardware).
    final Drive
    The drivetrain as written in define().
    protected final void
    The drivetrain.
    final void
    driveWith(double forward, double strafeRight, double turnRight)
    Drives with numbers in your own OpMode (for example in your own autonomous), each -1 to 1.
    final void
    driveWith(com.qualcomm.robotcore.hardware.Gamepad gamepad)
    Drives with a gamepad's sticks in your own OpMode, as the library's TeleOp does without its extras: left stick forward/back (and sideways on mecanum), right stick turns, the left trigger drives slowly.
    final void
    Code of your own that runs again and again in INIT, until START (FTC's init_loop): for example, show a sensor on the Driver Hub so the drivers can check it before the match.
    Every motor Robot.java names, for the Encoder Check (Tune and check): the drive motors first, then each part's motors (a lift's second motor rides with its first).
    final void
    Code of your own that runs once every loop after START, after the library's parts (not in INIT, not while paused).
    final List<Feature>
    What the library can do for this robot by itself, ready or not, worked out from Robot.java's parts (no hardware needed): the launcher's "Fire 1", "Fire 2"...
    final FieldMap
    The map from fieldMap(...) in Robot.java, or null if there is none.
    protected final void
    The places on the field the robot must not drive through, for s.routeTo(...) in an autonomous and route(...) in Controls.java.
    protected final void
    fixed(Shape... shapes)
    Parts the code does not move, for the simulator: fixed(Shape.box("ramp")...), and Shape.passive parts that belong to no module.
    The path follower as running (null before setup, or with no follower(...) line).
    protected final void
    A path follower from another library, e.g.
    static void
    Forgets everything the library keeps from one program to the next in one robot app, as if the robot had just been turned on: the alliance, pose and report from the last autonomous (MatchMemory), each turret's last angle (keepAngle), each launcher's last trim, the last autonomous's mirrorForRed(), and the numbers tuned in the tuning menu (in memory; a saved settings file stays).
    final boolean
    True with a cameraFix(camera) line in Robot.java (the alpha camera fix).
    final boolean
    True if Robot.java has a follower(...) line.
    protected final void
    heightMm(double height)
    The whole robot's height in mm (the tallest fixed part), for the simulator.
    init(com.qualcomm.robotcore.eventloop.opmode.OpMode opMode)
    INIT in your own OpMode (a plain LinearOpMode that uses this robot): makes every part's hardware, turns on bulk reads (faster loops), checks the robot configuration and Tunables.java (INIT stops with the reason, as in the library's OpModes), and runs your atInit code.
    final void
    One pass of the INIT loop in your own OpMode (call it in while (opModeInInit())): each part's INIT work (a camera's check), your duringInit code, the robot's INIT notes, then it sends the Driver Hub's screen.
    The interlock rules from Robot.java (read only).
    final boolean
    True while paused.
    protected final Interlock
    keepApart(String ruleName, Zone first, Zone second)
    An interlock rule: these two parts are never in their zones at the same time (see Interlock).
    makeOdometry(HardwareMap) with any Devices (tests use pretend ones).
    makeOdometry(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap)
    Makes only the odometry from the odometry(...) line, for a tool that runs without the rest of the robot (e.g.
    final boolean
    True when RED uses BLUE's numbers mirrored left-right (x and headings flip: a mirrored field like DECODE 2025-26); false when RED uses the same numbers from the red wall (a field turned half a turn, like BIOBUZZ 2026-27).
    final List<Module<?>>
    The mechanisms, in the order they were added (read only).
    final List<String>
    Notes for INIT: missing Tunables sections or fields (the library's defaults are used).
    The odometry as running (null before setup, or with no odometry(...) line).
    protected final void
    The odometry: what tells the robot where it is on the field (see Odometry).
    final boolean
    True once Tunables.Odometry.checked = true: the odometry's directions and offsets were checked with the Odometry Tuner.
    final Odometry
    The odometry as written in define() (null if none).
    final void
    Pauses the whole robot: every part stops now with its motors on brake (actions wait), and remembers what it was doing.
    final FieldPose
    Where the robot is now, from the odometry: x inches right, y inches away from your drivers' wall, heading 0 = facing away, counterclockwise + (the same as autonomous start spots).
    final boolean
    Sets the odometry's pose to the reset spot in Tunables.Odometry: resetX, resetY (inches, as seen from your drivers' wall: x to the right of the field's center line, y from the center toward the far wall) and resetHeading (degrees, 0 = facing away from you, counterclockwise +).
    final void
    resetPose(double xIn, double yIn, double headingDeg)
    Sets the odometry's pose to this spot, written for BLUE (mirrored for RED as in resetPose()).
    final void
    Ends pauseAll(): every part goes back to what it was doing.
    final Mode
    Reverse drive: while on, TeleOp's forward and strafe are flipped, so the back of the robot acts as the front (turning is not flipped; field-centric driving ignores it).
    The drivetrain's settings (motor names, IMU, autonomous tuning) for EasyTeleOp and EasyAuto.
    final void
    run(Action action)
    Starts an action (from its first step if it was running).
    static String
    sectionName(String deviceName)
    The Tunables section a device's module reads: its name in CamelCase ("intake_deploy" -> "IntakeDeploy", "Webcam 1" -> "Webcam1").
    final List<String>
    INIT warnings about misnamed Tunables sections (empty when none); see checkTunables().
    final void
    Sets the alliance (the OpMode classes do this).
    setup(Devices devices)
    setup(HardwareMap) with any Devices (tests use pretend ones).
    setup(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap)
    Makes every module's hardware (INIT).
    final void
    show(String label, Object value)
    Shows one line of your own on the Driver Hub in this loop, under the library's warnings: use it in duringInit and everyLoop(java.lang.Runnable) (call it every loop: the screen starts empty each loop).
    final List<String>
    The simulator robot file's lines from the code: the drive, then each module's (see ./gradlew :sim:fromRobot).
    final void
    START in your own OpMode: each part's start (a turret going to its start angle) and your atStart actions.
    final void
    For JUnit tests only (with PretendDevices): what START does in an OpMode (each part's start, like a servo turret going to its start angle, and the atStart actions).
    final void
    STOP in your own OpMode (put it in a finally, so it runs even after an error): stops the wheels and every part, then runs your atStop code.
    final void
    Pauses if running, resumes if paused.
    protected final void
    tunables(Class<?> tunables)
    The Tunables class, if it is not called Tunables in the same folder as Robot.java.
    final Class<?>
    The Tunables class in use, or null if there is none.
    final void
    One loop in your own OpMode (call it once in each pass of while (opModeIsActive())): every part and running action moves a little, your everyLoop(java.lang.Runnable) code runs, and the Driver Hub's screen is sent with each part's line.
    final boolean
    True once START was pressed in this OpMode.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RobotDefinition

      public RobotDefinition()
  • Method Details

    • define

      protected abstract void define()
      Describe the robot here: one drive line and one add(T) line per mechanism. Only describe: do not move anything (it runs in INIT, and also without a robot, to write the simulator file).
    • drive

      protected final void drive(Drive d)
      The drivetrain.
      Parameters:
      d - e.g. Drive.mecanum("front_left", "front_right", "back_left", "back_right")
    • odometry

      protected final void odometry(Odometry o)
      The odometry: what tells the robot where it is on the field (see Odometry).
      Parameters:
      o - e.g. Odometry.pinpoint("pinpoint").offsetsMm(-84, -168)
    • fieldMap

      protected final void fieldMap(FieldMap map)
      The places on the field the robot must not drive through, for s.routeTo(...) in an autonomous and route(...) in Controls.java. Needs an odometry(com.crossbotics.ftchelper.robot.Odometry) line.
      Parameters:
      map - e.g. FieldMap.margin(13).keepOut("Left post", -30, 10, -20, 20)
    • fieldMap

      public final FieldMap fieldMap()
      The map from fieldMap(...) in Robot.java, or null if there is none.
    • cameraFix

      protected final void cameraFix(Camera camera)
      ALPHA, NOT TESTED ON A ROBOT. Corrects the odometry's x and y with the field position this Limelight works out from AprilTags (MegaTag2). Also needs an odometry(com.crossbotics.ftchelper.robot.Odometry) line, and it is OFF until Tunables.CameraFix.enabled = true. Not for BIOBUZZ: its tags are under the CELLs and move when a HIVE tips. Find turnDegBlue / turnDegRed with the Camera Fix Check (Tune and check). Docs: docs/modules/odometry.md, "Camera fix (alpha)".
      Parameters:
      camera - a Limelight camera added with add(Camera.limelight(...))
    • cameraFixCamera

      public final Camera cameraFixCamera()
      The camera given to cameraFix(...) (alpha), or null.
    • hasCameraFix

      public final boolean hasCameraFix()
      True with a cameraFix(camera) line in Robot.java (the alpha camera fix).
    • follower

      protected final void follower(PathFollower.Maker maker)
      A path follower from another library, e.g. follower(Pedro.follower(Constants.foresight)) with the ftc-helper-lib "pedro" module. It needs an odometry(com.crossbotics.ftchelper.robot.Odometry) line too (it uses the same pose).
    • add

      protected final <T extends Module<?>> T add(T module)
      Adds a mechanism and hands it back, so it can go in a field: lift = add(Lift.slide("lift"));
      Parameters:
      module - the module, e.g. Intake.motor("intake")
      Returns:
      the same module
    • keepApart

      protected final Interlock keepApart(String ruleName, Zone first, Zone second)
      An interlock rule: these two parts are never in their zones at the same time (see Interlock). Write it after the parts' add lines; the numbers go in Tunables.<ruleName>. Any number of rules, between any parts; a robot with none works as before.
      
       keepApart("TurretLift", turret.zone(), lift.zoneAbove());   // turret out of the back while the lift is up
       keepApart("WristLift", wrist.zone(), lift.zoneBelow());     // wrist folded before the lift goes low
       keepApart("ClawLift", claw.zone(), lift.zoneAbove());       // claw closed above a height
       
      Parameters:
      ruleName - the rule's name, and its Tunables section (e.g. "TurretLift")
      first - one part's zone, e.g. turret.zone(); it goes first if both want in at once
      second - the other part's zone, e.g. lift.zoneAbove(), or Zone.when(java.lang.String, java.util.function.BooleanSupplier)
      Returns:
      the rule (Interlock.status() says what it holds)
    • interlocks

      public final List<Interlock> interlocks()
      The interlock rules from Robot.java (read only).
    • tunables

      protected final void tunables(Class<?> tunables)
      The Tunables class, if it is not called Tunables in the same folder as Robot.java.
      Parameters:
      tunables - e.g. MyNumbers.class
    • atStart

      public final void atStart(Supplier<Action> action)
      An action that runs once, right after START, in autonomous and in TeleOp (for example a servo that pushes the intake into place). Never in INIT: a robot must not move before START.

      In define(): every OpMode. In Controls.java's buttons(...) or an autonomous's atInit(robot): that OpMode only.

      Parameters:
      action - e.g. () -> Actions.deployIntake(this)
    • atInit

      public final void atInit(Runnable code)
      Code of your own that runs once in INIT, right after the library made every part's hardware (for example: reset a counter, read a switch, set the lights). It must not move anything: a robot must not move before START. Added after INIT has set the robot up, it runs at once.
      
       atInit(() -> piecesScored = 0);
       
      Parameters:
      code - what to run, e.g. a lambda () -> ...
    • duringInit

      public final void duringInit(Runnable code)
      Code of your own that runs again and again in INIT, until START (FTC's init_loop): for example, show a sensor on the Driver Hub so the drivers can check it before the match. It must be quick, never wait, and not move anything.
      
       duringInit(() -> show("Lift (counts)", lift.position()));
       
      Parameters:
      code - what to run, e.g. a lambda () -> ...
    • atStop

      public final void atStop(Runnable code)
      Code of your own that runs once when the OpMode ends: STOP, the end of an autonomous, or an error. It runs after every motor is stopped (for example: save a number for the next OpMode, write a log line). If one atStop fails, the others still run.
      
       atStop(() -> RobotLog.ii("team", "pieces scored: " + piecesScored));
       
      Parameters:
      code - what to run, e.g. a lambda () -> ...
    • wasStarted

      public final boolean wasStarted()
      True once START was pressed in this OpMode. In atStop: false means STOP came in INIT (the match never ran), e.g. do not save a number for the next OpMode then.
    • show

      public final void show(String label, Object value)
      Shows one line of your own on the Driver Hub in this loop, under the library's warnings: use it in duringInit and everyLoop(java.lang.Runnable) (call it every loop: the screen starts empty each loop). Does nothing before the first INIT loop (so not in atInit).
      Parameters:
      label - the name on the left, e.g. "Pieces scored"
      value - the value on the right
    • addOwn

      public final <T extends Subsystem> T addOwn(T part)
      Your own part, run with the library's parts: its update() every loop after START (after the library's parts, so it sees this loop's commands), and its stop() at STOP and whenever the robot pauses (BACK, see pauseAll()): so a motor in it stops with the rest. Nothing runs in INIT (make its hardware in its constructor, never move anything there). While paused its update() does not run; after resume() it runs again.

      Call it in define() for a part that needs no hardware, or after INIT has set the robot up (in Controls.java's buttons(...) or an autonomous's steps(...), which have the hardwareMap).

      
       // Controls.java, in buttons(robot, g1, g2):
       robot.addOwn(new Bucket(hardwareMap));   // class Bucket implements Subsystem { update(), stop() }
       

      A second motor on a lift or an arm needs none of this: Lift.slide("lift_left").alsoMotor("lift_right").

      Parameters:
      part - your part (a class that implements Subsystem); not null, added once
      Returns:
      the same part
    • everyLoop

      public final void everyLoop(Runnable code)
      Code of your own that runs once every loop after START, after the library's parts (not in INIT, not while paused). It must be quick and never wait (docs/guides/non-blocking.md). For code that moves a motor use addOwn(T) instead: pause and STOP call its stop(), and a Runnable has none.
      
       robot.everyLoop(() -> lastLiftHeight = robot.lift.position());
       
      Parameters:
      code - what to run, e.g. a lambda () -> ...
    • chassisMm

      protected final void chassisMm(double length, double width, double height)
      The chassis box for the simulator (it bumps into the field and the game pieces): length front to back, width side to side, height from the tiles to its top, in mm.
    • heightMm

      protected final void heightMm(double height)
      The whole robot's height in mm (the tallest fixed part), for the simulator.
    • fixed

      protected final void fixed(Shape... shapes)
      Parts the code does not move, for the simulator: fixed(Shape.box("ramp")...), and Shape.passive parts that belong to no module.
      Parameters:
      shapes - one or more Shape.box(java.lang.String) or passive shapes
    • describe

      public final RobotDefinition describe()
      Runs define() once (no hardware). Used by setup and by the simulator file generator.
    • setup

      public final RobotDefinition setup(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap)
      Makes every module's hardware (INIT). The OpMode classes call this for you.
      Parameters:
      hardwareMap - the OpMode's hardwareMap
    • setup

      public final RobotDefinition setup(Devices devices)
      setup(HardwareMap) with any Devices (tests use pretend ones).
    • checkTunables

      public final List<String> checkTunables()
      Checks Tunables.java the way INIT does, without a robot (the simulator's :sim:fromRobot runs it): a field no part reads (INIT stops on it) and a section that looks meant for a part but is read by none (INIT warns). Every part counts as on the robot. Empty when all is fine.
      Returns:
      one line per problem, e.g. "Tunables.Launcher is not read by any part: ..."
    • all

      public final Subsystems all()
      Every part, for one update() per loop (the OpMode classes do this). Null before setup(com.qualcomm.robotcore.hardware.HardwareMap).
    • robotConfig

      public final RobotConfig robotConfig()
      The drivetrain's settings (motor names, IMU, autonomous tuning) for EasyTeleOp and EasyAuto.
    • odometry

      public final PoseTracker odometry()
      The odometry as running (null before setup, or with no odometry(...) line).
    • aim

      public final Aim aim()
      Where the goal is (the camera first, the odometry as a backup), whole-robot aim and how far off the aim is. Null before setup. See Aim.
    • aimMode

      public final Mode aimMode()
      Whole-robot aim (for a robot with no turret): while on, TeleOp turns the robot toward the goal and the driver keeps forward and sideways (the turn stick still wins). One line in Controls.java: g1.rb.toggle(robot.aimMode());. Off at START. Numbers: Tunables.Aim (see Aim).
    • reverseDriveMode

      public final Mode reverseDriveMode()
      Reverse drive: while on, TeleOp's forward and strafe are flipped, so the back of the robot acts as the front (turning is not flipped; field-centric driving ignores it). Off at START. One line in Controls.java: g1.x.toggle(robot.reverseDriveMode()).rumble();.
    • follower

      public final PathFollower follower()
      The path follower as running (null before setup, or with no follower(...) line).
    • hasFollower

      public final boolean hasFollower()
      True if Robot.java has a follower(...) line.
    • makeOdometry

      public final PoseTracker makeOdometry(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap)
      Makes only the odometry from the odometry(...) line, for a tool that runs without the rest of the robot (e.g. Pedro's tuners through the pedro module). Your code calls update() on it each loop.
    • makeOdometry

      public final PoseTracker makeOdometry(Devices devices)
      makeOdometry(HardwareMap) with any Devices (tests use pretend ones).
    • odometrySpec

      public final Odometry odometrySpec()
      The odometry as written in define() (null if none).
    • pose

      public final FieldPose pose()
      Where the robot is now, from the odometry: x inches right, y inches away from your drivers' wall, heading 0 = facing away, counterclockwise + (the same as autonomous start spots). Null if the robot has no odometry. A copy: changing it does not move anything.
    • resetPose

      public final boolean resetPose()
      Sets the odometry's pose to the reset spot in Tunables.Odometry: resetX, resetY (inches, as seen from your drivers' wall: x to the right of the field's center line, y from the center toward the far wall) and resetHeading (degrees, 0 = facing away from you, counterclockwise +). Written for BLUE; RED uses it mirrored left-right (x and the heading flip), like autonomous's start spot, unless Tunables.Odometry.mirrorForRed = false (a field turned half a turn: the same numbers from the red wall).

      Use it when autonomous was stopped early or did not run: park the robot on the spot (e.g. the start tile against your wall), then call it. TeleOp's "set pose here" button (hold G1 START 1 s) does it for you. Never waits.

      
       public static class Odometry {
           public static double resetX = -36, resetY = -63, resetHeading = 0;   // our start tile, facing the field
       }
       
      Returns:
      true if it was set; false (nothing changed) with no odometry or no resetX/resetY
    • resetPose

      public final void resetPose(double xIn, double yIn, double headingDeg)
      Sets the odometry's pose to this spot, written for BLUE (mirrored for RED as in resetPose()). Never waits.
      Parameters:
      xIn - inches to the right of the field's center line, seen from your drivers' wall
      yIn - inches from the center toward the far wall (negative = your half)
      headingDeg - 0 = facing away from you, counterclockwise +
      Throws:
      IllegalStateException - if the robot has no odometry (or before setup)
    • freshRobotApp

      public static void freshRobotApp()
      Forgets everything the library keeps from one program to the next in one robot app, as if the robot had just been turned on: the alliance, pose and report from the last autonomous (MatchMemory), each turret's last angle (keepAngle), each launcher's last trim, the last autonomous's mirrorForRed(), and the numbers tuned in the tuning menu (in memory; a saved settings file stays). WHY: a test (a JUnit test, or the simulator running several scenario files) must start the same way each time, whatever ran before it. Never call it in robot code: the next program would lose what the last one left for it.
       RobotDefinition.freshRobotApp();   // in a test, before each robot
       
    • mirrorForRed

      public final boolean mirrorForRed()
      True when RED uses BLUE's numbers mirrored left-right (x and headings flip: a mirrored field like DECODE 2025-26); false when RED uses the same numbers from the red wall (a field turned half a turn, like BIOBUZZ 2026-27). ONE setting for the whole robot: the autonomous's routes and start spot, the aim's goal point, and TeleOp's reset spot all use it. Where it comes from, first found: Tunables.Aim.mirrorForRed, Tunables.Odometry.mirrorForRed, your autonomous's mirrorForRed() (in a TeleOp: the last autonomous's), else true. INIT shows the choice.
    • odometryChecked

      public final boolean odometryChecked()
      True once Tunables.Odometry.checked = true: the odometry's directions and offsets were checked with the Odometry Tuner. Until then, driveTo steps do not run on a real robot.
    • drive

      public final Drive drive()
      The drivetrain as written in define().
    • modules

      public final List<Module<?>> modules()
      The mechanisms, in the order they were added (read only).
    • encoderMotors

      public final List<EncoderMotor> encoderMotors()
      Every motor Robot.java names, for the Encoder Check (Tune and check): the drive motors first, then each part's motors (a lift's second motor rides with its first). Each has the direction Robot.java gives it, which way to push it (toward the side its range has room, from Tunables.java), and says if the library reads its encoder. A motor whose port reads something else (an odometry pod, a CR servo turret's encoder) is listed with a skip() reason. Servos are not listed.
      
       for (EncoderMotor m : new Robot().encoderMotors()) telemetry.addLine(m.toString());
       
      Returns:
      the motors, each name once (no hardware needed)
    • features

      public final List<Feature> features()
      What the library can do for this robot by itself, ready or not, worked out from Robot.java's parts (no hardware needed): the launcher's "Fire 1", "Fire 2"... and "Fire all" actions, "Aim at the goal" in an autonomous, the aim toggles for TeleOp, and the Goal line on the Driver Station. A feature that is not ready says what is missing. The simulator and the auto builder show this list.
    • checkConfiguration

      public final List<String> checkConfiguration(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap)
      Robot.java against a robot configuration (the Hardware Check shows it): one line for each device Robot.java names that is NOT in the configuration, and what that means. Empty when all are there.
      
       "lift" (Lift): NOT in the configuration: INIT will stop. Add it, or add .optional() to Lift in Robot.java
       "intake_deploy" (IntakeDeploy): not in the configuration: optional, so the part is off (fine)
       
      Parameters:
      hardwareMap - the OpMode's hardwareMap
    • checkConfiguration

      public final List<String> checkConfiguration(Devices devices)
      checkConfiguration(HardwareMap) with any Devices (tests use pretend ones).
    • pauseAll

      public final void pauseAll()
      Pauses the whole robot: every part stops now with its motors on brake (actions wait), and remembers what it was doing. resume() goes on from there. TeleOp's BACK does it.
    • resume

      public final void resume()
      Ends pauseAll(): every part goes back to what it was doing.
    • togglePause

      public final void togglePause()
      Pauses if running, resumes if paused.
    • isPaused

      public final boolean isPaused()
      True while paused.
    • run

      public final void run(Action action)
      Starts an action (from its first step if it was running). It runs a little every loop.
    • cancel

      public final void cancel(Action action)
      Stops an action. Its parts stop safely (a lift holds its height, waiting shots are dropped).
    • cancelAll

      public final void cancelAll()
      Stops every running action.
    • alliance

      public final Alliance alliance()
      The alliance for this match (chosen in autonomous; TeleOp remembers it).
    • setAlliance

      public final void setAlliance(Alliance a)
      Sets the alliance (the OpMode classes do this).
    • notes

      public final List<String> notes()
      Notes for INIT: missing Tunables sections or fields (the library's defaults are used).
    • sectionWarnings

      public final List<String> sectionWarnings()
      INIT warnings about misnamed Tunables sections (empty when none); see checkTunables().
    • tunablesClass

      public final Class<?> tunablesClass()
      The Tunables class in use, or null if there is none.
    • init

      public final RobotDefinition init(com.qualcomm.robotcore.eventloop.opmode.OpMode opMode)
      INIT in your own OpMode (a plain LinearOpMode that uses this robot): makes every part's hardware, turns on bulk reads (faster loops), checks the robot configuration and Tunables.java (INIT stops with the reason, as in the library's OpModes), and runs your atInit code. Moves nothing. docs/guides/your-own-code.md
      
       Robot robot = new Robot();
       robot.init(this);
       while (opModeInInit()) robot.initLoop();
       try {
           robot.start();
           while (opModeIsActive()) {
               robot.driveWith(gamepad1);
               if (gamepad1.a) robot.run(Actions.score(robot));
               robot.update();
           }
       } finally {
           robot.stop();
       }
       
      Parameters:
      opMode - your OpMode (this)
      Returns:
      this robot
    • initLoop

      public final void initLoop()
      One pass of the INIT loop in your own OpMode (call it in while (opModeInInit())): each part's INIT work (a camera's check), your duringInit code, the robot's INIT notes, then it sends the Driver Hub's screen. Never waits.
    • start

      public final void start()
      START in your own OpMode: each part's start (a turret going to its start angle) and your atStart actions. Call it once, after the INIT loop. If STOP was pressed in INIT, it does nothing: nothing may move then.
    • update

      public final void update()
      One loop in your own OpMode (call it once in each pass of while (opModeIsActive())): every part and running action moves a little, your everyLoop(java.lang.Runnable) code runs, and the Driver Hub's screen is sent with each part's line. Never waits. Your own telemetry.addData(...) lines go out with it (do not call telemetry.update() yourself).
    • stop

      public final void stop()
      STOP in your own OpMode (put it in a finally, so it runs even after an error): stops the wheels and every part, then runs your atStop code.
    • driveWith

      public final void driveWith(com.qualcomm.robotcore.hardware.Gamepad gamepad)
      Drives with a gamepad's sticks in your own OpMode, as the library's TeleOp does without its extras: left stick forward/back (and sideways on mecanum), right stick turns, the left trigger drives slowly. Robot-centric (forward = the robot's front). Call it every loop.
      Parameters:
      gamepad - e.g. gamepad1
    • driveWith

      public final void driveWith(double forward, double strafeRight, double turnRight)
      Drives with numbers in your own OpMode (for example in your own autonomous), each -1 to 1. Robot- centric. The wheels keep this power until the next call: send 0, 0, 0 to stop.
      Parameters:
      forward - + = forward
      strafeRight - + = to the right (mecanum only; a tank drive ignores it)
      turnRight - + = turn clockwise, seen from above
    • startForTests

      public final void startForTests()
      For JUnit tests only (with PretendDevices): what START does in an OpMode (each part's start, like a servo turret going to its start angle, and the atStart actions). The OpMode classes do this themselves: never call it in robot code.
      
       robot.setup(devices);     // INIT
       robot.startForTests();    // START
       robot.all().update();     // one loop
       
    • simLines

      public final List<String> simLines()
      The simulator robot file's lines from the code: the drive, then each module's (see ./gradlew :sim:fromRobot). Works without a robot.
    • changedTunables

      public static List<String> changedTunables()
      The Tunables values changed on this robot (tuning menu) that differ from Tunables.java, as lines to copy back into the code: "Tunables.Lift.kP = 0.0050 (code 0.004)". Empty if none.
    • sectionName

      public static String sectionName(String deviceName)
      The Tunables section a device's module reads: its name in CamelCase ("intake_deploy" -> "IntakeDeploy", "Webcam 1" -> "Webcam1").
      Parameters:
      deviceName - the configuration name