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, onModuleStateChange
public static final java.lang.String TAG
protected double biasVoltage
protected double degreesPerSecondPerVolt
protected boolean isCalibrating
public HiTechnicNxtGyroSensor(LegacyModule legacyModule, int physicalPort)
protected void moduleNowArmedOrPretending()
LegacyModulePortDeviceImpl
moduleNowArmedOrPretending
in class LegacyModulePortDeviceImpl
public 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()
Gyroscope
Gyroscope.getAngularVelocity(AngleUnit)
.getAngularVelocityAxes
in interface Gyroscope
Gyroscope.getAngularVelocity(AngleUnit)
public AngularVelocity getAngularVelocity(AngleUnit unit)
Gyroscope
getAngularVelocity
in interface Gyroscope
unit
- 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.Object
public void calibrate()
calibrate
in interface GyroSensor
public 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 GyroSensor
public double getRotationFraction()
GyroSensor
getRotationFraction
in interface GyroSensor
public double readRawVoltage()
AnalogSensor
readRawVoltage
in interface AnalogSensor
public double getMaxVoltage()
public int getHeading()
getHeading
in interface GyroSensor
java.lang.UnsupportedOperationException
public int rawX()
rawX
in interface GyroSensor
java.lang.UnsupportedOperationException
public int rawY()
rawY
in interface GyroSensor
java.lang.UnsupportedOperationException
public int rawZ()
rawZ
in interface GyroSensor
java.lang.UnsupportedOperationException
public void resetZAxisIntegrator()
resetZAxisIntegrator
in interface GyroSensor
java.lang.UnsupportedOperationException
public java.lang.String status()
GyroSensor
status
in interface GyroSensor
public HardwareDevice.Manufacturer getManufacturer()
HardwareDevice
getManufacturer
in interface HardwareDevice
public java.lang.String getDeviceName()
HardwareDevice
getDeviceName
in interface HardwareDevice
public java.lang.String getConnectionInfo()
HardwareDevice
getConnectionInfo
in interface HardwareDevice
public int getVersion()
HardwareDevice
getVersion
in interface HardwareDevice
public void resetDeviceConfigurationForOpMode()
HardwareDevice
resetDeviceConfigurationForOpMode
in interface HardwareDevice
public void close()
HardwareDevice
close
in interface HardwareDevice
protected void notSupported()