Class TrackingStop
java.lang.Object
frc.spectrumLib.mechanism.TrackingStop
Latches a mechanism to a stop once it has stayed out of tolerance of its closed-loop goal for a
debounce time: a jam, a slipped belt, a motor fighting a hard stop. The pattern is 6328's 2025
elevator, which stopped itself the same way rather than pushing into whatever held it.
Pure logic on values the caller reads from logged inputs, so it replays. The caller holds the
motor in neutral while isStopped().
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Releases the stop: the operator's override.doubledoublebooleanisFault()The error has been out of tolerance for the debounce time, whether or not that stops.booleanThe mechanism is held in neutral until disabled or cleared.booleanupdate(double nowSeconds, boolean enabled, boolean connected, boolean closedLoop, double error, boolean act) Advances one loop.
-
Constructor Details
-
TrackingStop
public TrackingStop(double tolerance, double debounceSeconds) - Parameters:
tolerance- largest error that counts as tracking, in the units of the error passed toupdate(double, boolean, boolean, boolean, double, boolean)debounceSeconds- how long the error must stay out before it is a fault
-
-
Method Details
-
update
public boolean update(double nowSeconds, boolean enabled, boolean connected, boolean closedLoop, double error, boolean act) Advances one loop.- Parameters:
nowSeconds- the robot clockenabled- the robot is enabled; disabling clears the stopconnected- the motor answered this loop. A disconnected motor's readings are stale or zero, so they restart the debounce instead of counting toward it.closedLoop- the motor ran a closed-loop setpoint since the last looperror- measured minus goalact- latch the stop on a fault;falseonly reports the fault- Returns:
trueon the loop the stop latches
-
clear
public void clear()Releases the stop: the operator's override. -
isFault
public boolean isFault()The error has been out of tolerance for the debounce time, whether or not that stops. -
isStopped
public boolean isStopped()The mechanism is held in neutral until disabled or cleared. -
getTolerance
public double getTolerance() -
getDebounceSeconds
public double getDebounceSeconds()
-