Class SoftLimits

java.lang.Object
com.crossbotics.ftchelper.safety.SoftLimits

public final class SoftLimits extends Object
The rule that keeps a mechanism inside its safe range. No hardware here; SafeMotor uses it.

Rules, in order:

  1. Power that pushes past a limit (position or limit switch) becomes 0. Power that moves AWAY from the limit is always allowed.
  2. 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 Type
    Method
    Description
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 now
      min - lowest allowed position
      max - highest allowed position
      slowZone - 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 1
      atLowerSwitch - 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