public class HiTechnicNxtGyroSensor extends LegacyModulePortDeviceImpl implements GyroSensor, Gyroscope, AnalogSensor
HiTechnicNxtGyroSensor supports the legacy HiTechnic gyro sensor. This sensor
is an analog sensor that must be connected using a Core Legacy Module.
"The NXT Gyro Sensor contains a single axis gyroscopic sensor that detects rotation and returns a value representing the number of degrees per second of rotation. The Gyro Sensor can measure up to +/- 360° per second of rotation."
"The rotation rate can be read up to approximately 300 times per second"
Note that the value coming out of the sensor is the rotation rate in the clockwise direction.
HardwareDevice.Manufacturer| Modifier and Type | Field and Description |
|---|---|
protected double |
biasVoltage
The voltage indicting zero angular rotation
|
protected double |
degreesPerSecondPerVolt
The conversion factor between voltage and angular rotation rate
|
protected boolean |
isCalibrating
whether or not the gyroscope is currently calibrating
|
static java.lang.String |
TAG |
module, physicalPort| Constructor and Description |
|---|
HiTechnicNxtGyroSensor(LegacyModule legacyModule,
int physicalPort) |
| Modifier and Type | Method and Description |
|---|---|
void |
calibrate()
Calibrates the HiTechnic gyroscope attempting to establish a reasonable value for
its internal bias using default calibration parameters.
|
void |
calibrate(int msCalibrationDuration,
int msCalibrationInterval)
Calibrates the HiTechnic gyroscope attempting to establish a reasonable value for
its internal bias using specified calibration parameters
|
void |
calibrate(int msCalibrationDuration,
int msCalibrationInterval,
int msSettlingTime)
Calibrates the HiTechnic gyroscope attempting to establish a reasonable value for
its internal bias using specified calibration parameters
|
void |
close()
Closes this device
|
AngularVelocity |
getAngularVelocity(AngleUnit unit)
Returns the angular rotation rate across all the axes measured by the gyro.
|
java.util.Set<Axis> |
getAngularVelocityAxes()
Returns the axes on which the gyroscope measures angular velocity.
|
protected float |
getAngularZVelocity(AngleUnit unit) |
double |
getBiasVoltage() |
java.lang.String |
getConnectionInfo()
Get connection information about this device in a human readable format
|
double |
getDefaultBiasVoltage() |
double |
getDefaultDegreesPerSecondPerVolt() |
double |
getDegreesPerSecondPerVolt() |
java.lang.String |
getDeviceName()
Returns a string suitable for display to the user as to the type of device.
|
int |
getHeading()
Method not supported by hardware.
|
HardwareDevice.Manufacturer |
getManufacturer()
Returns an indication of the manufacturer of this device.
|
double |
getMaxVoltage() |
double |
getRotationFraction()
Return the rotation of this sensor expressed as a fraction of the maximum possible reportable rotation
|
int |
getVersion()
Version
|
boolean |
isCalibrating()
Returns whether or not the gyro is currently calibrating
|
protected void |
moduleNowArmedOrPretending()
intended as a subclass hook
|
protected void |
notSupported() |
int |
rawX()
Method not supported by hardware.
|
int |
rawY()
Method not supported by hardware.
|
int |
rawZ()
Method not supported by hardware.
|
double |
readRawVoltage()
Returns the sensor's current value as a raw voltage level.
|
void |
resetDeviceConfigurationForOpMode()
Resets the device's configuration to that which is expected at the beginning of an OpMode.
|
void |
resetZAxisIntegrator()
Method not supported by hardware.
|
void |
setBiasVoltage(double biasVoltage) |
void |
setDegreesPerSecondPerVolt(double degreesPerSecondPerVolt) |
protected void |
sleep(int ms) |
java.lang.String |
status()
Status of this sensor, in string form
|
java.lang.String |
toString() |
finishConstruction, getLegacyModule, getPort, moduleNowDisarmed, onModuleStateChangepublic static final java.lang.String TAG
protected double biasVoltage
protected double degreesPerSecondPerVolt
protected boolean isCalibrating
public HiTechnicNxtGyroSensor(LegacyModule legacyModule, int physicalPort)
protected void moduleNowArmedOrPretending()
LegacyModulePortDeviceImplmoduleNowArmedOrPretending in class LegacyModulePortDeviceImplpublic double getBiasVoltage()
public void setBiasVoltage(double biasVoltage)
public double getDegreesPerSecondPerVolt()
public void setDegreesPerSecondPerVolt(double degreesPerSecondPerVolt)
public double getDefaultDegreesPerSecondPerVolt()
public double getDefaultBiasVoltage()
public java.util.Set<Axis> getAngularVelocityAxes()
GyroscopeGyroscope.getAngularVelocity(AngleUnit).getAngularVelocityAxes in interface GyroscopeGyroscope.getAngularVelocity(AngleUnit)public AngularVelocity getAngularVelocity(AngleUnit unit)
GyroscopegetAngularVelocity in interface Gyroscopeunit - the unit in which the rotation rates are to be returned (the time
dimension is always inverse-seconds).Gyroscope.getAngularVelocityAxes()protected float getAngularZVelocity(AngleUnit unit)
public java.lang.String toString()
toString in class java.lang.Objectpublic void calibrate()
calibrate in interface GyroSensorpublic void calibrate(int msCalibrationDuration,
int msCalibrationInterval)
msCalibrationDuration - the amount of time to spend on calibrationmsCalibrationInterval - the interval, in ms, to pause between eachpublic void calibrate(int msCalibrationDuration,
int msCalibrationInterval,
int msSettlingTime)
msCalibrationDuration - the amount of time to spend on calibrationmsCalibrationInterval - the interval, in ms, to pause between eachmsSettlingTime - the initial duration, in ms, to allow the gyro to settleprotected void sleep(int ms)
public boolean isCalibrating()
isCalibrating in interface GyroSensorpublic double getRotationFraction()
GyroSensorgetRotationFraction in interface GyroSensorpublic double readRawVoltage()
AnalogSensorreadRawVoltage in interface AnalogSensorpublic double getMaxVoltage()
public int getHeading()
getHeading in interface GyroSensorjava.lang.UnsupportedOperationExceptionpublic int rawX()
rawX in interface GyroSensorjava.lang.UnsupportedOperationExceptionpublic int rawY()
rawY in interface GyroSensorjava.lang.UnsupportedOperationExceptionpublic int rawZ()
rawZ in interface GyroSensorjava.lang.UnsupportedOperationExceptionpublic void resetZAxisIntegrator()
resetZAxisIntegrator in interface GyroSensorjava.lang.UnsupportedOperationExceptionpublic java.lang.String status()
GyroSensorstatus in interface GyroSensorpublic HardwareDevice.Manufacturer getManufacturer()
HardwareDevicegetManufacturer in interface HardwareDevicepublic java.lang.String getDeviceName()
HardwareDevicegetDeviceName in interface HardwareDevicepublic java.lang.String getConnectionInfo()
HardwareDevicegetConnectionInfo in interface HardwareDevicepublic int getVersion()
HardwareDevicegetVersion in interface HardwareDevicepublic void resetDeviceConfigurationForOpMode()
HardwareDeviceresetDeviceConfigurationForOpMode in interface HardwareDevicepublic void close()
HardwareDeviceclose in interface HardwareDeviceprotected void notSupported()