Package com.crossbotics.ftchelper.safety
Class JamDetector
java.lang.Object
com.crossbotics.ftchelper.safety.JamDetector
Tells when a motor is jammed: it is asked to spin but barely turns (or draws too much current)
for a while. No hardware here;
SpinMotor and MotorFeeder use it.
Why it matters: a jammed motor gets hot, drains the battery and can strip gears or burn out. Noticing the jam lets your code back the game piece out instead.
JamDetector jam = new JamDetector(50, 0.3); // slower than 50 ticks/s for 0.3 s = jammed
// every loop:
if (jam.update(power, motor.getVelocity(), getRuntime())) { ...back it out... }
Docs: docs/modules/safety.md (section "JamDetector")-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidreset()Starts over (after clearing a jam).setMaxCurrent(double amps) Also counts as jammed when the current is above this many amps (for the same time).setMinPower(double power) Below this power the motor is not really trying, so it is never "jammed".booleanupdate(double power, double speed, double nowSec) Checks speed only.booleanupdate(double power, double speed, double amps, double nowSec) Checks speed and current.
-
Constructor Details
-
JamDetector
public JamDetector(double minSpeed, double timeSec) - Parameters:
minSpeed- slowest normal speed while powered (ticks per second, any sign)timeSec- how long it must be too slow before it counts as jammed
-
-
Method Details
-
setMinPower
Below this power the motor is not really trying, so it is never "jammed". Default 0.15. -
setMaxCurrent
Also counts as jammed when the current is above this many amps (for the same time). -
update
public boolean update(double power, double speed, double nowSec) Checks speed only. Call every loop.- Parameters:
power- the power you are sendingspeed- the measured speed (ticks per second)nowSec- the time now, in seconds- Returns:
- true while jammed
-
update
public boolean update(double power, double speed, double amps, double nowSec) Checks speed and current. Call every loop.- Parameters:
power- the power you are sendingspeed- the measured speed (ticks per second)amps- the measured current (0 if you do not measure it)nowSec- the time now, in seconds- Returns:
- true while jammed
-
reset
public void reset()Starts over (after clearing a jam).
-