WPILibC++  2020.3.2-60-g3011ebe
ADXRS450_Gyro.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2015-2020 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 <hal/SimDevice.h>
13 
14 #include "frc/GyroBase.h"
15 #include "frc/SPI.h"
16 
17 namespace frc {
18 
32 class ADXRS450_Gyro : public GyroBase {
33  public:
37  ADXRS450_Gyro();
38 
44  explicit ADXRS450_Gyro(SPI::Port port);
45 
46  ~ADXRS450_Gyro() override = default;
47 
48  ADXRS450_Gyro(ADXRS450_Gyro&&) = default;
49  ADXRS450_Gyro& operator=(ADXRS450_Gyro&&) = default;
50 
63  double GetAngle() const override;
64 
72  double GetRate() const override;
73 
81  void Reset() override;
82 
95  void Calibrate() override;
96 
97  private:
98  SPI m_spi;
99 
100  hal::SimDevice m_simDevice;
101  hal::SimDouble m_simAngle;
102  hal::SimDouble m_simRate;
103 
104  uint16_t ReadRegister(int reg);
105 };
106 
107 } // namespace frc
frc::ADXRS450_Gyro::Calibrate
void Calibrate() override
Initialize the gyro.
frc::ADXRS450_Gyro::ADXRS450_Gyro
ADXRS450_Gyro()
Gyro constructor on onboard CS0.
frc::SPI
SPI bus interface class.
Definition: SPI.h:32
frc::ADXRS450_Gyro::GetRate
double GetRate() const override
Return the rate of rotation of the gyro.
frc::ADXRS450_Gyro::Reset
void Reset() override
Reset the gyro.
frc
A class that enforces constraints on the differential drive kinematics.
Definition: PDPSim.h:16
frc::GyroBase
GyroBase is the common base class for Gyro implementations such as AnalogGyro.
Definition: GyroBase.h:22
frc::ADXRS450_Gyro::GetAngle
double GetAngle() const override
Return the actual angle in degrees that the robot is currently facing.
frc::ADXRS450_Gyro
Use a rate gyro to return the robots heading relative to a starting position.
Definition: ADXRS450_Gyro.h:32