Class Indexer

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

public final class Indexer extends Module<Indexer> implements Feeder
Feeds ONE game piece at a time into a launcher: a servo that pushes, a CR servo or a motor that runs for a moment. Usually given to a Launcher, which decides when to feed:

 launcher = add(Launcher.flywheel("launcher", "gobilda-5203-6000").feeder(Indexer.servo("indexer")));

 public static class Indexer {                       // Tunables.java
     public static double rest = 0.15, push = 0.55;  // servo positions (Indexer.servo)
     public static double pushSec = 0.25, returnSec = 0.25;
 }
 

Two arms that push together (one on each side, pinching behind the piece): Indexer.servo("feeder_left").alsoServoReversed("feeder_right"). They share one Tunables section (the first name's): the second arm mirrors the first; alsoTrim lines it up.

Two wheels that spin together (one on each side of the piece, squeezing it in): Indexer.crServo("feeder_left").alsoServoReversed("feeder_right"). Both CR servos get the same power; the second spins the other way. They share one Tunables section (the first name's).

Tunables: Indexer.servo: rest, push, pushSec, returnSec (and alsoTrim with a second servo). Indexer.crServo and Indexer.motor: power and feedSec (how long it runs per piece), and stopOnShot (true: a launcher's feed stops when the flywheel sees the shot, and feedSec is the time limit). Added on its own (no launcher), its usual button (a line in Controls.java) is operator RB: feed one.

A feed wheel (Launcher.feedWheel(Indexer.crServo("feeder_wheel"))): a CR servo or motor that moves the pieces up to the pusher (the launcher's feeder). Its Tunables: power, alwaysOn (false: it runs only while firing), stageSec (it runs this long before the push, 0.2) and stopSec (it stops this long after the push starts, 0.3; below 0 = before the push). Docs: docs/reference/robot-java.md (section "Indexer")

  • Method Details

    • servo

      public static Indexer servo(String name)
      A servo that pushes a piece in, then comes back.
    • fullRange

      public Indexer fullRange()
      A servo indexer uses its servo's whole turn: positions 0 to 1 send the servo's full pulse range (the part's, else 500-2500 us) instead of the FTC SDK's normal 600-2400 us. Set rest and push again after turning it on: the same position points somewhere else.
      Returns:
      this indexer
      Throws:
      IllegalStateException - on a CR servo or motor indexer
    • crServo

      public static Indexer crServo(String name)
      A continuous-rotation servo that runs for a moment per piece.
    • motor

      public static Indexer motor(String name)
      A motor (a roller or belt) that runs for a moment per piece.
    • reversed

      public Indexer reversed()
      It turns the other way.
    • feedOne

      public void feedOne()
      Feeds one piece now (ignored while busy). A launcher usually calls this, when it is ready.
      Specified by:
      feedOne in interface Feeder
    • onFeed

      public void onFeed(Runnable listener)
      Runs listener each time a feed starts (a call while busy is not a feed). A feed that starts may still jam: Pieces counts a piece out only when the feed ends normally (or its ready sensor sees the piece leave).
    • isFeeding

      public boolean isFeeding()
      True from the start of a feed until it ends (normally, jammed or stopped).
    • isBusy

      public boolean isBusy()
      Description copied from interface: Feeder
      True until the piece is through and the feeder is ready for the next one.
      Specified by:
      isBusy in interface Feeder
    • isJammed

      public boolean isJammed()
      Description copied from interface: Feeder
      True if the feeder is jammed (then the launcher stops shooting). Default: never. "default" means a class that does not write this method gets this version.
      Specified by:
      isJammed in interface Feeder
    • clearJam

      public void clearJam()
      Description copied from interface: Feeder
      Forgets a jam (the launcher calls it when the driver asks to shoot again). Default: nothing.
      Specified by:
      clearJam in interface Feeder
    • 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
    • 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
    • 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<Indexer>
    • adjustPush

      public void adjustPush(int steps)
      A push servo: moves the push position by steps x Tunables pushStep (0.01): + = further from rest (a longer push), - = nearer rest. For a D-pad during TeleOp, when the push stops getting the piece all the way (a servo horn that slips, a worn pad): g1.dpadRight.press(() -> robot.launcher.feeder().adjustPush(+1)). Kept until the program ends; the Tunables value is not changed (the screen shows the number to copy into Tunables). Never past rest, never outside 0 to 1. Ignored for a CR servo or motor feeder.
    • pushNow

      public double pushNow()
      The push position in use now: Tunables push plus the adjustPush(int) trim.
    • alsoServoReversed

      public Indexer alsoServoReversed(String name)
      A second push servo that moves with this one, mirrored: two arms, one on each side, that pinch together behind the piece and push it in. Both go to the same rest and push; the second turns the other way (it is mounted facing the first). If the two do not quite meet, set alsoTrim (raw position added for the second one).

      On a CR servo indexer: a second wheel that spins with the first, the other way. Two wheels, one on each side of the piece, that squeeze it and move it in (both servos' shafts up, so they must turn opposite ways). Both get the same power; there is no alsoTrim.

      
       .feeder(Indexer.servo("feeder_left").alsoServoReversed("feeder_right").part("gobilda-2000-torque"))
       .feeder(Indexer.crServo("feeder_left").alsoServoReversed("feeder_right").part("gobilda-2000-speed"))
       
      Parameters:
      name - the second servo's configuration name
      Returns:
      this indexer
      Throws:
      IllegalStateException - on a motor indexer
    • alsoServo

      public Indexer alsoServo(String name)
      Like alsoServoReversed(java.lang.String), for a second servo that turns the same way as the first. For two CR servo wheels: one mounted upside down (shaft down) already spins the other way, so it takes the same power.
      Parameters:
      name - the second servo's configuration name
      Returns:
      this indexer
      Throws:
      IllegalStateException - on a motor indexer
    • secondServoName

      public String secondServoName()
      The second servo's configuration name (alsoServo...), or null if it has one servo.
    • isReversed

      public boolean isReversed()
      True if reversed() is set in Robot.java (positions 0 and 1 swap ends).
    • secondServoMirrored

      public boolean secondServoMirrored()
      True if the second servo mirrors the first (alsoServoReversed).
    • isServo

      public boolean isServo()
      True for a servo that pushes and comes back (not a CR servo or motor that runs).