Class MotorFeeder

java.lang.Object
com.crossbotics.ftchelper.launcher.MotorFeeder
All Implemented Interfaces:
Subsystem, Feeder

public class MotorFeeder extends Object implements Feeder
A feeder driven by a motor (a roller, belt or indexer wheel): runs for a set time per piece, or until a sensor sees the piece leave.

 Feeder feeder = MotorFeeder.create(hardwareMap, "feeder")
         .power(1.0)
         .feedTime(0.25)                         // seconds per piece
         .jamDetection(60, 0.2);                 // optional, needs the encoder cable
 

The Launcher calls feedOne(); this class then times the feed in update(), without ever waiting. Docs: docs/modules/launcher.md

  • Constructor Summary

    Constructors
    Constructor
    Description
    MotorFeeder(String name, com.qualcomm.robotcore.hardware.DcMotorEx motor)
    Wraps a motor you already set up.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    A JAMMED warning; "feeding" or "idle" in debug mode.
    void
    Clears the jam flag.
    create(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String name)
    Gets the motor (brake, plain power).
    void
    Starts feeding one piece: the motor turns on now, and update() turns it off.
    feedTime(double seconds)
    Seconds to run per piece (also the longest it waits for the sensor).
    boolean
    True until the piece is through and the feeder is ready for the next one.
    boolean
    True if the feeder is jammed (then the launcher stops shooting).
    jamDetection(double minSpeed, double seconds)
    Jam detection: slower than minSpeed ticks/s for seconds while feeding.
    The name shown in telemetry and in the hardware check.
    power(double p)
    Power while feeding, -1 to 1.
    Positive power turns the other way.
    void
    Stops the motor at once and ends any feed.
    stopWhen(BooleanSupplier pieceHasLeft)
    Stop as soon as this is true (e.g.
    void
    Once per loop: ends the feed when the time is up, the sensor sees the piece leave, or it jams.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • MotorFeeder

      public MotorFeeder(String name, com.qualcomm.robotcore.hardware.DcMotorEx motor)
      Wraps a motor you already set up.
  • Method Details

    • create

      public static MotorFeeder create(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String name)
      Gets the motor (brake, plain power).
    • reversed

      public MotorFeeder reversed()
      Positive power turns the other way.
    • power

      public MotorFeeder power(double p)
      Power while feeding, -1 to 1. Default 1.
    • feedTime

      public MotorFeeder feedTime(double seconds)
      Seconds to run per piece (also the longest it waits for the sensor). Default 0.25.
    • stopWhen

      public MotorFeeder stopWhen(BooleanSupplier pieceHasLeft)
      Stop as soon as this is true (e.g. a beam-break sensor sees the piece leave). Example: stopWhen(() -> beam.isBroken()): () -> ... is a small question handed over to be asked every loop.
    • jamDetection

      public MotorFeeder jamDetection(double minSpeed, double seconds)
      Jam detection: slower than minSpeed ticks/s for seconds while feeding.
    • feedOne

      public void feedOne()
      Starts feeding one piece: the motor turns on now, and update() turns it off. Ignored while busy.
      Specified by:
      feedOne in interface Feeder
    • update

      public void update()
      Once per loop: ends the feed when the time is up, the sensor sees the piece leave, or it jams.
      Specified by:
      update in interface Subsystem
    • 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
    • stop

      public void stop()
      Stops the motor at once and ends any feed. (A jam stays marked until clearJam().)
      Specified by:
      stop in interface Subsystem
    • clearJam

      public void clearJam()
      Clears the jam flag. The launcher calls this when the driver asks to shoot again.
      Specified by:
      clearJam in interface Feeder
    • 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)
      A JAMMED warning; "feeding" or "idle" in debug mode.
      Specified by:
      addTelemetry in interface Subsystem