public class Motor.Encoder
extends java.lang.Object
Encoder
represents a physical encoder that is attached to a specific
motor.Modifier and Type | Field and Description |
---|---|
private static double |
DEFAULT_TICKS_PER_INCH
The default number of encoder ticks that measure one inch on the circumference
of the wheel.
|
private static double |
DEFAULT_TICKS_PER_REVOLUTION
The default number of encoder ticks that measure exactly one full rotation of
the motor.
|
private double |
ticksPerInch
The number of encoder ticks that measure one inch on the circumference of the
wheel.
|
private double |
ticksPerRevolution
The number of encoder ticks that measure exactly one full rotation of the motor.
|
private int |
zeroPoint
The value that should be considered 'zero' on the encoder.
|
Constructor and Description |
---|
Encoder()
Constructs a new encoder that is bound to the motor in which it is constructed.
|
Modifier and Type | Method and Description |
---|---|
double |
getInches()
Gets the current position of the encoder, converted to inches on the wheel
circumference.
|
int |
getPosition()
Gets the current position of the encoder.
|
double |
getRevolutions()
Gets the current position of the encoder with respect to the zero point,
converted to revolutions of the motor.
|
void |
reset()
Resets this encoder.
|
void |
setTicksPerInch(double ticks)
Sets the number of encoder ticks that measure one inch on the circumference of
the wheel.
|
void |
setTicksPerRevolution(double ticks)
Sets the number of encoder ticks that measure exactly one full rotation of the
motor.
|
java.lang.String |
toString() |
private int zeroPoint
private double ticksPerRevolution
private double ticksPerInch
private static final double DEFAULT_TICKS_PER_REVOLUTION
private static final double DEFAULT_TICKS_PER_INCH
public Encoder()
public void reset()
getPosition()
is called immediately after this
method, it will return zero.public int getPosition()
public double getRevolutions()
public double getInches()
public void setTicksPerRevolution(double ticks)
ticks
- the encoder ticks that measure exactly one full rotation of the
motor.ticksPerRevolution
public void setTicksPerInch(double ticks)
ticks
- the encoder ticks that measure one inch on the circumference of the
wheel.ticksPerInch
public java.lang.String toString()
toString
in class java.lang.Object