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_t moduleNumber, uint32_t channel)
 
 Gyro (uint32_t channel)
 
 Gyro (AnalogChannel *channel)
 
 Gyro (AnalogChannel &channel)
 
virtual ~Gyro ()
 
virtual float GetAngle ()
 
virtual double GetRate ()
 
void SetSensitivity (float voltsPerDegreePerSecond)
 
void SetPIDSourceParameter (PIDSourceParameter pidSource)
 
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_t lineNumber) const
 Set error information associated with a C library call that set an error to the "errno" global variable. More...
 
virtual void SetImaqError (int success, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set the current error information associated from the nivision Imaq API. More...
 
virtual void SetError (Error::Code code, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void SetWPIError (const char *errorMessage, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber) const
 Set the current error information associated with this sensor. More...
 
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. More...
 

Static Public Attributes

static const uint32_t kOversampleBits = 10
 
static const uint32_t kAverageBits = 0
 
static constexpr float kSamplesPerSecond = 50.0
 
static constexpr float kCalibrationSampleTime = 5.0
 
static constexpr float kDefaultVoltsPerDegreePerSecond = 0.007
 
- Static Public Attributes inherited from SensorBase
static const uint32_t kSystemClockTicksPerMicrosecond = 40
 
static const uint32_t kDigitalChannels = 14
 
static const uint32_t kAnalogChannels = 8
 
static const uint32_t kAnalogModules = 2
 
static const uint32_t kDigitalModules = 2
 
static const uint32_t kSolenoidChannels = 8
 
static const uint32_t kSolenoidModules = 2
 
static const uint32_t kPwmChannels = 10
 
static const uint32_t kRelayChannels = 8
 
static const uint32_t kChassisSlots = 8
 

Additional Inherited Members

- Public Types inherited from PIDSource
enum  PIDSourceParameter { kDistance, kRate, kAngle }
 
- Static Public Member Functions inherited from SensorBase
static void DeleteSingletons ()
 
static uint32_t GetDefaultAnalogModule ()
 
static uint32_t GetDefaultDigitalModule ()
 
static uint32_t GetDefaultSolenoidModule ()
 
static bool CheckAnalogModule (uint8_t moduleNumber)
 
static bool CheckDigitalModule (uint8_t moduleNumber)
 
static bool CheckPWMModule (uint8_t moduleNumber)
 
static bool CheckRelayModule (uint8_t moduleNumber)
 
static bool CheckSolenoidModule (uint8_t moduleNumber)
 
static bool CheckDigitalChannel (uint32_t channel)
 
static bool CheckRelayChannel (uint32_t channel)
 
static bool CheckPWMChannel (uint32_t channel)
 
static bool CheckAnalogChannel (uint32_t channel)
 
static bool CheckSolenoidChannel (uint32_t channel)
 
- Static Public Member Functions inherited from ErrorBase
static void SetGlobalError (Error::Code code, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber)
 
static void SetGlobalWPIError (const char *errorMessage, const char *contextMessage, const char *filename, const char *function, uint32_t lineNumber)
 
static ErrorGetGlobalError ()
 
- Protected Member Functions inherited from SensorBase
void AddToSingletonList ()
 
- Protected Member Functions inherited from ErrorBase
 ErrorBase ()
 Initialize the instance status to 0 for now.
 
- 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_t  moduleNumber,
uint32_t  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 79 of file Gyro.cpp.

Gyro::Gyro ( uint32_t  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 93 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 106 of file Gyro.cpp.

Gyro::~Gyro ( )
virtual

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

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

double Gyro::GetRate ( void  )
virtual

Return the rate of rotation of the gyro

The rate is based on the most recent reading of the gyro analog value

Returns
the current rate in degrees per second

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

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

Implements Sendable.

Definition at line 245 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 240 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 210 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 132 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 193 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 228 of file Gyro.cpp.

void Gyro::StopLiveWindowMode ( )
virtual

Stop having this sendable object automatically respond to value changes.

Implements LiveWindowSendable.

Definition at line 232 of file Gyro.cpp.

void Gyro::UpdateTable ( )
virtual

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

Implements LiveWindowSendable.

Definition at line 222 of file Gyro.cpp.


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

Generated on Sat Apr 26 2014 12:26:46 for WPILibC++ by doxygen 1.8.6