Class PretendServo

java.lang.Object
com.crossbotics.ftchelper.testkit.PretendServo

public class PretendServo extends Object
A pretend servo for JUnit tests: it remembers the position it was sent (NaN = none yet, like a real servo before its first command). Get one from PretendDevices.servo(String).

 robot.claw.close();
 assertEquals(0.70, devices.servo("claw").position, 1e-9);
 
Docs: docs/modules/testkit.md
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    com.qualcomm.robotcore.hardware.Servo.Direction
    FORWARD or REVERSE, as set.
    double
    The last position sent, 0 to 1 (NaN = never sent).
    double[]
    The pulse range set with .fullRange() ({low, high} microseconds), or null (the SDK's 600-2400).
    final com.qualcomm.robotcore.hardware.Servo
    The SDK servo to hand to code that wants one (it is also a PwmControl, like a hub servo).
    int
    How many positions were sent.
  • Constructor Summary

    Constructors
    Constructor
    Description
    A new pretend servo on a hub (it can change its pulse range).
  • Method Summary

    Methods inherited from class java.lang.Object

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

    • position

      public double position
      The last position sent, 0 to 1 (NaN = never sent).
    • writes

      public int writes
      How many positions were sent.
    • direction

      public com.qualcomm.robotcore.hardware.Servo.Direction direction
      FORWARD or REVERSE, as set.
    • pulseUs

      public double[] pulseUs
      The pulse range set with .fullRange() ({low, high} microseconds), or null (the SDK's 600-2400).
    • servo

      public final com.qualcomm.robotcore.hardware.Servo servo
      The SDK servo to hand to code that wants one (it is also a PwmControl, like a hub servo).
  • Constructor Details

    • PretendServo

      public PretendServo()
      A new pretend servo on a hub (it can change its pulse range).