com.qualcomm.robotcore.hardware

## Class ServoImpl

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

- All Implemented Interfaces:
    HardwareDevice, Servo
  Direct Known Subclasses:
    ServoImplEx

      public class ServoImpl
      extends java.lang.Object
      implements Servo

  ServoImpl provides an implementation of the Servo interface that operates on top of an instance of the ServoController interface.

- - ### Nested Class Summary

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

      `Servo.Direction`

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

      `HardwareDevice.Manufacturer`

  - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected ServoController` | `controller`
    `protected Servo.Direction` | `direction`
    `protected double` | `limitPositionMax`
    `protected double` | `limitPositionMin`
    `protected int` | `portNumber`

    - ### Fields inherited from interface com.qualcomm.robotcore.hardware.Servo

      `MAX_POSITION, MIN_POSITION`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ServoImpl(ServoController controller, int portNumber)` Constructor
    `ServoImpl(ServoController controller, int portNumber, Servo.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()` Get Servo Controller
    `java.lang.String` | `getDeviceName()` Returns a string suitable for display to the user as to the type of device.
    `Servo.Direction` | `getDirection()` Get the direction
    `HardwareDevice.Manufacturer` | `getManufacturer()` Returns an indication of the manufacturer of this device.
    `int` | `getPortNumber()` Get Channel
    `double` | `getPosition()` Returns the position to which the servo was last commanded, or Double.NaN if that is unavailable.
    `int` | `getVersion()` Version
    `protected void` | `internalSetPosition(double position)`
    `void` | `resetDeviceConfigurationForOpMode()` Resets the device's configuration to that which is expected at the beginning of an OpMode.
    `void` | `scaleRange(double min, double max)` Automatically scales the position of the servo.
    `void` | `setDirection(Servo.Direction direction)` Set the direction
    `void` | `setPosition(double position)` Commands the servo to move to a designated position.

    - ### 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 Servo.Direction direction

    - #### limitPositionMin

          protected double limitPositionMin

    - #### limitPositionMax

          protected double limitPositionMax

  - ### Constructor Detail

    - #### ServoImpl

          public ServoImpl(ServoController controller,
                           int portNumber)

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

    - #### ServoImpl

          public ServoImpl(ServoController controller,
                           int portNumber,
                           Servo.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()

      Get Servo Controller
      Specified by:
        `getController` in interface `Servo`
      Returns:
        servo controller
      See Also:
        `Servo.getPortNumber()`

    - #### setDirection

          public void setDirection(Servo.Direction direction)

      Set the direction
      Specified by:
        `setDirection` in interface `Servo`
      Parameters:
        `direction` - direction
      See Also:
        `Servo.getDirection()`, `Servo.Direction`

    - #### getDirection

          public Servo.Direction getDirection()

      Get the direction
      Specified by:
        `getDirection` in interface `Servo`
      Returns:
        direction
      See Also:
        `Servo.setDirection(Direction)`

    - #### getPortNumber

          public int getPortNumber()

      Get Channel
      Specified by:
        `getPortNumber` in interface `Servo`
      Returns:
        channel
      See Also:
        `Servo.getController()`

    - #### setPosition

          public void setPosition(double position)

      Commands the servo to move to a designated position. This method initiates the movement; the servo will arrive at the commanded position at some later time.
      Specified by:
        `setPosition` in interface `Servo`
      Parameters:
        `position` - the commanded servo position. Should be in the range [0.0, 1.0].
      See Also:
        `getPosition()`

    - #### internalSetPosition

          protected void internalSetPosition(double position)

    - #### getPosition

          public double getPosition()

      Returns the position to which the servo was last commanded, or Double.NaN if that is unavailable.
      Specified by:
        `getPosition` in interface `Servo`
      Returns:
        the last commanded position
      See Also:
        `setPosition(double)`, `Double.isNaN(double)`

    - #### scaleRange

          public void scaleRange(double min,
                                 double max)

      Automatically scales the position of the servo.
      Specified by:
        `scaleRange` in interface `Servo`
      Parameters:
        `min` - the lower limit of the servo movement range, a value in the interval [0.0, 1.0]
        `max` - the upper limit of the servo movement range, a value in the interval [0.0, 1.0]
      See Also:
        `Servo.setPosition(double)`