Class CRServoDevice

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

public class CRServoDevice extends Device
A Device wrapping a CRServo (continuous-rotation servo). Power commands are cached and only written to hardware in update() when the target has changed.
  • Constructor Summary

    Constructors
    Constructor
    Description
    CRServoDevice(com.qualcomm.robotcore.hardware.CRServo servo)
    Wraps an already-resolved CR servo.
    CRServoDevice(com.qualcomm.robotcore.hardware.HardwareMap hardwareMap, String name)
    Resolves the CR servo from the hardware map by configured name.
  • Method Summary

    Modifier and Type
    Method
    Description
    double
     
    com.qualcomm.robotcore.hardware.CRServo
     
    setDirection(com.qualcomm.robotcore.hardware.DcMotorSimple.Direction direction)
    Sets the CR servo's direction.
    setPower(double power)
    Sets the power to command on the next update().
    void
    Flush pending writes to, or refresh cached reads from, the underlying hardware.

    Methods inherited from class java.lang.Object

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

    • CRServoDevice

      public CRServoDevice(com.qualcomm.robotcore.hardware.CRServo servo)
      Wraps an already-resolved CR servo.
    • CRServoDevice

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

    • setPower

      public CRServoDevice setPower(double power)
      Sets the power to command on the next update(). Range [-1.0, 1.0].
    • getPower

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

      public CRServoDevice setDirection(com.qualcomm.robotcore.hardware.DcMotorSimple.Direction direction)
      Sets the CR servo's direction.
    • getServo

      public com.qualcomm.robotcore.hardware.CRServo getServo()
      Returns:
      the wrapped SDK CR 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