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:

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 ()
void UpdateTable ()
void StartLiveWindowMode ()
void StopLiveWindowMode ()
std::string GetSmartDashboardType ()
void InitTable (ITable *subTable)
ITableGetTable ()
- Public Member Functions inherited from SensorBase
 SensorBase ()
virtual ~SensorBase ()
- Public Member Functions inherited from ErrorBase
virtual ErrorGetError ()
 Retrieve the current error. Get the current error information associated with this sensor.
virtual const ErrorGetError () const
virtual void SetErrnoError (const char *contextMessage, const char *filename, const char *function, UINT32 lineNumber) const
 Set error information associated with a C library call that set an error to the "errno" global variable.
virtual void SetImaqError (int success, const char *contextMessage, const char *filename, const char *function, UINT32 lineNumber) const
 Set the current error information associated from the nivision Imaq API.
virtual void SetError (Error::Code code, const char *contextMessage, const char *filename, const char *function, UINT32 lineNumber) const
 Set the current error information associated with this sensor.
virtual void SetWPIError (const char *errorMessage, const char *contextMessage, const char *filename, const char *function, UINT32 lineNumber) const
 Set the current error information associated with this sensor.
virtual void CloneError (ErrorBase *rhs) const
virtual void ClearError () const
 Clear the current error information associated with this sensor.
virtual bool StatusIsFatal () const
 Check if the current error code represents a fatal error.

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
- Static Public Attributes inherited from SensorBase
static const UINT32 kSystemClockTicksPerMicrosecond = 40
static const UINT32 kDigitalChannels = 14
static const UINT32 kAnalogChannels = 8
static const UINT32 kAnalogModules = 2
static const UINT32 kDigitalModules = 2
static const UINT32 kSolenoidChannels = 8
static const UINT32 kSolenoidModules = 2
static const UINT32 kPwmChannels = 10
static const UINT32 kRelayChannels = 8
static const UINT32 kChassisSlots = 8

Additional Inherited Members

- Static Public Member Functions inherited from SensorBase
static void DeleteSingletons ()
static UINT32 GetDefaultAnalogModule ()
static UINT32 GetDefaultDigitalModule ()
static UINT32 GetDefaultSolenoidModule ()
static bool CheckAnalogModule (UINT8 moduleNumber)
static bool CheckDigitalModule (UINT8 moduleNumber)
static bool CheckPWMModule (UINT8 moduleNumber)
static bool CheckRelayModule (UINT8 moduleNumber)
static bool CheckSolenoidModule (UINT8 moduleNumber)
static bool CheckDigitalChannel (UINT32 channel)
static bool CheckRelayChannel (UINT32 channel)
static bool CheckPWMChannel (UINT32 channel)
static bool CheckAnalogChannel (UINT32 channel)
static bool CheckSolenoidChannel (UINT32 channel)
- Protected Member Functions inherited from SensorBase
void AddToSingletonList ()
- Protected Attributes inherited from ErrorBase
Error m_error
- Static Protected Attributes inherited from ErrorBase
static SEM_ID _globalErrorMutex = semMCreate(SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE)
static Error _globalError

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 27 of file Gyro.h.

Constructor & Destructor Documentation

Gyro::Gyro ( UINT8  moduleNumber,
UINT32  channel 
)

Gyro constructor given a slot and a channel.

Parameters
moduleNumberThe analog module the gyro is connected to (1).
channelThe analog channel the gyro is connected to (1 or 2).

Definition at line 76 of file Gyro.cpp.

Gyro::Gyro ( UINT32  channel)
explicit

Gyro constructor with only a channel.

Use the default analog module slot.

Parameters
channelThe analog channel the gyro is connected to.

Definition at line 90 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
channelThe AnalogChannel object that the gyro is connected to.

Definition at line 103 of file Gyro.cpp.

Gyro::~Gyro ( )
virtual

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

Definition at line 137 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 154 of file Gyro.cpp.

std::string Gyro::GetSmartDashboardType ( )
virtual
Returns
the string representation of the named data type that will be used by the smart dashboard for this sendable

Implements Sendable.

Definition at line 205 of file Gyro.cpp.

ITable * Gyro::GetTable ( )
virtual
Returns
the table that is currently associated with the sendable

Implements Sendable.

Definition at line 214 of file Gyro.cpp.

void Gyro::InitTable ( ITable subtable)
virtual

Initializes a table for this sendable object.

Parameters
subtableThe table to put the values in.

Implements Sendable.

Definition at line 209 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 186 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 129 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
voltsPerDegreePerSecondThe type of gyro specified as the voltage that represents one degree/second.

Definition at line 176 of file Gyro.cpp.

void Gyro::StartLiveWindowMode ( )
virtual

Start having this sendable object automatically respond to value changes reflect the value on the table.

Implements LiveWindowSendable.

Definition at line 197 of file Gyro.cpp.

void Gyro::StopLiveWindowMode ( )
virtual

Stop having this sendable object automatically respond to value changes.

Implements LiveWindowSendable.

Definition at line 201 of file Gyro.cpp.

void Gyro::UpdateTable ( )
virtual

Update the table for this sendable object with the latest values.

Implements LiveWindowSendable.

Definition at line 191 of file Gyro.cpp.


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

Generated on Tue Feb 5 2013 00:55:10 for WPILibC++ by doxygen 1.8.1.2