public class Encoder
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
Encoder.Direction |
Modifier and Type | Field and Description |
---|---|
private com.acmerobotics.roadrunner.util.NanoClock |
clock |
private static int |
CPS_STEP |
private Encoder.Direction |
direction |
private int |
lastPosition |
private double |
lastUpdateTime |
private com.qualcomm.robotcore.hardware.DcMotorEx |
motor |
private double |
velocityEstimate |
Constructor and Description |
---|
Encoder(com.qualcomm.robotcore.hardware.DcMotorEx motor) |
Encoder(com.qualcomm.robotcore.hardware.DcMotorEx motor,
com.acmerobotics.roadrunner.util.NanoClock clock) |
Modifier and Type | Method and Description |
---|---|
double |
getCorrectedVelocity() |
int |
getCurrentPosition() |
Encoder.Direction |
getDirection() |
double |
getRawVelocity() |
private static double |
inverseOverflow(double input,
double estimate) |
void |
setDirection(Encoder.Direction direction)
Allows you to set the direction of the counts and velocity without modifying the motor's direction state
|
private static final int CPS_STEP
private com.qualcomm.robotcore.hardware.DcMotorEx motor
private com.acmerobotics.roadrunner.util.NanoClock clock
private Encoder.Direction direction
private int lastPosition
private double velocityEstimate
private double lastUpdateTime
public Encoder(com.qualcomm.robotcore.hardware.DcMotorEx motor, com.acmerobotics.roadrunner.util.NanoClock clock)
public Encoder(com.qualcomm.robotcore.hardware.DcMotorEx motor)
private static double inverseOverflow(double input, double estimate)
public Encoder.Direction getDirection()
public void setDirection(Encoder.Direction direction)
direction
- either reverse or forward depending on if encoder counts should be negatedpublic int getCurrentPosition()
public double getRawVelocity()
public double getCorrectedVelocity()