Class Launcher

java.lang.Object
com.crossbotics.ftchelper.launcher.Launcher
All Implemented Interfaces:
Subsystem

public class Launcher extends Object implements 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

  • Constructor Details

    • Launcher

      public Launcher(Flywheel flywheel, Feeder feeder)
      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

      public Launcher hood(PositionServo hoodServo)
      A hood servo that has degrees(...) set. The table's hood angle goes to it.
    • table

      public Launcher table(ShotTable shotTable)
      A shot table, used by setDistance(double).
    • requireReady

      public Launcher requireReady(String checkName, BooleanSupplier check)
      Another condition that must be true before each piece is fed (aim, sensor, anything). checkName is shown by whyNotReady() 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

      public Launcher clearReadyChecks()
      Removes every requireReady(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

      public Launcher shotInterval(double seconds)
      Least time between two pieces, seconds. Default 0.25.
    • readyTimeout

      public Launcher readyTimeout(double seconds)
      Give up the remaining shots if not ready within this many seconds. Default 3.
    • idleRpm

      public Launcher idleRpm(double rpm)
      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). Use stop() for fully off.
    • shoot

      public void shoot(int count)
      Shoots count pieces (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().
      Specified by:
      stop in interface Subsystem
    • 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.
      Specified by:
      update in interface Subsystem
    • isReady

      public boolean isReady()
      True when the flywheel is at speed, the hood has arrived, and every check passes.
    • whyNotReady

      public String whyNotReady()
      What is not ready yet, e.g. "flywheel, Turret" ("" when ready).
    • getState

      public Launcher.State getState()
      What it is doing now (see Launcher.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

      public String getLastProblem()
      The last problem (e.g. why it gave up), or "".
    • getFlywheel

      public Flywheel getFlywheel()
      The flywheel inside.
    • getHood

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

      public AutoStep spinUpStep()
      A step: spin up and wait until ready (or the ready timeout).
    • shootStep

      public AutoStep shootStep(int count)
      A step: shoot count pieces and wait until done (or it gives up).
    • name

      public String name()
      Description copied from interface: Subsystem
      The name shown in telemetry and in the hardware check.
      Specified by:
      name in interface Subsystem
    • addTelemetry

      public void addTelemetry(RobotTelemetry t)
      Shows the state, shots left and READY; problems as warnings; then the flywheel, feeder and hood.
      Specified by:
      addTelemetry in interface Subsystem