#include <Gyro.h>
Public Member Functions | |
Gyro (unsigned slot, unsigned channel) | |
Gyro (unsigned channel) | |
Gyro (AnalogChannel *channel) | |
~Gyro (void) | |
float | GetAngle (void) |
void | SetSensitivity (float voltsPerDegreePerSecond) |
void | Reset (void) |
Gyro::Gyro | ( | unsigned | slot, | |
unsigned | channel | |||
) |
Gyro constructor given a slot and a channel.
slot | The cRIO slot for the analog module the gyro is connected to. | |
channel | The analog channel the gyro is connected to. |
Gyro::Gyro | ( | unsigned | channel | ) |
Gyro constructor with only a channel.
Use the default analog module slot.
channel | The analog channel the gyro is connected to. |
Gyro::Gyro | ( | AnalogChannel * | channel | ) |
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.
channel | The AnalogChannel object that the gyro is connected to. |
Gyro::~Gyro | ( | void | ) |
Delete (free) the accumulator and the analog components used for the gyro.
float Gyro::GetAngle | ( | void | ) |
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.
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.
voltsPerDegreePerSecond | The type of gyro in degrees/volts. |
void Gyro::Reset | ( | void | ) |
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.