WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
ADXRS450_Gyro.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) FIRST 2015-2016. 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 the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include <memory>
11 
12 #include "GyroBase.h"
13 #include "HAL/cpp/priority_mutex.h"
14 #include "Notifier.h"
15 #include "SPI.h"
16 
17 namespace frc {
18 
30 class ADXRS450_Gyro : public GyroBase {
31  public:
32  ADXRS450_Gyro();
33  explicit ADXRS450_Gyro(SPI::Port port);
34  virtual ~ADXRS450_Gyro() = default;
35 
36  double GetAngle() const override;
37  double GetRate() const override;
38  void Reset() override;
39  void Calibrate() override;
40 
41  private:
42  SPI m_spi;
43 
44  uint16_t ReadRegister(int reg);
45 };
46 
47 } // namespace frc
SPI bus interface class.
Definition: SPI.h:24
double GetRate() const override
Return the rate of rotation of the gyro.
Definition: ADXRS450_Gyro.cpp:151
ADXRS450_Gyro()
Gyro constructor on onboard CS0.
Definition: ADXRS450_Gyro.cpp:57
double GetAngle() const override
Return the actual angle in degrees that the robot is currently facing.
Definition: ADXRS450_Gyro.cpp:140
void Reset() override
Reset the gyro.
Definition: ADXRS450_Gyro.cpp:126
GyroBase is the common base class for Gyro implementations such as AnalogGyro.
Definition: GyroBase.h:24
void Calibrate() override
Initialize the gyro.
Definition: ADXRS450_Gyro.cpp:42
Use a rate gyro to return the robots heading relative to a starting position.
Definition: ADXRS450_Gyro.h:30