|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecticommand.robotics.ServoNavigator
public class ServoNavigator
The ServoNavigator class contains methods for performing basic navigational
movements. This class uses two standard NXT servo motors to monitor the wheels of the
differential drive.
PRELIMINARY: Doesn't work very good because of SyncMotors poor performance.
Note: This class will only work for robots using two motors to steer differentially
that can rotate within its footprint (i.e. turn on the spot).
Constructor Summary | |
---|---|
ServoNavigator(double wheelDiameter,
double driveLength,
double ratio,
SyncMotors vehicle)
Allocates a ServoNavigator object and initializes it with a SyncMotors object. |
|
ServoNavigator(double wheelDiameter,
double driveLength,
SyncMotors vehicle)
For use only if the wheel axle is inserted directly into the motor. |
|
ServoNavigator(float wheelDiameter,
float driveLength,
float ratio,
Motor left,
Motor right)
|
Method Summary | |
---|---|
void |
backward()
Moves the NXT robot backward until stop() is called. |
void |
forward()
Moves the NXT robot forward until stop() is called. |
double |
getAngle()
Returns the current angle the NXT robot is facing. |
float |
getX()
Returns the current x coordinate of the NXT. |
float |
getY()
Returns the current y coordinate of the NXT. |
void |
gotoAngle(double degrees)
Rotates the NXT robot to point in a certain direction. |
void |
gotoPoint(double x,
double y)
Rotates the NXT robot towards the target point and moves the required distance. |
void |
rotate(double degrees)
Rotates the NXT robot a specific number of degrees in a direction (+ or -). |
void |
stop()
Halts the NXT robot and calculates new x, y coordinates. |
void |
travel(long dist)
Moves the NXT robot a specific distance. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ServoNavigator(double wheelDiameter, double driveLength, SyncMotors vehicle)
wheelDiameter
- driveLength
- vehicle
- public ServoNavigator(double wheelDiameter, double driveLength, double ratio, SyncMotors vehicle)
wheelDiameter
- The diameter of the wheel, usually printed right on the
wheel, in millimeters (e.g. 56 mm)driveLength
- The distance from the center of the left tire to the center
of the right tire, in centimeters.ratio
- The ratio of sensor rotations to wheel rotations.vehicle
- A SyncMotors object containing two synchronized motors.public ServoNavigator(float wheelDiameter, float driveLength, float ratio, Motor left, Motor right)
wheelDiameter
- The diameter of the wheel, usually printed right on the
wheel, in millimeters (e.g. 56 mm)driveLength
- The distance from the center of the left tire to the center
of the right tire, in centimeters.ratio
- The ratio of sensor rotations to wheel rotations.left
- Left Motor e.g. Motor.Bright
- Right Motor e.g. Motor.BMethod Detail |
---|
public float getX()
getX
in interface Navigator
public float getY()
getY
in interface Navigator
public double getAngle()
getAngle
in interface Navigator
public void rotate(double degrees)
rotate
in interface Navigator
degrees
- Angle to rotate in degrees. A positive value rotates left, a negative value right.public void gotoAngle(double degrees)
gotoAngle
in interface Navigator
angle
- The angle to rotate to, in degrees.public void gotoPoint(double x, double y)
gotoPoint
in interface Navigator
x
- The x coordinate to move to.y
- The y coordinate to move to.public void travel(long dist)
travel
in interface Navigator
dist
- The positive or negative distance to move the robot (in centimeters).public void forward()
forward
in interface Navigator
Navigator.stop().
public void backward()
backward
in interface Navigator
Navigator.stop().
public void stop()
stop
in interface Navigator
Navigator.forward().
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |