public class GyroDirectionFinder extends java.lang.Object implements DirectionFinder
DirectionFinder
interface that integrates repeated rate-of-turn readings from a
gyro sensor
into a continuously updated heading. This class is very similar to the compass sensors,
except that the direction returned does not convey true heading (north, south, etc) but rather
relative heading change since the last time setDegrees() or resetCartesianZero() was called.Constructor and Description |
---|
GyroDirectionFinder(Gyroscope gyro)
Creates and initializes a new
GyroDirectionFinder using passed GyroSensor |
GyroDirectionFinder(Gyroscope gyro,
boolean calibrate)
Creates and initializes a new
GyroDirectionFinder using passed GyroSensor and does
the GyroSensor.recalibrateOffset() method. |
Modifier and Type | Method and Description |
---|---|
float |
getAngularAcceleration()
Returns the current rate at which the angular velocity is increasing or decreasing in degrees-per-second, per second.
|
float |
getAngularVelocity()
Returns the current rate-of-turn in degrees/second, as read by the
GyroSensor instance passed in the constructor. |
float |
getDegrees()
Returns the directional heading in degrees.
|
float |
getDegreesCartesian()
Returns the current rate-of-turn in degrees, as read by the
GyroSensor . |
void |
resetCartesianZero()
Resets the current heading to zero.
|
void |
setDegrees(float heading)
Resets the current heading to a desired value.
|
void |
setDegreesCartesian(float heading)
Resets the current heading to a desired value.
|
void |
startCalibration()
Find offset/bias of gyro while at rest (ensure it is at rest).
|
void |
stopCalibration()
NO FUNCTIONALITY EQUIVALENT for
GyroSensor so implemented just to satisfy the DirectionFinder interface. |
public GyroDirectionFinder(Gyroscope gyro)
GyroDirectionFinder
using passed GyroSensor
gyro
- a gyro sensor instancepublic GyroDirectionFinder(Gyroscope gyro, boolean calibrate)
GyroDirectionFinder
using passed GyroSensor
and does
the GyroSensor.recalibrateOffset()
method.gyro
- A gyro sensor instancepublic void setDegrees(float heading)
getDegrees()
public float getDegrees()
resetCartesianZero()
.setDegrees(float)
public float getAngularVelocity()
GyroSensor
instance passed in the constructor.public float getAngularAcceleration()
public float getDegreesCartesian()
GyroSensor
.getDegreesCartesian
in interface DirectionFinder
public void setDegreesCartesian(float heading)
public void resetCartesianZero()
resetCartesianZero
in interface DirectionFinder
public void startCalibration()
recalibrateOffset()
method of
the GyroSensor
instance passed in the constructor. This takes 3 seconds.startCalibration
in interface Calibrate
public void stopCalibration()
GyroSensor
so implemented just to satisfy the DirectionFinder
interface.
Does nothing.stopCalibration
in interface Calibrate