public class Navigation extends Object
Modifier and Type | Field and Description |
---|---|
private EV3LargeRegulatedMotor |
leftMotor |
private Odometer |
odometer |
static boolean |
PathBlocked |
private EV3LargeRegulatedMotor |
rightMotor |
Constructor and Description |
---|
Navigation(Odometer odometer)
Navigation Constructor
|
Modifier and Type | Method and Description |
---|---|
private static int |
convertAngle(double radius,
double width,
double angle)
Converts angle to rotate to degrees a wheel must rotate
|
private static int |
convertDistance(double radius,
double distance)
Converts linear distance to degrees a wheel must rotate
|
void |
goForward(double distance)
Go forward a set distances
|
static double |
minimalAngle(double theta1,
double theta2)
Calculates minimal angle
|
void |
setFloat()
Float the two motors jointly
|
void |
setSpeeds(float lSpd,
float rSpd)
Function to set the motor speeds jointly
|
void |
setSpeeds(int lSpd,
int rSpd)
Function to set the motor speeds jointly
|
void |
travelTo(double x,
double y)
TravelTo function that travels to designated position while constantly updating heading
|
void |
travelTo(double x,
double y,
boolean checkSides)
TravelTo function that travels to a designated position while constantly updating heading
If checkSides is set to true, it will also incrementally check for obstacles on to its sides.
|
void |
travelToInterruptible(double x,
double y,
Lock interrupt) |
void |
turnBy(double theta)
turnBy function that turns by an angle relative to the robot
|
void |
turnTo(double angle,
boolean stop)
TurnTo function which takes an angle and boolean as arguments
|
private Odometer odometer
private EV3LargeRegulatedMotor leftMotor
private EV3LargeRegulatedMotor rightMotor
public static boolean PathBlocked
public Navigation(Odometer odometer)
odometer
- Odometer objectpublic void setSpeeds(float lSpd, float rSpd)
lSpd
- - speed of left motorrSpd
- - speed of right motorpublic void setSpeeds(int lSpd, int rSpd)
lSpd
- - speed of left motorrSpd
- - speed of right motorpublic void setFloat()
public void travelTo(double x, double y)
x
- x positiony
- y positionpublic void travelToInterruptible(double x, double y, Lock interrupt)
public void travelTo(double x, double y, boolean checkSides)
x
- x positiony
- y positioncheckSides
- whether or not to check for obstacles on its sides while navigatingpublic void turnTo(double angle, boolean stop)
angle
- absolute angle to turn tostop
- if the robot should stop moving after turningpublic void turnBy(double theta)
theta
- relative angle to turn byprivate static int convertDistance(double radius, double distance)
radius
- radius of the wheel (cm)distance
- distance (cm)private static int convertAngle(double radius, double width, double angle)
radius
- radius of the wheel (cm)width
- distance between wheelsangle
- angle to rotatepublic static double minimalAngle(double theta1, double theta2)
theta1
- in radianstheta2
- in radianspublic void goForward(double distance)
distance
- distance to move (cm)