Class Zone

java.lang.Object
com.crossbotics.ftchelper.robot.Zone

public final class Zone extends Object
One side of an interlock rule (Interlock): the space one part must not be in while the other part is in its own zone. Made in Robot.java from the part, with its numbers in the rule's Tunables.java section:

 keepApart("TurretLift", turret.zone(), lift.zoneAbove());          // Robot.java

 public static class TurretLift {                                    // Tunables.java
     public static double turretFrom = 154, turretTo = 218;          // degrees: the turret's zone
     public static double liftAbove = 620;                           // counts: the lift's zone
 }
 
  • part.zone(): between two numbers, <part>From and <part>To.
  • part.zoneAbove(): from <part>Above up (to the top of its range).
  • part.zoneBelow(): from <part>Below down.
  • when(String, BooleanSupplier): a condition, for something the library cannot move (your own sensor or device): the other part keeps out while it is true.

<part> is the part's Tunables section name with a small first letter ("Turret" gives turretFrom, "IntakeDeploy" gives intakeDeployFrom). The numbers are in the part's own units: degrees for a turret or an arm, counts for a lift, the servo position (0 to 1) for a claw, wrist or positioner, the hood's scale for a hood. A turret's zone repeats every 360 degrees (a zone from 154 to 218 is also -206 to -142).

Optional: <part>Margin, the extra safety distance, and <part>StopSec, how long a motor part takes to stop (see Interlock). Docs: docs/modules/robot.md (section "Interlock")

  • Method Details

    • when

      public static Zone when(String words, BooleanSupplier condition)
      A condition instead of a part's position, for something the library cannot hold back (your own sensor or device). While it is true, the other part of the rule keeps out of its zone (or, already in it, may only move out). It never moves anything itself.
      
       keepApart("ArmBucket", arm.zoneBelow(), Zone.when("the bucket is up", () -> bucketUp.isPressed()));
       
      Parameters:
      words - what it means, for the Driver Station ("the bucket is up")
      condition - true = "in its zone"; asked every loop, so it must be quick (no waiting)
    • part

      public Module<?> part()
    • words

      public String words()
      The zone in words, e.g. "between 154 and 218 deg", "above 620 counts", "the bucket is up".