FRC Paradigm Shift #1259
Documentation for the 2021 Robot
Gyro.cpp
Go to the documentation of this file.
1 #include "common/Gyro.h"
2 
3 
4 Gyro::Gyro() : m_gyro(0) {}
5 
7 {
8  auto heading = std::remainder(m_gyro.GetFusedHeading(), 360.0) * (kGyroReversed ? -1. : 1.);
9  if (heading > 180.0)
10  heading -= 360.0;
11 
12  return heading;
13 }
14 
16 {
17  m_gyro.SetFusedHeading(0.0, 0);
18 }
19 
21 {
22  double turnRates [3] = {0, 0, 0};
23  m_gyro.GetRawGyro(turnRates);
24  return turnRates[2] * (kGyroReversed ? -1. : 1.);
25 }
PigeonIMU m_gyro
Definition: Gyro.h:31
double GetTurnRate()
Definition: Gyro.cpp:20
Gyro()
Definition: Gyro.cpp:4
constexpr bool kGyroReversed
Definition: Constants.h:75
double GetHeading()
Definition: Gyro.cpp:6
void ZeroHeading()
Zeroes the heading of the robot.
Definition: Gyro.cpp:15