Class NudgeStep

java.lang.Object
com.crossbotics.ftchelper.finders.NudgeStep

public final class NudgeStep extends Object
The step size for nudging a servo in a finder: D-pad up/down moves the servo by the step, D-pad left/right makes the step smaller/bigger. Big steps get close fast; the smallest (0.001) finds an exact spot, such as the gap two wheels squeeze a game piece through.

The Servo Finder, Feed Stop Finder and Hood Finder all use it, so the buttons are the same in each.


 NudgeStep step = new NudgeStep();       // starts at 0.05
 step.smaller();                         // 0.01
 double p = step.move(0.500, +1);        // 0.510
 
Docs: docs/modules/finders.md. Guide: docs/tuning/03-servo-finder.md
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double[]
    The step sizes, biggest first.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    D-pad right: the next bigger step (stays at the biggest).
     
    double
    move(double position, int direction)
    The position one step away.
    void
    Back to the first step (0.05), for example when another servo is chosen.
    double
     
    void
    D-pad left: the next smaller step (stays at the smallest).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • SIZES

      public static final double[] SIZES
      The step sizes, biggest first. 0.001 is about a quarter of a degree on a 270 degree servo.
  • Constructor Details

    • NudgeStep

      public NudgeStep()
  • Method Details

    • size

      public double size()
      Returns:
      the step now, servo position units (0..1 is the whole range)
    • smaller

      public void smaller()
      D-pad left: the next smaller step (stays at the smallest).
    • bigger

      public void bigger()
      D-pad right: the next bigger step (stays at the biggest).
    • reset

      public void reset()
      Back to the first step (0.05), for example when another servo is chosen.
    • move

      public double move(double position, int direction)
      The position one step away.
      Parameters:
      position - the servo position now, 0..1
      direction - +1 = up (bigger number), -1 = down
      Returns:
      the new position, rounded to 0.001 (so 0.1 + 0.05 shows as 0.150) and kept inside 0..1
    • label

      public String label()
      Returns:
      the step for the screen, e.g. "0.005"