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 enumHow strict the launcher is before it feeds a piece.static enumWhat the launcher is doing (for telemetry). -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleHow long a problem ("gave up: turret aimed") stays as a warning on the Driver Station, seconds.static final doubleSPRAY feeds only when the wheel turns at least this share of its target speed (0.5). -
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, or null if there is none.doubleThe degrees added to the table's hood angle (hoodOffset(double)); 0 = none.The last problem (e.g.doubleThe QUICK band in use, RPM.doubleThe QUICK wait limit, seconds (quickMaxWait(double)).doubleThe least time between two pieces, seconds (shotInterval(double)).The shot mode in use.doubleThe shot speed beforespeedScale: fromsetRpm(double)or the table (RPM; 0 = none yet).intPieces fed since the OpMode started.intShots still waiting to be fired.What each fed piece did to the wheel: for tuning the shot modes (debug lines).doubleThe shot speed's multiplier (speedScale): 1 = as set.getState()What it is doing now (seeLauncher.State).getTable()The shot table given withtable, or null.booleanhasTable()True if a shot table was given (setDistance(double)works).hood(AngleDevice hoodServo) A hood: aPositionServowithdegrees(...)set, or anyAngleDevice(the five-filesHood, a motor, your own).hoodDeadband(double degrees) The hood moves only when the table's angle changes by more than this (degrees, default 0.25).voidhoodOffset(double degrees) Degrees added to the table's hood angle bysetDistance(double)(a hood trim: +1 = every shot 1 degree more).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.quickBand(double rpm) QUICK: after the volley's first piece, feed when the wheel is within this many RPM of its speed.quickMaxWait(double seconds) QUICK: after the volley's first piece, feed after waiting this long at most, seconds.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: the speed, and the hood angle (plushoodOffset(double)) when there is a hood and the table has hood angles.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.shotMode(Launcher.ShotMode shotMode) How strict it is before each feed (seeLauncher.ShotMode).voidspeedScale(double scale) Multiplies the shot speed (fromsetRpm(double)or the table) by this, e.g.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.
-
Field Details
-
SPRAY_MIN_SHARE
public static final double SPRAY_MIN_SHARESPRAY feeds only when the wheel turns at least this share of its target speed (0.5).- See Also:
-
PROBLEM_SHOW_SEC
public static final double PROBLEM_SHOW_SECHow long a problem ("gave up: turret aimed") stays as a warning on the Driver Station, seconds.- See Also:
-
-
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: aPositionServowithdegrees(...)set, or anyAngleDevice(the five-filesHood, a motor, your own). The table's hood angle goes to it (only from a table with hood angles, seeShotTable.hasHood()), and the launcher waits for it to arrive before feeding ("hood" inwhyNotReady()). -
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. -
hoodDeadband
The hood moves only when the table's angle changes by more than this (degrees, default 0.25). A camera's distance jitters a little every picture; without this the hood would be sent a new angle every loop, and a servo that is always "moving" never lets the launcher feed.- Parameters:
degrees- 0 or more, in the hood's scale (a hood in servo positions: e.g. 0.005); 0 = send every change
-
shotMode
How strict it is before each feed (seeLauncher.ShotMode). Default CAREFUL. Takes effect at the next piece. -
getShotMode
The shot mode in use. -
quickBand
QUICK: after the volley's first piece, feed when the wheel is within this many RPM of its speed. Default: 3 x the flywheel's ready band (its tolerance). -
quickMaxWait
QUICK: after the volley's first piece, feed after waiting this long at most, seconds. Default 0.3. -
getShotInterval
public double getShotInterval()The least time between two pieces, seconds (shotInterval(double)). -
getQuickMaxWait
public double getQuickMaxWait()The QUICK wait limit, seconds (quickMaxWait(double)). -
getQuickBand
public double getQuickBand()The QUICK band in use, RPM. -
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: the speed, and the hood angle (plushoodOffset(double)) when there is a hood and the table has hood angles. Distance in the table's unit (inches in the examples). Safe to call every loop, e.g. with the camera's distance: the hood is only sent a new angle when it changes by more thanhoodDeadband(double)(0.25 deg). -
hoodOffset
public void hoodOffset(double degrees) Degrees added to the table's hood angle bysetDistance(double)(a hood trim: +1 = every shot 1 degree more). 0 = as the table says (the default). Takes effect at the next setDistance.- Parameters:
degrees- e.g. +1 or -0.5
-
getHoodOffset
public double getHoodOffset()The degrees added to the table's hood angle (hoodOffset(double)); 0 = none. -
getTable
The shot table given withtable, or null. -
speedScale
public void speedScale(double scale) Multiplies the shot speed (fromsetRpm(double)or the table) by this, e.g. 1.03 = 3% faster: a live trim for a match (a tired battery, a worn wheel), not a new table. Not the idle speed. 1 = as set (the default). The robot in five files' speed trim uses it.- Parameters:
scale- 0.5 to 1.5 (kept to that); 1.03 = +3%
-
getShotRpm
public double getShotRpm()The shot speed beforespeedScale: fromsetRpm(double)or the table (RPM; 0 = none yet). -
getSpeedScale
public double getSpeedScale()The shot speed's multiplier (speedScale): 1 = as set. -
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. -
getShotStats
What each fed piece did to the wheel: for tuning the shot modes (debug lines). -
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, 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
-