WPILib 2012
WPILibRoboticsLibraryforFRC
Gyro.h
00001 /*----------------------------------------------------------------------------*/
00002 /* Copyright (c) FIRST 2008. All Rights Reserved.                                                         */
00003 /* Open Source Software - may be modified and shared by FRC teams. The code   */
00004 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib.  */
00005 /*----------------------------------------------------------------------------*/
00006 
00007 #ifndef GYRO_H_
00008 #define GYRO_H_
00009 
00010 #include "SensorBase.h"
00011 #include "PIDSource.h"
00012 
00013 class AnalogChannel;
00014 class AnalogModule;
00015 
00026 class Gyro : public SensorBase, public PIDSource
00027 {
00028 public:
00029         static const UINT32 kOversampleBits = 10;
00030         static const UINT32 kAverageBits = 0;
00031         static const float kSamplesPerSecond = 50.0;
00032         static const float kCalibrationSampleTime = 5.0;
00033         static const float kDefaultVoltsPerDegreePerSecond = 0.007;
00034 
00035         Gyro(UINT8 moduleNumber, UINT32 channel);
00036         explicit Gyro(UINT32 channel);
00037         explicit Gyro(AnalogChannel *channel);
00038         explicit Gyro(AnalogChannel &channel);
00039         virtual ~Gyro();
00040         virtual float GetAngle();
00041         void SetSensitivity(float voltsPerDegreePerSecond);
00042         virtual void Reset();
00043 
00044         // PIDSource interface
00045         double PIDGet();
00046 
00047 private:
00048         void InitGyro();
00049 
00050         AnalogChannel *m_analog;
00051         float m_voltsPerDegreePerSecond;
00052         float m_offset;
00053         bool m_channelAllocated;
00054 };
00055 #endif
 All Classes Functions Variables