Package com.crossbotics.ftchelper.safety
Class SoftLimits
java.lang.Object
com.crossbotics.ftchelper.safety.SoftLimits
The rule that keeps a mechanism inside its safe range. No hardware here;
SafeMotor
uses it.
Rules, in order:
- Power that pushes past a limit (position or limit switch) becomes 0. Power that moves AWAY from the limit is always allowed.
- Inside the "slow zone" near a limit, power toward that limit is scaled down, so the mechanism does not slam into the end.
These are "soft" (software) limits. The robot still needs a hard stop (a physical block): if the software is ever wrong, the block holds. Docs: docs/modules/safety.md (section "SoftLimits")
-
Method Summary
Modifier and TypeMethodDescriptionstatic doublelimit(double power, double position, double min, double max, double slowZone, double slowZonePower, boolean atLowerSwitch, boolean atUpperSwitch) Applies the limits to a power.
-
Method Details
-
limit
public static double limit(double power, double position, double min, double max, double slowZone, double slowZonePower, boolean atLowerSwitch, boolean atUpperSwitch) Applies the limits to a power.- Parameters:
power- the power you want, -1 to 1 (positive = toward max)position- where the mechanism is nowmin- lowest allowed positionmax- highest allowed positionslowZone- distance from a limit where power toward it is reduced (0 = no slow zone)slowZonePower- the largest power allowed right at the limit edge of the slow zone, 0 to 1atLowerSwitch- true if a lower limit switch is pressed (false if there is none)atUpperSwitch- true if an upper limit switch is pressed (false if there is none)- Returns:
- the safe power
-