Class LibraryButtons

java.lang.Object
com.crossbotics.ftchelper.teleop.LibraryButtons

public final class LibraryButtons extends Object
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));
 }
 
The defaults (two drivers; one driver in brackets)
JobDefault
drive / strafe, turnG1 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/offnone (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 INITG1 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

  • Field Details

    • HOLD_SEC

      public static final double HOLD_SEC
      How 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_SEC
      How long both "switch alliance" buttons are held (seconds): long, so it never happens by accident.
      See Also:
  • Method Details

    • twoDrivers

      public static LibraryButtons twoDrivers()
      The two-driver defaults (see the table above).
    • oneDriver

      public static LibraryButtons oneDriver()
      The one-driver defaults (Controls.java with oneDriver = 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

      public LibraryButtons pause(Key key)
      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

      public LibraryButtons resetForward(Key key)
      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

      public LibraryButtons debug(Key key, Key with)
      Debug lines on/off: press key and with together (either order, except that when one of them is the pause button, the other must go down first: hold START, then press BACK). with null: key alone, a tap. Both null = no button.
    • slow

      public LibraryButtons slow(Key key)
      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

      public LibraryButtons slowToggle(Key key)
      Slow on/off: each press switches slow driving on or off. Null = none.
    • fieldCentric

      public LibraryButtons fieldCentric(Key key)
      Field-centric on/off (a mecanum with an IMU or odometry). Null = none (it stays as it starts).
    • buttonMap

      public LibraryButtons buttonMap(Key key)
      The button map on the Driver Station (a tap shows it, a tap again hides it). Null = none.
    • tuningMenu

      public LibraryButtons tuningMenu(Key key)
      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

      public LibraryButtons setPose(Key key)
      "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

      public LibraryButtons switchAlliance(Key key, Key with)
      Turns on switching the alliance (BLUE / RED) during TeleOp: hold key and with together SWITCH_ALLIANCE_SEC seconds. 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). with null: key alone, held. Both null = off again.
    • allianceInInit

      public LibraryButtons allianceInInit(Key blue, Key red)
      The INIT buttons that choose the alliance (before START). Null = no button for that color.
    • swapSticks

      public LibraryButtons swapSticks(boolean swap)
      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

      public Key key(LibraryButtons.Job job)
      The button of a job (the first one of a pair), or null if it has none.
    • with

      public Key with(LibraryButtons.Job job)
      The second button of a pair (debug, switch alliance), or null.
    • initBlue

      public Key initBlue()
      The INIT button for BLUE, or null.
    • initRed

      public Key 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

      public LibraryButtons 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 with oneDriver = true does it for you.
    • words

      public Map<Key,String> words(Set<LibraryButtons.Job> jobs)
      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")