public interface Servo extends HardwareDevice
Modifier and Type | Interface and Description |
---|---|
static class |
Servo.Direction
Servos can be configured to internally reverse the values
to which their positioning power is set.
|
HardwareDevice.Manufacturer
Modifier and Type | Field and Description |
---|---|
static double |
MAX_POSITION
The maximum allowable position to which a servo can be moved
|
static double |
MIN_POSITION
The minimum allowable position to which a servo can be moved
|
Modifier and Type | Method and Description |
---|---|
ServoController |
getController()
Returns the underlying servo controller on which this servo is situated.
|
Servo.Direction |
getDirection()
Returns the current logical direction in which this servo is set as operating.
|
int |
getPortNumber()
Returns the port number on the underlying servo controller on which this motor is situated.
|
double |
getPosition()
Returns the position to which the servo was last commanded to move.
|
void |
scaleRange(double min,
double max)
Scales the available movement range of the servo to be a subset of its maximum range.
|
void |
setDirection(Servo.Direction direction)
Sets the logical direction in which this servo operates.
|
void |
setPosition(double position)
Sets the current position of the servo, expressed as a fraction of its available
range.
|
close, getConnectionInfo, getDeviceName, getManufacturer, getVersion, resetDeviceConfigurationForOpMode
static final double MIN_POSITION
setPosition(double)
,
Constant Field Valuesstatic final double MAX_POSITION
setPosition(double)
,
Constant Field ValuesServoController getController()
getPortNumber()
int getPortNumber()
getController()
void setDirection(Servo.Direction direction)
direction
- the direction to set for this servogetDirection()
,
Servo.Direction
Servo.Direction getDirection()
setDirection(Direction)
void setPosition(double position)
position
- the position to which the servo should move, a value in the range [0.0, 1.0]ServoController.pwmEnable()
,
getPosition()
double getPosition()
setPosition(double)
,
Double.NaN
,
Double.isNaN()
void scaleRange(double min, double max)
setPosition()
each time.
For example, if scaleRange(0.2, 0.8) is set; then servo positions will be
scaled to fit in that range:
setPosition(0.0) scales to 0.2
setPosition(1.0) scales to 0.8
setPosition(0.5) scales to 0.5
setPosition(0.25) scales to 0.35
setPosition(0.75) scales to 0.65
Note the parameters passed here are relative to the underlying full range of motion of the servo, not its currently scaled range, if any. Thus, scaleRange(0.0, 1.0) will reset the servo to its full range of movement.
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]setPosition(double)