Package com.crossbotics.ftchelper.teleop
Class LibraryButtons
java.lang.Object
com.crossbotics.ftchelper.teleop.LibraryButtons
Where the library's own TeleOp jobs are on the gamepads: driving, pause, slow, field-centric, the
button map, the tuning menu, "set pose here" and "switch alliance" (off unless you turn it on). Every
one can be moved to another button, or freed (
null: no button). The defaults are below.
// Controls.java (the robot in five files):
@Override protected void libraryButtons(LibraryButtons lib, Pad g1, Pad g2) {
lib.fieldCentric(g1.x); // field-centric on/off on X instead of Y
lib.slow(g1.rt); // slow on the right trigger (LT is free now)
lib.switchAlliance(g1.start, g1.back); // turn on the alliance switch: hold START, then BACK, 1.5 s
}
// EasyTeleOp (your own TeleOp):
@Override protected void libraryButtons(LibraryButtons lib) {
lib.pause(Key.g1(Btn.A));
}
| Job | Default |
|---|---|
| drive / strafe, turn | G1 left stick, G1 right stick X (swapSticks) |
| pause (at the press) / go on (a tap) | G1 BACK |
| reset "forward" (hold 1 s, field-centric) | G1 BACK |
| debug lines (hold START, then press BACK; runs when let go) | G1 START + BACK |
| switch alliance (both held 1.5 s) | none: off until switchAlliance(com.crossbotics.ftchelper.teleop.Key, com.crossbotics.ftchelper.teleop.Key) turns it on |
| set pose here (hold 1 s, robots with odometry; also in INIT) | G1 START |
| slow (squeeze) | G1 LT (one driver: none) |
| slow on/off | none (one driver: G1 left stick click) |
| field-centric on/off (mecanum with an IMU) | G1 Y (one driver: G1 right stick click) |
| button map (a tap) | G1 GUIDE |
| tuning menu (hold 1 s, PRACTICE profile) | G1 GUIDE |
| choose the alliance in INIT | G1 X = BLUE, G1 B = RED |
Rules, checked at INIT (a clear message names the button): a button gets at most one quick job (a tap) and one long job (held); "reset forward" and "tuning menu" are the long job when their button has a quick one, else a tap. The slow trigger gets nothing else. A pair is two different buttons on one gamepad; debug and "switch alliance" may share one pair (a quick press of both = debug, both held 1.5 s = switch). START + A or B (pairing a gamepad on the Driver Station) cancels START's own job for that press. The tuning menu's button may not be one the menu itself uses on gamepad 1 (D-pad, A, B, X, Y, LB, RB). Docs: docs/guides/buttons.md (section "Moving the library's buttons"), docs/modules/teleop.md
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumThe library's jobs, with the words the button map shows. -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleHow long a "hold" job takes: reset forward, set pose here, the tuning menu (seconds).static final doubleHow long both "switch alliance" buttons are held (seconds): long, so it never happens by accident. -
Method Summary
Modifier and TypeMethodDescriptionallianceInInit(Key blue, Key red) The INIT buttons that choose the alliance (before START).The button map on the Driver Station (a tap shows it, a tap again hides it).Debug lines on/off: presskeyandwithtogether (either order, except that when one of them is the pause button, the other must go down first: hold START, then press BACK).fieldCentric(Key key) Field-centric on/off (a mecanum with an IMU or odometry).initBlue()The INIT button for BLUE, or null.initRed()The INIT button for RED, or null.key(LibraryButtons.Job job) The button of a job (the first one of a pair), or null if it has none.Moves every gamepad 2 button of these jobs to the same button on gamepad 1 (one driver: there is no gamepad 2).static LibraryButtonsThe one-driver defaults (Controls.java withoneDriver = true): no slow trigger (the triggers are the operator's), slow on/off on the left stick click, field-centric on the right stick click.Pause / go on.resetForward(Key key) Reset "forward" (field-centric: the robot now faces away from you)."Set pose here": held 1 s, the odometry's pose becomes the reset spot (Tunables.Odometry.resetX, resetY, resetHeading).Slow driving.slowToggle(Key key) Slow on/off: each press switches slow driving on or off.booleanTrue when the right stick drives and the left stick X turns.swapSticks(boolean swap) True: drive (and strafe) with the RIGHT stick and turn with the LEFT stick's X.switchAlliance(Key key, Key with) Turns on switching the alliance (BLUE / RED) during TeleOp: holdkeyandwithtogetherSWITCH_ALLIANCE_SECseconds.tuningMenu(Key key) The tuning menu (PRACTICE profile): held 1 s when its button also shows the button map, else a tap.static LibraryButtonsThe two-driver defaults (see the table above).with(LibraryButtons.Job job) The second button of a pair (debug, switch alliance), or null.words(Set<LibraryButtons.Job> jobs) Each button's words for the button map: "pause / go on; hold 1 s: forward = away from you now".
-
Field Details
-
HOLD_SEC
public static final double HOLD_SECHow long a "hold" job takes: reset forward, set pose here, the tuning menu (seconds).- See Also:
-
SWITCH_ALLIANCE_SEC
public static final double SWITCH_ALLIANCE_SECHow long both "switch alliance" buttons are held (seconds): long, so it never happens by accident.- See Also:
-
-
Method Details
-
twoDrivers
The two-driver defaults (see the table above). -
oneDriver
The one-driver defaults (Controls.java withoneDriver = true): no slow trigger (the triggers are the operator's), slow on/off on the left stick click, field-centric on the right stick click. The rest as with two drivers. -
pause
Pause / go on. A press pauses at once (even when the button also has a long job, like BACK's "reset forward"); a tap goes on again. A pair with this button in it (debug lines, the alliance switch) needs the other button down first: this button pressed first is always a plain pause. Null = no button (INIT then warns: nothing can pause). -
resetForward
Reset "forward" (field-centric: the robot now faces away from you). Held 1 s when its button also has a quick job (like pause), else a tap. Null = no button. -
debug
Debug lines on/off: presskeyandwithtogether (either order, except that when one of them is the pause button, the other must go down first: hold START, then press BACK).withnull:keyalone, a tap. Both null = no button. -
slow
Slow driving. A trigger: the further it is pulled, the slower (down to the slow speed at a full squeeze). A button: slow while it is held. Null = none. -
slowToggle
Slow on/off: each press switches slow driving on or off. Null = none. -
fieldCentric
Field-centric on/off (a mecanum with an IMU or odometry). Null = none (it stays as it starts). -
buttonMap
The button map on the Driver Station (a tap shows it, a tap again hides it). Null = none. -
tuningMenu
The tuning menu (PRACTICE profile): held 1 s when its button also shows the button map, else a tap. The menu itself is worked with gamepad 1's D-pad, A, B, X, Y and bumpers. Null = none. -
setPose
"Set pose here": held 1 s, the odometry's pose becomes the reset spot (Tunables.Odometry.resetX, resetY, resetHeading). Only on a robot with odometry, only with the drive sticks let go, and also in INIT (before the match). Null = none. -
switchAlliance
Turns on switching the alliance (BLUE / RED) during TeleOp: holdkeyandwithtogetherSWITCH_ALLIANCE_SECseconds. Off by default (the alliance is chosen in INIT);lib.switchAlliance(g1.start, g1.back)is the usual pair (it shares START + BACK with the debug lines: a quick press of both = debug). BACK is the pause button, so hold START first, then BACK (BACK first is just a pause).withnull:keyalone, held. Both null = off again. -
allianceInInit
The INIT buttons that choose the alliance (before START). Null = no button for that color. -
swapSticks
True: drive (and strafe) with the RIGHT stick and turn with the LEFT stick's X. False (default): the left stick drives, the right stick X turns. -
key
The button of a job (the first one of a pair), or null if it has none. -
with
The second button of a pair (debug, switch alliance), or null. -
initBlue
The INIT button for BLUE, or null. -
initRed
The INIT button for RED, or null. -
sticksSwapped
public boolean sticksSwapped()True when the right stick drives and the left stick X turns. -
moveAllToGamepad1
Moves every gamepad 2 button of these jobs to the same button on gamepad 1 (one driver: there is no gamepad 2). Two jobs that land on one button are then checked like any other clash. Controls.java withoneDriver = truedoes it for you. -
words
Each button's words for the button map: "pause / go on; hold 1 s: forward = away from you now". A pair's words are on both of its buttons ("with A: ..."); a pair with the pause button says which goes first ("START: then BACK: debug lines", "BACK: after START: debug lines"). The slow key is included. Checks the buttons first (two jobs on one button stop with the button's name).- Parameters:
jobs- the jobs this TeleOp has (a robot without odometry has no "set pose")
-