com.qualcomm.robotcore.hardware

## Class CRServoImpl

- java.lang.Object
- - com.qualcomm.robotcore.hardware.CRServoImpl

- All Implemented Interfaces:
    CRServo, DcMotorSimple, HardwareDevice
  Direct Known Subclasses:
    CRServoImplEx

      public class CRServoImpl
      extends java.lang.Object
      implements CRServo

  ContinuousRotationServoImpl provides an implementation of continuous rotation servo functionality.

- - ### Nested Class Summary

    - ### Nested classes/interfaces inherited from interface com.qualcomm.robotcore.hardware.DcMotorSimple

      `DcMotorSimple.Direction`

    - ### Nested classes/interfaces inherited from interface com.qualcomm.robotcore.hardware.HardwareDevice

      `HardwareDevice.Manufacturer`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected static double` | `apiPowerMax`
    `protected static double` | `apiPowerMin`
    `protected static double` | `apiServoPositionMax`
    `protected static double` | `apiServoPositionMin`
    `protected ServoController` | `controller`
    `protected DcMotorSimple.Direction` | `direction`
    `protected int` | `portNumber`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `CRServoImpl(ServoController controller, int portNumber)` Constructor
    `CRServoImpl(ServoController controller, int portNumber, DcMotorSimple.Direction direction)` Constructor

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `close()` Closes this device
    `java.lang.String` | `getConnectionInfo()` Get connection information about this device in a human readable format
    `ServoController` | `getController()` Returns the underlying servo controller on which this servo is situated.
    `java.lang.String` | `getDeviceName()` Returns a string suitable for display to the user as to the type of device.
    `DcMotorSimple.Direction` | `getDirection()` Returns the current logical direction in which this motor is set as operating.
    `HardwareDevice.Manufacturer` | `getManufacturer()` Returns an indication of the manufacturer of this device.
    `int` | `getPortNumber()` Returns the port number on the underlying servo controller on which this motor is situated.
    `double` | `getPower()` Returns the current configured power level of the motor.
    `int` | `getVersion()` Version
    `void` | `resetDeviceConfigurationForOpMode()` Resets the device's configuration to that which is expected at the beginning of an OpMode.
    `void` | `setDirection(DcMotorSimple.Direction direction)` Sets the logical direction in which this motor operates.
    `void` | `setPower(double power)` Sets the power level of the motor, expressed as a fraction of the maximum possible power / speed supported according to the run mode in which the motor is operating.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### controller

          protected ServoController controller

    - #### portNumber

          protected int portNumber

    - #### direction

          protected DcMotorSimple.Direction direction

    - #### apiPowerMin

          protected static final double apiPowerMin

      See Also:
        Constant Field Values

    - #### apiPowerMax

          protected static final double apiPowerMax

      See Also:
        Constant Field Values

    - #### apiServoPositionMin

          protected static final double apiServoPositionMin

      See Also:
        Constant Field Values

    - #### apiServoPositionMax

          protected static final double apiServoPositionMax

      See Also:
        Constant Field Values

  - ### Constructor Detail

    - #### CRServoImpl

          public CRServoImpl(ServoController controller,
                             int portNumber)

      Constructor
      Parameters:
        `controller` - Servo controller that this servo is attached to
        `portNumber` - physical port number on the servo controller

    - #### CRServoImpl

          public CRServoImpl(ServoController controller,
                             int portNumber,
                             DcMotorSimple.Direction direction)

      Constructor
      Parameters:
        `controller` - Servo controller that this servo is attached to
        `portNumber` - physical port number on the servo controller
        `direction` - FORWARD for normal operation, REVERSE to reverse operation

  - ### Method Detail

    - #### getManufacturer

          public HardwareDevice.Manufacturer getManufacturer()

      Description copied from interface: `HardwareDevice`
      Returns an indication of the manufacturer of this device.
      Specified by:
        `getManufacturer` in interface `HardwareDevice`
      Returns:
        the device's manufacturer

    - #### getDeviceName

          public java.lang.String getDeviceName()

      Description copied from interface: `HardwareDevice`
      Returns a string suitable for display to the user as to the type of device. Note that this is a device-type-specific name; it has nothing to do with the name by which a user might have configured the device in a robot configuration.
      Specified by:
        `getDeviceName` in interface `HardwareDevice`
      Returns:
        device manufacturer and name

    - #### getConnectionInfo

          public java.lang.String getConnectionInfo()

      Description copied from interface: `HardwareDevice`
      Get connection information about this device in a human readable format
      Specified by:
        `getConnectionInfo` in interface `HardwareDevice`
      Returns:
        connection info

    - #### getVersion

          public int getVersion()

      Description copied from interface: `HardwareDevice`
      Version
      Specified by:
        `getVersion` in interface `HardwareDevice`
      Returns:
        get the version of this device

    - #### resetDeviceConfigurationForOpMode

          public void resetDeviceConfigurationForOpMode()

      Description copied from interface: `HardwareDevice`
      Resets the device's configuration to that which is expected at the beginning of an OpMode. For example, motors will reset the their direction to 'forward'.
      Specified by:
        `resetDeviceConfigurationForOpMode` in interface `HardwareDevice`

    - #### close

          public void close()

      Description copied from interface: `HardwareDevice`
      Closes this device
      Specified by:
        `close` in interface `HardwareDevice`

    - #### getController

          public ServoController getController()

      Description copied from interface: `CRServo`
      Returns the underlying servo controller on which this servo is situated.
      Specified by:
        `getController` in interface `CRServo`
      Returns:
        the underlying servo controller on which this servo is situated.
      See Also:
        `CRServo.getPortNumber()`

    - #### getPortNumber

          public int getPortNumber()

      Description copied from interface: `CRServo`
      Returns the port number on the underlying servo controller on which this motor is situated.
      Specified by:
        `getPortNumber` in interface `CRServo`
      Returns:
        the port number on the underlying servo controller on which this motor is situated.
      See Also:
        `CRServo.getController()`

    - #### setDirection

          public void setDirection(DcMotorSimple.Direction direction)

      Description copied from interface: `DcMotorSimple`
      Sets the logical direction in which this motor operates.
      Specified by:
        `setDirection` in interface `DcMotorSimple`
      Parameters:
        `direction` - the direction to set for this motor
      See Also:
        `DcMotorSimple.getDirection()`

    - #### getDirection

          public DcMotorSimple.Direction getDirection()

      Description copied from interface: `DcMotorSimple`
      Returns the current logical direction in which this motor is set as operating.
      Specified by:
        `getDirection` in interface `DcMotorSimple`
      Returns:
        the current logical direction in which this motor is set as operating.
      See Also:
        `DcMotorSimple.setDirection(Direction)`

    - #### setPower

          public void setPower(double power)

      Description copied from interface: `DcMotorSimple`
      Sets the power level of the motor, expressed as a fraction of the maximum possible power / speed supported according to the run mode in which the motor is operating.

      Setting a power level of zero will brake the motor

      Specified by:
        `setPower` in interface `DcMotorSimple`
      Parameters:
        `power` - the new power level of the motor, a value in the interval [-1.0, 1.0]
      See Also:
        `DcMotorSimple.getPower()`, `DcMotor.setMode(DcMotor.RunMode)`, `DcMotor.setPowerFloat()`

    - #### getPower

          public double getPower()

      Description copied from interface: `DcMotorSimple`
      Returns the current configured power level of the motor.
      Specified by:
        `getPower` in interface `DcMotorSimple`
      Returns:
        the current level of the motor, a value in the interval [0.0, 1.0]
      See Also:
        `DcMotorSimple.setPower(double)`