Now you can download a copy of these docs so you can use them offline! Download now

#include <Gyro.h>

Inheritance diagram for Gyro:
Collaboration diagram for Gyro:

List of all members.

Public Member Functions

 Gyro (UINT8 moduleNumber, UINT32 channel)
 Gyro (UINT32 channel)
 Gyro (AnalogChannel *channel)
 Gyro (AnalogChannel &channel)
virtual ~Gyro ()
virtual float GetAngle ()
void SetSensitivity (float voltsPerDegreePerSecond)
virtual void Reset ()
double PIDGet ()

Static Public Attributes

static const UINT32 kOversampleBits = 10
static const UINT32 kAverageBits = 0
static const float kSamplesPerSecond = 50.0
static const float kCalibrationSampleTime = 5.0
static const float kDefaultVoltsPerDegreePerSecond = 0.007

Detailed Description

Use a rate gyro to return the robots heading relative to a starting position. The Gyro class tracks the robots heading based on the starting position. As the robot rotates the new heading is computed by integrating the rate of rotation returned by the sensor. When the class is instantiated, it does a short calibration routine where it samples the gyro while at rest to determine the default offset. This is subtracted from each sample to determine the heading. This gyro class must be used with a channel that is assigned one of the Analog accumulators from the FPGA. See AnalogChannel for the current accumulator assignments.

Definition at line 26 of file Gyro.h.


Constructor & Destructor Documentation

Gyro::Gyro ( UINT8  moduleNumber,
UINT32  channel 
)

Gyro constructor given a slot and a channel.

Parameters:
moduleNumber The analog module the gyro is connected to (1).
channel The analog channel the gyro is connected to (1 or 2).

Definition at line 71 of file Gyro.cpp.

Gyro::Gyro ( UINT32  channel  )  [explicit]

Gyro constructor with only a channel.

Use the default analog module slot.

Parameters:
channel The analog channel the gyro is connected to.

Definition at line 85 of file Gyro.cpp.

Gyro::Gyro ( AnalogChannel channel  )  [explicit]

Gyro constructor with a precreated analog channel object. Use this constructor when the analog channel needs to be shared. There is no reference counting when an AnalogChannel is passed to the gyro.

Parameters:
channel The AnalogChannel object that the gyro is connected to.

Definition at line 98 of file Gyro.cpp.

Gyro::~Gyro (  )  [virtual]

Delete (free) the accumulator and the analog components used for the gyro.

Definition at line 132 of file Gyro.cpp.


Member Function Documentation

float Gyro::GetAngle ( void   )  [virtual]

Return the actual angle in degrees that the robot is currently facing.

The angle is based on the current accumulator value corrected by the oversampling rate, the gyro type and the A/D calibration values. The angle is continuous, that is can go beyond 360 degrees. This make algorithms that wouldn't want to see a discontinuity in the gyro output as it sweeps past 0 on the second time around.

Returns:
the current heading of the robot in degrees. This heading is based on integration of the returned rate from the gyro.

Definition at line 149 of file Gyro.cpp.

double Gyro::PIDGet (  )  [virtual]

Get the angle in degrees for the PIDSource base object.

Returns:
The angle in degrees.

Implements PIDSource.

Definition at line 181 of file Gyro.cpp.

void Gyro::Reset (  )  [virtual]

Reset the gyro. Resets the gyro to a heading of zero. This can be used if there is significant drift in the gyro and it needs to be recalibrated after it has been running.

Definition at line 124 of file Gyro.cpp.

void Gyro::SetSensitivity ( float  voltsPerDegreePerSecond  ) 

Set the gyro type based on the sensitivity. This takes the number of volts/degree/second sensitivity of the gyro and uses it in subsequent calculations to allow the code to work with multiple gyros.

Parameters:
voltsPerDegreePerSecond The type of gyro specified as the voltage that represents one degree/second.

Definition at line 171 of file Gyro.cpp.


The documentation for this class was generated from the following files:

Generated on Thu Jan 12 2012 22:35:32 for WPILibC++ by doxygen 1.7.1