34 static const uint32_t kOversampleBits = 10;
35 static const uint32_t kAverageBits = 0;
36 static constexpr
float kSamplesPerSecond = 50.0;
37 static constexpr
float kCalibrationSampleTime = 5.0;
38 static constexpr
float kDefaultVoltsPerDegreePerSecond = 0.007;
42 explicit AnalogGyro(std::shared_ptr<AnalogInput> channel);
43 AnalogGyro(int32_t channel, uint32_t center,
float offset);
44 AnalogGyro(std::shared_ptr<AnalogInput> channel, uint32_t center,
float offset);
48 double GetRate()
const override;
53 void Reset()
override;
58 std::shared_ptr<AnalogInput> m_analog;
61 float m_voltsPerDegreePerSecond;
void Calibrate() override
Calibrate the gyro by running for a number of samples and computing the center value.Then use the center value as the Accumulator center value for subsequent measurements. It's important to make sure that the robot is not moving while the centering calculations are in progress, this is typically done when the robot is first turned on while it's sitting at rest before the competition starts.
Definition: AnalogGyro.cpp:141
virtual float GetOffset() const
Return the gyro offset value.
Definition: AnalogGyro.cpp:211
virtual uint32_t GetCenter() const
Return the gyro center value.
Definition: AnalogGyro.cpp:221
GyroBase is the common base class for Gyro implementations such as AnalogGyro.
Definition: GyroBase.h:21
void SetSensitivity(float voltsPerDegreePerSecond)
Set the gyro sensitivity.
Definition: AnalogGyro.cpp:235
void SetDeadband(float volts)
Set the size of the neutral zone.
Definition: AnalogGyro.cpp:247
float GetAngle() const override
Return the actual angle in degrees that the robot is currently facing.
Definition: AnalogGyro.cpp:174
double GetRate() const override
Return the rate of rotation of the gyro.
Definition: AnalogGyro.cpp:197
AnalogGyro(int32_t channel)
Gyro constructor using the Analog Input channel number.
Definition: AnalogGyro.cpp:26
Use a rate gyro to return the robots heading relative to a starting position.
Definition: AnalogGyro.h:32
void Reset() override
Reset the gyro.
Definition: AnalogGyro.cpp:104
virtual void InitGyro()
Initialize the gyro.
Definition: AnalogGyro.cpp:112