Package com.crossbotics.ftchelper.robot
Class Intake
- All Implemented Interfaces:
Subsystem,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 Summary
Modifier and TypeMethodDescriptionvoidThe part's telemetry line; each module adds its own.static IntakeAn intake on one or more CR servos (they run together).voidEndsreverse().doubleSeconds it has been held back bystopsWhen(java.util.function.BooleanSupplier)without a break (0 when it is not).voidholdIn()The intake's own "in" button job, forhold(...): runs in every loop while the button is held.holds(int pieces) How many game pieces it can hold at once: count them by hand (load pieces until no more fit).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).intHow many pieces it holds in all (0 = not given):holds(int).voidin()Runs in untilstop().voidinAnyway()Runs in even thoughstopsWhen(java.util.function.BooleanSupplier)says no, untilstop()orout(): for when the count is wrong (it says full, but the robot is not).voidinOn(Pad.Button button) Puts "in" onbutton, inControls.java(the intake's usual RT), the right way for this intake: held = in (withstopsWhen, held 1 s = in anyway); withonAtStart(), a press switches it on and off instead (withstopsWhentoo, held 1 s = in anyway).booleanTrue while thestopsWhen(java.util.function.BooleanSupplier)condition holds it back from running in.booleanTrue while the launcher borrows it to push a piece in.booleanbooleanTrue while it runs in or out.The kind limits fromholds(int, String)(a copy; empty = none).intThe limit for one kind of piece fromholds(int, String)(the first name it contains), or -1 when no limit names it.static intThe limit inlimitswhose name is inkind(letters only, any case), or -1.static IntakeAn intake on one motor.Starts running in at START (in autonomous and TeleOp), until stopped.voidout()voidoutOn(Pad.Button button) Puts "out" onbutton, inControls.java(the intake's usual LT): pushes out while held, then stops (withonAtStart(): then goes back to what it was doing).voidreverse()Pushes out while a button is held: call it every loop while held, andendReverse()on release.reversed()Reverses the only device (same asreversed(itsName)).These run the other way (for example the right one of two facing servos).voidstop()Stops all motion.stopsWhen(BooleanSupplier condition) Never runs IN whileconditionis true (pushing out still works), e.g.voidtoggle()On (in) if stopped, stopped if running.voidupdate()Called once every loop.withCrServos(String... crServoNames) CR servos that run together with the intake motor (for example two side wheels next to a roller).
-
Method Details
-
motor
An intake on one motor. -
crServos
An intake on one or more CR servos (they run together). The Tunables section is the first name's. -
withCrServos
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
These run the other way (for example the right one of two facing servos). -
reversed
Reverses the only device (same asreversed(itsName)). -
holds
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 itsmaxsays 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
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 withholds(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 morekind- 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): writeholds(n)too. -
kindLimits
The kind limits fromholds(int, String)(a copy; empty = none). -
limitFor
The limit for one kind of piece fromholds(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
The limit inlimitswhose name is inkind(letters only, any case), or -1. -
stopsWhen
Never runs IN whileconditionis 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 thestopsWhen(java.util.function.BooleanSupplier)condition holds it back from running in. -
inAnyway
public void inAnyway()Runs in even thoughstopsWhen(java.util.function.BooleanSupplier)says no, untilstop()orout(): 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
Starts running in at START (in autonomous and TeleOp), until stopped. -
in
public void in()Runs in untilstop(). -
out
public void out() -
holdIn
public void holdIn()The intake's own "in" button job, forhold(...): runs in every loop while the button is held. WithstopsWhen(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:SubsystemStops all motion. Called at the end of every OpMode. -
toggle
public void toggle()On (in) if stopped, stopped if running.- Specified by:
togglein interfaceToggleable
-
reverse
public void reverse()Pushes out while a button is held: call it every loop while held, andendReverse()on release. Afterwards it goes back to what it was doing (running in, or stopped). -
endReverse
public void endReverse()Endsreverse(). -
isPushingOut
public boolean isPushingOut() -
heldBackSec
public double heldBackSec()Seconds it has been held back bystopsWhen(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:SubsystemCalled 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). -
addTelemetry
Description copied from class:ModuleThe part's telemetry line; each module adds its own.- Specified by:
addTelemetryin interfaceSubsystem- Overrides:
addTelemetryin classModule<Intake>
-
inOn
Puts "in" onbutton, inControls.java(the intake's usual RT), the right way for this intake: held = in (withstopsWhen, held 1 s = in anyway); withonAtStart(), a press switches it on and off instead (withstopsWhentoo, held 1 s = in anyway). Example:robot.intake.inOn(g2.rt);- Parameters:
button- the button
-
outOn
Puts "out" onbutton, inControls.java(the intake's usual LT): pushes out while held, then stops (withonAtStart(): then goes back to what it was doing). Example:robot.intake.outOn(g2.lt);- Parameters:
button- the button
-