WPILibC++  unspecified
ADXRS450_Gyro.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2015-2018 FIRST. 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 <stdint.h>
11 
12 #include "GyroBase.h"
13 #include "SPI.h"
14 
15 namespace frc {
16 
29 class ADXRS450_Gyro : public GyroBase {
30  public:
31  ADXRS450_Gyro();
32  explicit ADXRS450_Gyro(SPI::Port port);
33  virtual ~ADXRS450_Gyro() = default;
34 
35  double GetAngle() const override;
36  double GetRate() const override;
37  void Reset() override;
38  void Calibrate() override;
39 
40  private:
41  SPI m_spi;
42 
43  uint16_t ReadRegister(int reg);
44 };
45 
46 } // namespace frc
Definition: RobotController.cpp:14
SPI bus interface class.
Definition: SPI.h:31
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:20
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:29