Class ServoDevice

java.lang.Object
com.cdarobotics.cdalib.devices.Device
com.cdarobotics.cdalib.devices.actuators.ServoDevice

public class ServoDevice extends Device
A Device wrapping a Servo. Position commands are cached and only written to hardware in update() when the target has changed, collapsing redundant bus writes.
  • Constructor Details

    • ServoDevice

      public ServoDevice(com.qualcomm.robotcore.hardware.Servo servo)
      Wraps an already-resolved servo.
    • ServoDevice

      public ServoDevice(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String name)
      Resolves the servo from the hardware map by configured name.
  • Method Details

    • setPosition

      public ServoDevice setPosition(double position)
      Sets the position to command on the next update(). Range [0.0, 1.0].
    • getPosition

      public double getPosition()
      Returns:
      the last commanded position (not necessarily yet flushed to hardware).
    • setDirection

      public ServoDevice setDirection(com.qualcomm.robotcore.hardware.Servo.Direction direction)
      Sets the servo's direction.
    • scaleRange

      public ServoDevice scaleRange(double min, double max)
      Constrains the usable range of the servo. See Servo.scaleRange(double, double).
    • getServo

      public com.qualcomm.robotcore.hardware.Servo getServo()
      Returns:
      the wrapped SDK servo, for operations not exposed here.
    • update

      public void update()
      Description copied from class: Device
      Flush pending writes to, or refresh cached reads from, the underlying hardware.
      Specified by:
      update in class Device