Modifier and Type | Class and Description |
---|---|
static class |
Odometer.LINEDIR |
static class |
Odometer.TURNDIR |
Thread.State, Thread.UncaughtExceptionHandler
Modifier and Type | Field and Description |
---|---|
private double |
data |
private EV3LargeRegulatedMotor |
leftMotor |
private int |
leftMotorTachoCount |
private Object |
mutex |
static int |
NAVIGATE_SPEED |
private double |
oldltacho |
private double |
oldrtacho |
private EV3LargeRegulatedMotor |
rightMotor |
private int |
rightMotorTachoCount |
static int |
ROTATE_SPEED |
private double |
theta |
private double |
x |
private double |
y |
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
Odometer(EV3LargeRegulatedMotor leftMotor,
EV3LargeRegulatedMotor rightMotor)
Odometer Constructor
|
Modifier and Type | Method and Description |
---|---|
void |
backwardMotors()
Have both motors move in reverse
|
private int |
convertAngle(double radius,
double width,
double angle)
Deprecated.
|
private int |
convertDistance(double radius,
double distance)
Deprecated.
|
static double |
euclideanDistance(double[] a,
double[] b)
Euclidean distance between two (x, y) points
|
void |
forwardMotors()
Have both motors move forward
|
double |
getFilteredData()
Deprecated.
|
int |
getLeftMotorTachoCount() |
EV3LargeRegulatedMotor[] |
getMotors()
Returns the motors used by the odometer
|
void |
getPosition(double[] position)
Write coordinates of current position to position
|
void |
getPosition(double[] position,
boolean[] update)
Write coordinates of the current position to an array
|
int |
getRightMotorTachoCount() |
double |
getTheta() |
double |
getX() |
double |
getY() |
void |
moveCM(Odometer.LINEDIR dir,
double distance,
boolean stop)
Move a set distance
|
void |
run()
Start odometer
|
void |
setData(double data)
Deprecated.
|
void |
setLeftMotorTachoCount(int leftMotorTachoCount) |
void |
setMotorSpeed(int speed)
Update motor speeds (deg/s)
|
void |
setMotorSpeeds(int speedL,
int speedR)
Update motor speeds (deg/s)
|
void |
setPosition(double[] position,
boolean[] update)
Overrides the current position in the odometer
|
void |
setRightMotorTachoCount(int rightMotorTachoCount) |
void |
setTheta(double theta) |
void |
setX(double x) |
void |
setY(double y) |
void |
spin(Odometer.TURNDIR dir)
Spin in a certain direction
|
void |
stopMotors()
Stop motors safely
|
void |
travelTo(double x,
double y)
Deprecated.
|
void |
turnBy(double theta)
Deprecated.
|
void |
turnTo(double theta)
Deprecated.
|
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public static final int ROTATE_SPEED
public static final int NAVIGATE_SPEED
private double x
private double y
private double theta
private int leftMotorTachoCount
private int rightMotorTachoCount
private EV3LargeRegulatedMotor leftMotor
private EV3LargeRegulatedMotor rightMotor
private Object mutex
private double oldltacho
private double oldrtacho
private double data
public Odometer(EV3LargeRegulatedMotor leftMotor, EV3LargeRegulatedMotor rightMotor)
leftMotor
- left motor objectrightMotor
- right motor objectpublic void run()
public EV3LargeRegulatedMotor[] getMotors()
public void setMotorSpeeds(int speedL, int speedR)
speedL
- left speedspeedR
- right spedpublic void setMotorSpeed(int speed)
speed
- speed for both motorspublic void forwardMotors()
public void backwardMotors()
public void spin(Odometer.TURNDIR dir)
dir
- direction to spin inpublic void stopMotors()
public void moveCM(Odometer.LINEDIR dir, double distance, boolean stop)
dir
- direction to move indistance
- distance to move (cm)stop
- if the robot should stop after movingpublic void getPosition(double[] position, boolean[] update)
position
- array to hold x, y, and theta coordinatesupdate
- if the x, y, and theta coordinates written to the arraypublic void getPosition(double[] position)
position
- array to hold x, y, and theta coordinatespublic double getX()
public double getY()
public double getTheta()
public void setPosition(double[] position, boolean[] update)
position
- x, y, and theta overridesupdate
- if x, y, and theta should be overriddenpublic void setX(double x)
x
- x coordinate overridepublic void setY(double y)
y
- y coordinate overridepublic void setTheta(double theta)
theta
- heading overridepublic int getLeftMotorTachoCount()
public void setLeftMotorTachoCount(int leftMotorTachoCount)
leftMotorTachoCount
- the leftMotorTachoCount to setpublic int getRightMotorTachoCount()
public void setRightMotorTachoCount(int rightMotorTachoCount)
rightMotorTachoCount
- the rightMotorTachoCount to setpublic double getFilteredData()
public void setData(double data)
data
- - data to setpublic static double euclideanDistance(double[] a, double[] b)
a
- point ab
- point bpublic void turnTo(double theta)
Navigation.turnTo(double, boolean)
public void turnBy(double theta)
Navigation.turnBy(double)
public void travelTo(double x, double y)
Navigation.travelTo(double, double)
private int convertDistance(double radius, double distance)
radius
- - wheel radiusdistance
- - linear distanceprivate int convertAngle(double radius, double width, double angle)
radius
- - wheel radiuswidth
- - track widthangle
- - angle to turn