Class Launcher
java.lang.Object
com.crossbotics.ftchelper.launcher.Launcher
- All Implemented Interfaces:
Subsystem
Joins a flywheel, a feeder, and optionally a hood, a shot table and any "ready" checks into one
shooter: spin up, wait until everything is ready, feed, repeat. It never stops the loop, so it
works the same in TeleOp and in autonomous. (Last season's FiringController, made general.)
Launcher launcher = new Launcher(flywheel, feeder)
.hood(hood) // a PositionServo with degrees(...)
.table(pollenTable) // distance -> rpm + hood
.requireReady("Turret", turret::isAimed) // add any check you like
.shotInterval(0.25); // at least 0.25 s between pieces
launcher.setDistance(40); // or launcher.setRpm(3200)
controls.bindPress(Pad.G2, Btn.RB, () -> launcher.shoot(1))
.bindPress(Pad.G2, Btn.LB, () -> launcher.shoot(4))
.bindPress(Pad.G2, Btn.B, launcher::stopShooting);
routine.step("Shoot 3", launcher.shootStep(3));
// every loop: launcher.update(); (it updates the flywheel, feeder and hood for you)
If it is not ready within readyTimeout(double), it gives up the remaining shots and
whyNotReady() says what was missing. That is your first debug clue.
How it works: shoot(int) only adds to a count of "shots still to fire". Each loop,
update() feeds ONE piece if everything is ready, and otherwise just checks again next loop.
No waiting anywhere (see docs/guides/non-blocking.md). Tutorial 17 builds a shooter step by step.
Docs: docs/modules/launcher.md
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumWhat the launcher is doing (for telemetry). -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidShows the state, shots left and READY; problems as warnings; then the flywheel, feeder and hood.Removes everyrequireReady(java.lang.String, java.util.function.BooleanSupplier)check.The flywheel inside.getHood()The hood servo, or null if there is none.The last problem (e.g.intPieces fed since the OpMode started.intShots still waiting to be fired.getState()What it is doing now (seeLauncher.State).booleanhasTable()True if a shot table was given (setDistance(double)works).hood(PositionServo hoodServo) A hood servo that hasdegrees(...)set.voididle()Goes back to the idle speed (cancels any shots).idleRpm(double rpm) Speed to keep when not shooting, in RPM (0 = stop).booleanisReady()True when the flywheel is at speed, the hood has arrived, and every check passes.booleanTrue while shots are waiting or a piece is being fed.name()The name shown in telemetry and in the hardware check.readyTimeout(double seconds) Give up the remaining shots if not ready within this many seconds.requireReady(String checkName, BooleanSupplier check) Another condition that must be true before each piece is fed (aim, sensor, anything).voidsetDistance(double distance) Sets the shot from the table (speed, and hood angle if there is a hood).voidsetRpm(double rpm) Sets the shot speed by hand, in RPM.voidshoot(int count) Shootscountpieces (spins up first if needed).shootStep(int count) A step: shootcountpieces and wait until done (or it gives up).shotInterval(double seconds) Least time between two pieces, seconds.voidspinUp()Spins the flywheel up to the shot speed and keeps it there.A step: spin up and wait until ready (or the ready timeout).voidstop()Fully off: no shots, no idle speed.voidCancels the shots still waiting (keeps spinning).A shot table, used bysetDistance(double).voidupdate()Once per loop: sets the flywheel speed, updates the flywheel, feeder and hood, then feeds one piece if shots are waiting and everything is ready.What is not ready yet, e.g.
-
Constructor Details
-
Launcher
Makes a launcher from a flywheel and a feeder you already made. It starts OFF. Put only the launcher in your loop (or Subsystems group): it updates both for you.
-
-
Method Details
-
hood
A hood servo that hasdegrees(...)set. The table's hood angle goes to it. -
table
A shot table, used bysetDistance(double). -
requireReady
Another condition that must be true before each piece is fed (aim, sensor, anything).checkNameis shown bywhyNotReady()while it is false. Example:requireReady("Turret", turret::isAimed): "turret::isAimed" hands over the question "is the turret aimed?" so the launcher can ask it every loop. -
clearReadyChecks
Removes everyrequireReady(java.lang.String, java.util.function.BooleanSupplier)check. The Shot Tuner does this for a robot in five files: there you aim by hand, so a "turret aimed" check must not stop each shot. -
shotInterval
Least time between two pieces, seconds. Default 0.25. -
readyTimeout
Give up the remaining shots if not ready within this many seconds. Default 3. -
idleRpm
Speed to keep when not shooting, in RPM (0 = stop). A low idle speed makes spin-up faster. -
setRpm
public void setRpm(double rpm) Sets the shot speed by hand, in RPM. -
setDistance
public void setDistance(double distance) Sets the shot from the table (speed, and hood angle if there is a hood). Distance in the table's unit (inches in the examples). Safe to call every loop, e.g. with the camera's distance. -
spinUp
public void spinUp()Spins the flywheel up to the shot speed and keeps it there. -
idle
public void idle()Goes back to the idle speed (cancels any shots). Usestop()for fully off. -
shoot
public void shoot(int count) Shootscountpieces (spins up first if needed). Adds to any shots still waiting. -
stopShooting
public void stopShooting()Cancels the shots still waiting (keeps spinning). -
stop
public void stop()Fully off: no shots, no idle speed. Stays off until spinUp(), shoot() or idle(). -
update
public void update()Once per loop: sets the flywheel speed, updates the flywheel, feeder and hood, then feeds one piece if shots are waiting and everything is ready. Gives up (with a reason) if not ready in time. -
isReady
public boolean isReady()True when the flywheel is at speed, the hood has arrived, and every check passes. -
whyNotReady
What is not ready yet, e.g. "flywheel, Turret" ("" when ready). -
getState
What it is doing now (seeLauncher.State). -
isShooting
public boolean isShooting()True while shots are waiting or a piece is being fed. -
getShotsLeft
public int getShotsLeft()Shots still waiting to be fired. -
getShotsFired
public int getShotsFired()Pieces fed since the OpMode started. -
getLastProblem
The last problem (e.g. why it gave up), or "". -
getFlywheel
The flywheel inside. -
getHood
The hood servo, or null if there is none. -
hasTable
public boolean hasTable()True if a shot table was given (setDistance(double)works). -
spinUpStep
A step: spin up and wait until ready (or the ready timeout). -
shootStep
A step: shootcountpieces and wait until done (or it gives up). -
name
Description copied from interface:SubsystemThe name shown in telemetry and in the hardware check. -
addTelemetry
Shows the state, shots left and READY; problems as warnings; then the flywheel, feeder and hood.- Specified by:
addTelemetryin interfaceSubsystem
-