public class Servo
extends java.lang.Object
Servo
represents any physical servo on that is connected to the robot.Modifier and Type | Field and Description |
---|---|
private com.qualcomm.robotcore.hardware.Servo |
baseServo
The servo that this object is based on.
|
static double |
CENTER_POSITION
The default center position of the servo.
|
private double |
centerPos
The 'center' position of this servo.
|
static double |
MAX_POSITION
The maximum position of the servo.
|
static double |
MIN_POSITION
The minimum position of the servo.
|
Constructor and Description |
---|
Servo(com.qualcomm.robotcore.hardware.Servo baseServo)
Constructs a new servo that uses the given robotcore
Servo as a base. |
Modifier and Type | Method and Description |
---|---|
void |
center()
Moves the servo to its center position.
|
double |
getCenterPosition()
Gets the 'center' position of this servo.
|
java.lang.String |
getName()
Gets the name of the device as it is defined in the configuration file.
|
double |
getPosition()
Gets the current position of this servo.
|
void |
move(double increment)
Moves the servo to its current position plus the given increment.
|
void |
moveToPosition(double position)
Moves the servo to the given position.
|
void |
setCenterPosition(double position)
Sets the 'center' position of this servo.
|
java.lang.String |
toString() |
private com.qualcomm.robotcore.hardware.Servo baseServo
private double centerPos
CENTER_POSITION
.public static final double MIN_POSITION
public static final double MAX_POSITION
public static final double CENTER_POSITION
public Servo(com.qualcomm.robotcore.hardware.Servo baseServo)
Servo
as a base.baseServo
- the base robotcore Servo
public java.lang.String getName()
public double getCenterPosition()
centerPos
public void setCenterPosition(double position)
position
- the new 'center' position of this servo.centerPos
public double getPosition()
public void moveToPosition(double position)
position
- the position to move to.public void move(double increment)
increment
- the change in servo position.public void center()
public java.lang.String toString()
toString
in class java.lang.Object