WPILib  2014.0
WPIRoboticsLibraryforFRC
 All Classes Functions Variables Pages
Gyro.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2008. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */
5 /*----------------------------------------------------------------------------*/
6 
7 #ifndef GYRO_H_
8 #define GYRO_H_
9 
10 #include "SensorBase.h"
11 #include "PIDSource.h"
12 #include "LiveWindow/LiveWindowSendable.h"
13 
14 class AnalogChannel;
15 class AnalogModule;
16 
27 class Gyro : public SensorBase, public PIDSource, public LiveWindowSendable
28 {
29 public:
30  static const uint32_t kOversampleBits = 10;
31  static const uint32_t kAverageBits = 0;
32 
33  static constexpr float kSamplesPerSecond = 50.0;
34  static constexpr float kCalibrationSampleTime = 5.0;
35  static constexpr float kDefaultVoltsPerDegreePerSecond = 0.007;
36 
37  Gyro(uint8_t moduleNumber, uint32_t channel);
38  explicit Gyro(uint32_t channel);
39  explicit Gyro(AnalogChannel *channel);
40  explicit Gyro(AnalogChannel &channel);
41  virtual ~Gyro();
42  virtual float GetAngle();
43  virtual double GetRate();
44  void SetSensitivity(float voltsPerDegreePerSecond);
45  void SetPIDSourceParameter(PIDSourceParameter pidSource);
46  virtual void Reset();
47 
48  // PIDSource interface
49  double PIDGet();
50 
51  void UpdateTable();
52  void StartLiveWindowMode();
53  void StopLiveWindowMode();
54  std::string GetSmartDashboardType();
55  void InitTable(ITable *subTable);
56  ITable * GetTable();
57 
58 private:
59  void InitGyro();
60 
61  AnalogChannel *m_analog;
62  float m_voltsPerDegreePerSecond;
63  float m_offset;
64  bool m_channelAllocated;
65  uint32_t m_center;
66  PIDSourceParameter m_pidSource;
67 
68  ITable *m_table;
69 };
70 #endif
void SetSensitivity(float voltsPerDegreePerSecond)
Definition: Gyro.cpp:194
Definition: AnalogModule.h:20
virtual float GetAngle()
Definition: Gyro.cpp:158
virtual ~Gyro()
Definition: Gyro.cpp:141
Definition: SensorBase.h:20
double PIDGet()
Definition: Gyro.cpp:211
virtual void Reset()
Definition: Gyro.cpp:133
Definition: PIDSource.h:15
Gyro(uint8_t moduleNumber, uint32_t channel)
Definition: Gyro.cpp:80
Definition: Gyro.h:27
virtual double GetRate()
Definition: Gyro.cpp:180
Definition: AnalogChannel.h:29