Class RobotDefinition
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 -
Method Summary
Modifier and TypeMethodDescriptionprotected final <T extends Module<?>>
Tadd(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>
TaddOwn(T part) Your own part, run with the library's parts: itsupdate()every loop after START (after the library's parts, so it sees this loop's commands), and itsstop()at STOP and whenever the robot pauses (BACK, seepauseAll()): so a motor in it stops with the rest.final Aimaim()Where the goal is (the camera first, the odometry as a backup), whole-robot aim and how far off the aim is.final ModeaimMode()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).final Subsystemsall()Every part, for one update() per loop (the OpMode classes do this).final Alliancealliance()The alliance for this match (chosen in autonomous; TeleOp remembers it).final voidCode 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 voidAn action that runs once, right after START, in autonomous and in TeleOp (for example a servo that pushes the intake into place).final voidCode of your own that runs once when the OpMode ends: STOP, the end of an autonomous, or an error.protected final voidALPHA, NOT TESTED ON A ROBOT. Corrects the odometry's x and y with the field position this Limelight works out from AprilTags (MegaTag2).final CameraThe camera given tocameraFix(...)(alpha), or null.final voidStops an action.final voidStops every running action.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 voidchassisMm(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.checkConfiguration(Devices devices) checkConfiguration(HardwareMap)with anyDevices(tests use pretend ones).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.ChecksTunables.javathe way INIT does, without a robot (the simulator's:sim:fromRobotruns 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 voiddefine()Describe the robot here: onedriveline and oneadd(T)line per mechanism.final RobotDefinitiondescribe()Runs define() once (no hardware).final Drivedrive()The drivetrain as written in define().protected final voidThe drivetrain.final voiddriveWith(double forward, double strafeRight, double turnRight) Drives with numbers in your own OpMode (for example in your own autonomous), each -1 to 1.final voiddriveWith(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 voidduringInit(Runnable code) Code of your own that runs again and again in INIT, until START (FTC'sinit_loop): for example, show a sensor on the Driver Hub so the drivers can check it before the match.final List<EncoderMotor> 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 voidCode of your own that runs once every loop after START, after the library's parts (not in INIT, not while paused).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"...final FieldMapfieldMap()The map fromfieldMap(...)in Robot.java, or null if there is none.protected final voidThe places on the field the robot must not drive through, fors.routeTo(...)in an autonomous androute(...)in Controls.java.protected final voidParts the code does not move, for the simulator:fixed(Shape.box("ramp")...), andShape.passiveparts that belong to no module.final PathFollowerfollower()The path follower as running (null before setup, or with no follower(...) line).protected final voidfollower(PathFollower.Maker maker) A path follower from another library, e.g.static voidForgets 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'smirrorForRed(), and the numbers tuned in the tuning menu (in memory; a saved settings file stays).final booleanTrue with acameraFix(camera)line in Robot.java (the alpha camera fix).final booleanTrue if Robot.java has a follower(...) line.protected final voidheightMm(double height) The whole robot's height in mm (the tallest fixed part), for the simulator.final RobotDefinitioninit(com.qualcomm.robotcore.eventloop.opmode.OpMode opMode) INIT in your own OpMode (a plainLinearOpModethat 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 youratInitcode.final voidinitLoop()One pass of the INIT loop in your own OpMode (call it inwhile (opModeInInit())): each part's INIT work (a camera's check), yourduringInitcode, the robot's INIT notes, then it sends the Driver Hub's screen.The interlock rules from Robot.java (read only).final booleanisPaused()True while paused.protected final InterlockAn interlock rule: these two parts are never in their zones at the same time (seeInterlock).final PoseTrackermakeOdometry(Devices devices) makeOdometry(HardwareMap)with anyDevices(tests use pretend ones).final PoseTrackermakeOdometry(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 booleanTrue 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).modules()The mechanisms, in the order they were added (read only).notes()Notes for INIT: missing Tunables sections or fields (the library's defaults are used).final PoseTrackerodometry()The odometry as running (null before setup, or with no odometry(...) line).protected final voidThe odometry: what tells the robot where it is on the field (seeOdometry).final booleanTrue onceTunables.Odometry.checked = true: the odometry's directions and offsets were checked with the Odometry Tuner.final OdometryThe odometry as written in define() (null if none).final voidpauseAll()Pauses the whole robot: every part stops now with its motors on brake (actions wait), and remembers what it was doing.final FieldPosepose()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 booleanSets the odometry's pose to the reset spot inTunables.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) andresetHeading(degrees, 0 = facing away from you, counterclockwise +).final voidresetPose(double xIn, double yIn, double headingDeg) Sets the odometry's pose to this spot, written for BLUE (mirrored for RED as inresetPose()).final voidresume()EndspauseAll(): every part goes back to what it was doing.final ModeReverse 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).final RobotConfigThe drivetrain's settings (motor names, IMU, autonomous tuning) for EasyTeleOp and EasyAuto.final voidStarts an action (from its first step if it was running).static StringsectionName(String deviceName) The Tunables section a device's module reads: its name in CamelCase ("intake_deploy" -> "IntakeDeploy", "Webcam 1" -> "Webcam1").INIT warnings about misnamed Tunables sections (empty when none); seecheckTunables().final voidSets the alliance (the OpMode classes do this).final RobotDefinitionsetup(HardwareMap)with anyDevices(tests use pretend ones).final RobotDefinitionsetup(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap) Makes every module's hardware (INIT).final voidShows one line of your own on the Driver Hub in this loop, under the library's warnings: use it induringInitandeveryLoop(java.lang.Runnable)(call it every loop: the screen starts empty each loop).simLines()The simulator robot file's lines from the code: the drive, then each module's (see./gradlew :sim:fromRobot).final voidstart()START in your own OpMode: each part's start (a turret going to its start angle) and youratStartactions.final voidFor JUnit tests only (withPretendDevices): what START does in an OpMode (each part's start, like a servo turret going to its start angle, and theatStartactions).final voidstop()STOP in your own OpMode (put it in afinally, so it runs even after an error): stops the wheels and every part, then runs youratStopcode.final voidPauses if running, resumes if paused.protected final voidThe Tunables class, if it is not calledTunablesin the same folder as Robot.java.final Class<?> The Tunables class in use, or null if there is none.final voidupdate()One loop in your own OpMode (call it once in each pass ofwhile (opModeIsActive())): every part and running action moves a little, youreveryLoop(java.lang.Runnable)code runs, and the Driver Hub's screen is sent with each part's line.final booleanTrue once START was pressed in this OpMode.
-
Constructor Details
-
RobotDefinition
public RobotDefinition()
-
-
Method Details
-
define
protected abstract void define()Describe the robot here: onedriveline and oneadd(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
The drivetrain.- Parameters:
d- e.g.Drive.mecanum("front_left", "front_right", "back_left", "back_right")
-
odometry
The odometry: what tells the robot where it is on the field (seeOdometry).- Parameters:
o- e.g.Odometry.pinpoint("pinpoint").offsetsMm(-84, -168)
-
fieldMap
The places on the field the robot must not drive through, fors.routeTo(...)in an autonomous androute(...)in Controls.java. Needs anodometry(com.crossbotics.ftchelper.robot.Odometry)line.- Parameters:
map- e.g.FieldMap.margin(13).keepOut("Left post", -30, 10, -20, 20)
-
fieldMap
The map fromfieldMap(...)in Robot.java, or null if there is none. -
cameraFix
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 anodometry(com.crossbotics.ftchelper.robot.Odometry)line, and it is OFF untilTunables.CameraFix.enabled = true. Not for BIOBUZZ: its tags are under the CELLs and move when a HIVE tips. FindturnDegBlue/turnDegRedwith the Camera Fix Check (Tune and check). Docs: docs/modules/odometry.md, "Camera fix (alpha)".- Parameters:
camera- a Limelight camera added withadd(Camera.limelight(...))
-
cameraFixCamera
The camera given tocameraFix(...)(alpha), or null. -
hasCameraFix
public final boolean hasCameraFix()True with acameraFix(camera)line in Robot.java (the alpha camera fix). -
follower
A path follower from another library, e.g.follower(Pedro.follower(Constants.foresight))with the ftc-helper-lib "pedro" module. It needs anodometry(com.crossbotics.ftchelper.robot.Odometry)line too (it uses the same pose). -
add
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
An interlock rule: these two parts are never in their zones at the same time (seeInterlock). Write it after the parts'addlines; the numbers go inTunables.<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 oncesecond- the other part's zone, e.g.lift.zoneAbove(), orZone.when(java.lang.String, java.util.function.BooleanSupplier)- Returns:
- the rule (
Interlock.status()says what it holds)
-
interlocks
The interlock rules from Robot.java (read only). -
tunables
The Tunables class, if it is not calledTunablesin the same folder as Robot.java.- Parameters:
tunables- e.g.MyNumbers.class
-
atStart
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. InControls.java'sbuttons(...)or an autonomous'satInit(robot): that OpMode only.- Parameters:
action- e.g.() -> Actions.deployIntake(this)
-
atInit
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
Code of your own that runs again and again in INIT, until START (FTC'sinit_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
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 oneatStopfails, 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. InatStop: false means STOP came in INIT (the match never ran), e.g. do not save a number for the next OpMode then. -
show
Shows one line of your own on the Driver Hub in this loop, under the library's warnings: use it induringInitandeveryLoop(java.lang.Runnable)(call it every loop: the screen starts empty each loop). Does nothing before the first INIT loop (so not inatInit).- Parameters:
label- the name on the left, e.g. "Pieces scored"value- the value on the right
-
addOwn
Your own part, run with the library's parts: itsupdate()every loop after START (after the library's parts, so it sees this loop's commands), and itsstop()at STOP and whenever the robot pauses (BACK, seepauseAll()): 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 itsupdate()does not run; afterresume()it runs again.Call it in
define()for a part that needs no hardware, or after INIT has set the robot up (inControls.java'sbuttons(...)or an autonomous'ssteps(...), which have thehardwareMap).// 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 thatimplements Subsystem); not null, added once- Returns:
- the same part
-
everyLoop
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 useaddOwn(T)instead: pause and STOP call itsstop(), 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
Parts the code does not move, for the simulator:fixed(Shape.box("ramp")...), andShape.passiveparts that belong to no module.- Parameters:
shapes- one or moreShape.box(java.lang.String)or passive shapes
-
describe
Runs define() once (no hardware). Used by setup and by the simulator file generator. -
setup
Makes every module's hardware (INIT). The OpMode classes call this for you.- Parameters:
hardwareMap- the OpMode'shardwareMap
-
setup
setup(HardwareMap)with anyDevices(tests use pretend ones). -
checkTunables
ChecksTunables.javathe way INIT does, without a robot (the simulator's:sim:fromRobotruns 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
Every part, for one update() per loop (the OpMode classes do this). Null beforesetup(com.qualcomm.robotcore.hardware.HardwareMap). -
robotConfig
The drivetrain's settings (motor names, IMU, autonomous tuning) for EasyTeleOp and EasyAuto. -
odometry
The odometry as running (null before setup, or with no odometry(...) line). -
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. SeeAim. -
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(seeAim). -
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
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
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
makeOdometry(HardwareMap)with anyDevices(tests use pretend ones). -
odometrySpec
The odometry as written in define() (null if none). -
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 inTunables.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) andresetHeading(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, unlessTunables.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 inresetPose()). Never waits.- Parameters:
xIn- inches to the right of the field's center line, seen from your drivers' wallyIn- 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'smirrorForRed(), 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'smirrorForRed()(in a TeleOp: the last autonomous's), else true. INIT shows the choice. -
odometryChecked
public final boolean odometryChecked()True onceTunables.Odometry.checked = true: the odometry's directions and offsets were checked with the Odometry Tuner. Until then,driveTosteps do not run on a real robot. -
drive
The drivetrain as written in define(). -
modules
The mechanisms, in the order they were added (read only). -
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 askip()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
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'shardwareMap
-
checkConfiguration
checkConfiguration(HardwareMap)with anyDevices(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()EndspauseAll(): 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
Starts an action (from its first step if it was running). It runs a little every loop. -
cancel
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
The alliance for this match (chosen in autonomous; TeleOp remembers it). -
setAlliance
Sets the alliance (the OpMode classes do this). -
notes
Notes for INIT: missing Tunables sections or fields (the library's defaults are used). -
sectionWarnings
INIT warnings about misnamed Tunables sections (empty when none); seecheckTunables(). -
tunablesClass
The Tunables class in use, or null if there is none. -
init
INIT in your own OpMode (a plainLinearOpModethat 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 youratInitcode. Moves nothing. docs/guides/your-own-code.mdRobot 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 inwhile (opModeInInit())): each part's INIT work (a camera's check), yourduringInitcode, 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 youratStartactions. 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 ofwhile (opModeIsActive())): every part and running action moves a little, youreveryLoop(java.lang.Runnable)code runs, and the Driver Hub's screen is sent with each part's line. Never waits. Your owntelemetry.addData(...)lines go out with it (do not calltelemetry.update()yourself). -
stop
public final void stop()STOP in your own OpMode (put it in afinally, so it runs even after an error): stops the wheels and every part, then runs youratStopcode. -
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- + = forwardstrafeRight- + = 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 (withPretendDevices): what START does in an OpMode (each part's start, like a servo turret going to its start angle, and theatStartactions). 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
The simulator robot file's lines from the code: the drive, then each module's (see./gradlew :sim:fromRobot). Works without a robot. -
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
The Tunables section a device's module reads: its name in CamelCase ("intake_deploy" -> "IntakeDeploy", "Webcam 1" -> "Webcam1").- Parameters:
deviceName- the configuration name
-