Package com.crossbotics.ftchelper.drive
Class StallDetector
java.lang.Object
com.crossbotics.ftchelper.drive.StallDetector
Tells when a move is stuck: the distance left has not gone down enough for a while.
Used by
AutoDrive; you can use it for any mechanism with a target.
StallDetector stall = new StallDetector(0.25, 0.4); // 0.25 in of progress within 0.4 s
// every loop:
if (stall.update(inchesLeft, seconds)) { ... stuck ... }
This checks progress over a time window, not per loop, so it works the same at any loop speed. (At 200 loops a second each loop moves only a tiny bit, so "did it move this loop?" would give false alarms; "did it move 0.25 in during the last 0.4 s?" does not.) Docs: docs/modules/drive.md (section "StallDetector")
-
Constructor Summary
Constructors -
Method Summary
-
Constructor Details
-
StallDetector
public StallDetector(double minProgress, double windowSec) - Parameters:
minProgress- how much closer the move must get within the window (same unit as "remaining")windowSec- the window, seconds
-
-
Method Details
-
update
public boolean update(double remaining, double timeSec) Call every loop.- Parameters:
remaining- how far is left to go (any unit, must go down as you move)timeSec- the time now, seconds (any starting point)- Returns:
- true if stuck. Never true when
remainingis already withinminProgress.
-
reset
public void reset()Starts over. Call before a new move.
-