Class MotorFeeder
java.lang.Object
com.crossbotics.ftchelper.launcher.MotorFeeder
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
ConstructorsConstructorDescriptionMotorFeeder(String name, com.qualcomm.robotcore.hardware.DcMotorEx motor) Wraps a motor you already set up. -
Method Summary
Modifier and TypeMethodDescriptionvoidA JAMMED warning; "feeding" or "idle" in debug mode.voidclearJam()Clears the jam flag.static MotorFeederGets the motor (brake, plain power).voidfeedOne()Starts feeding one piece: the motor turns on now, andupdate()turns it off.feedTime(double seconds) Seconds to run per piece (also the longest it waits for the sensor).booleanisBusy()True until the piece is through and the feeder is ready for the next one.booleanisJammed()True if the feeder is jammed (then the launcher stops shooting).jamDetection(double minSpeed, double seconds) Jam detection: slower thanminSpeedticks/s forsecondswhile feeding.name()The name shown in telemetry and in the hardware check.power(double p) Power while feeding, -1 to 1.reversed()Positive power turns the other way.voidstop()Stops the motor at once and ends any feed.stopWhen(BooleanSupplier pieceHasLeft) Stop as soon as this is true (e.g.voidupdate()Once per loop: ends the feed when the time is up, the sensor sees the piece leave, or it jams.
-
Constructor Details
-
MotorFeeder
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
Positive power turns the other way. -
power
Power while feeding, -1 to 1. Default 1. -
feedTime
Seconds to run per piece (also the longest it waits for the sensor). Default 0.25. -
stopWhen
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
Jam detection: slower thanminSpeedticks/s forsecondswhile feeding. -
feedOne
public void feedOne()Starts feeding one piece: the motor turns on now, andupdate()turns it off. Ignored while busy. -
update
public void update()Once per loop: ends the feed when the time is up, the sensor sees the piece leave, or it jams. -
isBusy
public boolean isBusy()Description copied from interface:FeederTrue until the piece is through and the feeder is ready for the next one. -
isJammed
public boolean isJammed()Description copied from interface:FeederTrue 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. -
stop
public void stop()Stops the motor at once and ends any feed. (A jam stays marked untilclearJam().) -
clearJam
public void clearJam()Clears the jam flag. The launcher calls this when the driver asks to shoot again. -
name
Description copied from interface:SubsystemThe name shown in telemetry and in the hardware check. -
addTelemetry
A JAMMED warning; "feeding" or "idle" in debug mode.- Specified by:
addTelemetryin interfaceSubsystem
-