Class Intake

java.lang.Object
com.crossbotics.ftchelper.robot.Module<Intake>
com.crossbotics.ftchelper.robot.Intake
All Implemented Interfaces:
Subsystem, Toggleable

public final class Intake extends Module<Intake> implements Toggleable
A roller that pulls game pieces in (and pushes them out): one motor, or one or more continuous rotation (CR) servos.

 intake = add(Intake.motor("intake"));                              // Robot.java
 intake = add(Intake.crServos("intake", "intake_right").reversed("intake_right"));
 intake = add(Intake.motor("intake").onAtStart());                  // runs from START until stopped
 intake = add(Intake.motor("intake").stopsWhen(() -> pieces.isFull()));   // no 5th piece (see Pieces)
 

Tunables.Intake: inPower (default 1.0) and outPower (default 0.7). Usual buttons (lines to write in Controls.java): hold G2 RT to run it in, hold G2 LT to push out. With onAtStart(): G2 RT switches it on and off, and holding LT pushes out, then goes back to what it was doing. With stopsWhen(java.util.function.BooleanSupplier): holding RT for 1 s runs it in anyway (the count was wrong), and the Driver Station warns when it has been held back for more than 2 s. Docs: docs/reference/robot-java.md (section "Intake")

  • Method Details

    • motor

      public static Intake motor(String name)
      An intake on one motor.
    • crServos

      public static Intake crServos(String... names)
      An intake on one or more CR servos (they run together). The Tunables section is the first name's.
    • withCrServos

      public Intake withCrServos(String... crServoNames)
      CR servos that run together with the intake motor (for example two side wheels next to a roller). They read the same Tunables section.
      Parameters:
      crServoNames - their configuration names
    • reversed

      public Intake reversed(String... deviceNames)
      These run the other way (for example the right one of two facing servos).
    • reversed

      public Intake reversed()
      Reverses the only device (same as reversed(itsName)).
    • holds

      public Intake holds(int pieces)
      How many game pieces it can hold at once: count them by hand (load pieces until no more fit). The simulator uses it, and so does the robot's piece count (Pieces: "full" at this number unless its max says another). Above the game's limit (BIOBUZZ G407: 4) INIT warns. Without it the simulator guesses the game's limit (4).
      Parameters:
      pieces - e.g. 4
    • holds

      public Intake holds(int pieces, String kind)
      How many pieces of one kind it can hold, for a robot where the kinds differ: 0 = it cannot take that kind at all (goBILDA's starter bot and a NECTAR). A name matches every kind that contains it, any case: "NECTAR" is red and blue NECTAR. Give the total with holds(int) too (.holds(4).holds(1, "NECTAR"): 4 pieces, at most 1 of them a NECTAR); without it the total is not known (the simulator guesses the game's limit).
      Parameters:
      pieces - 0 or more
      kind - e.g. "NECTAR", "POLLEN"
    • holdsInAll

      public int holdsInAll()
      How many pieces it holds in all (0 = not given): holds(int). Kind limits alone do not give a total (a limit for NECTAR says nothing about POLLEN): write holds(n) too.
    • kindLimits

      public Map<String,Integer> kindLimits()
      The kind limits from holds(int, String) (a copy; empty = none).
    • limitFor

      public int limitFor(String kind)
      The limit for one kind of piece from holds(int, String) (the first name it contains), or -1 when no limit names it.
      Parameters:
      kind - a piece kind, e.g. "RED_NECTAR" or "red NECTAR"
    • limitFor

      public static int limitFor(Map<String,Integer> limits, String kind)
      The limit in limits whose name is in kind (letters only, any case), or -1.
    • stopsWhen

      public Intake stopsWhen(BooleanSupplier condition)
      Never runs IN while condition is true (pushing out still works), e.g. Intake.motor("intake").stopsWhen(() -> pieces.isFull()): it will not pull in one piece too many. It runs in again by itself once the condition is false (if it is still switched on).
      Parameters:
      condition - checked every loop; must be quick
    • isHeldBack

      public boolean isHeldBack()
      True while the stopsWhen(java.util.function.BooleanSupplier) condition holds it back from running in.
    • inAnyway

      public void inAnyway()
      Runs in even though stopsWhen(java.util.function.BooleanSupplier) says no, until stop() or out(): for when the count is wrong (it says full, but the robot is not). The suggested in-button does this when held for 1 s. The drivers are then responsible for the game's limit.
    • onAtStart

      public Intake onAtStart()
      Starts running in at START (in autonomous and TeleOp), until stopped.
    • in

      public void in()
      Runs in until stop().
    • out

      public void out()
      Runs out until stop() or in().
    • holdIn

      public void holdIn()
      The intake's own "in" button job, for hold(...): runs in every loop while the button is held. With stopsWhen(java.util.function.BooleanSupplier), held 1 s it runs in anyway (the count was wrong). Your own button: g2.rt.hold(robot.intake::holdIn, robot.intake::stop).says("in (hold)");
    • stop

      public void stop()
      Description copied from interface: Subsystem
      Stops all motion. Called at the end of every OpMode.
      Specified by:
      stop in interface Subsystem
    • toggle

      public void toggle()
      On (in) if stopped, stopped if running.
      Specified by:
      toggle in interface Toggleable
    • reverse

      public void reverse()
      Pushes out while a button is held: call it every loop while held, and endReverse() on release. Afterwards it goes back to what it was doing (running in, or stopped).
    • endReverse

      public void endReverse()
      Ends reverse().
    • isPushingOut

      public boolean isPushingOut()
      True while it pushes pieces out: after out() (until in() or stop()), or while reverse() is held.
    • heldBackSec

      public double heldBackSec()
      Seconds it has been held back by stopsWhen(java.util.function.BooleanSupplier) without a break (0 when it is not).
    • isPushingForShot

      public boolean isPushingForShot()
      True while the launcher borrows it to push a piece in.
    • isRunning

      public boolean isRunning()
      True while it runs in or out.
    • update

      public void update()
      Description copied from interface: Subsystem
      Called once every loop. Do the hardware work here. Must be quick: no sleep, no waiting. While update() waits, the whole robot is frozen (no driving, no limits, no STOP).
      Specified by:
      update in interface Subsystem
    • addTelemetry

      public void addTelemetry(RobotTelemetry t)
      Description copied from class: Module
      The part's telemetry line; each module adds its own.
      Specified by:
      addTelemetry in interface Subsystem
      Overrides:
      addTelemetry in class Module<Intake>
    • inOn

      public void inOn(Pad.Button button)
      Puts "in" on button, in Controls.java (the intake's usual RT), the right way for this intake: held = in (with stopsWhen, held 1 s = in anyway); with onAtStart(), a press switches it on and off instead (with stopsWhen too, held 1 s = in anyway). Example: robot.intake.inOn(g2.rt);
      Parameters:
      button - the button
    • outOn

      public void outOn(Pad.Button button)
      Puts "out" on button, in Controls.java (the intake's usual LT): pushes out while held, then stops (with onAtStart(): then goes back to what it was doing). Example: robot.intake.outOn(g2.lt);
      Parameters:
      button - the button