maslab.orc
Class Gyro

java.lang.Object
  extended by maslab.orc.Gyro

public class Gyro
extends java.lang.Object

Orc wrapper for Gyro angular rate sensor.


Field Summary
 double gyroCorrectionPerTick
           
 double mvPerDegreePerSecond
           
 
Constructor Summary
Gyro(Orc orc)
          Create a new Orc object, using the default gyro port (15)
Gyro(Orc orc, int port)
           
 
Method Summary
 double calibrate(int ms)
          Automatically perform gyro calibration by waiting a while and measuring the drift.
 double getRadians()
          Read the (calibrated) gyro orientation.
 void reset()
          Reset the integrated position to zero.
 void setRateConstant(double mvPerDegreePerSecond)
          Set the scale factor of the gyro, in millivolts per degree per second.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

gyroCorrectionPerTick

public double gyroCorrectionPerTick

mvPerDegreePerSecond

public double mvPerDegreePerSecond
Constructor Detail

Gyro

public Gyro(Orc orc)
Create a new Orc object, using the default gyro port (15)


Gyro

public Gyro(Orc orc,
            int port)
Method Detail

setRateConstant

public void setRateConstant(double mvPerDegreePerSecond)
Set the scale factor of the gyro, in millivolts per degree per second. The nominal value is 5. You can test this by rotating the gyro 360 degrees (physically) and comparing it to the calculated value. If the sensor says N degrees, set the parameter to 5*N/360


calibrate

public double calibrate(int ms)
Automatically perform gyro calibration by waiting a while and measuring the drift. The robot should be stationary during this period. The function will return after calibration is complete (i.e., this method is synchronous).

Parameters:
ms - Number of milliseconds to integrate over. According to Analog Devices, periods greater than 5000ms are of marginal benefit.
Returns:
The calibration value (for sanity checking; the value is remembered internally).

getRadians

public double getRadians()
Read the (calibrated) gyro orientation.

Returns:
The gyro's orientation, in radians, [-PI, PI].

reset

public void reset()
Reset the integrated position to zero.