FRC Paradigm Shift #1259
Documentation for the 2021 Robot
Gyro Class Reference

Public Member Functions

 Gyro ()
 
double GetHeading ()
 
frc::Rotation2d GetHeadingAsRot2d ()
 
void ZeroHeading ()
 Zeroes the heading of the robot. More...
 
double GetTurnRate ()
 

Public Attributes

PigeonIMU m_gyro
 

Detailed Description

Definition at line 14 of file Gyro.h.

Constructor & Destructor Documentation

Gyro::Gyro ( )

Definition at line 4 of file Gyro.cpp.

4 : m_gyro(0) {}
PigeonIMU m_gyro
Definition: Gyro.h:31

Member Function Documentation

double Gyro::GetHeading ( )

Returns the heading of the robot.

Returns
the robot's heading in degrees, from -180 to 180

Definition at line 6 of file Gyro.cpp.

References DriveConstants::kGyroReversed, and m_gyro.

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 }
PigeonIMU m_gyro
Definition: Gyro.h:31
constexpr bool kGyroReversed
Definition: Constants.h:75
frc::Rotation2d Gyro::GetHeadingAsRot2d ( )
inline

Definition at line 22 of file Gyro.h.

22 { return frc::Rotation2d(degree_t(GetHeading())); }
double GetHeading()
Definition: Gyro.cpp:6
void Gyro::ZeroHeading ( )

Zeroes the heading of the robot.

Definition at line 15 of file Gyro.cpp.

References m_gyro.

16 {
17  m_gyro.SetFusedHeading(0.0, 0);
18 }
PigeonIMU m_gyro
Definition: Gyro.h:31
double Gyro::GetTurnRate ( )

Returns the turn rate of the robot.

Returns
The turn rate of the robot, in degrees per second

Definition at line 20 of file Gyro.cpp.

References DriveConstants::kGyroReversed, and m_gyro.

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
constexpr bool kGyroReversed
Definition: Constants.h:75

Member Data Documentation

PigeonIMU Gyro::m_gyro

Definition at line 31 of file Gyro.h.


The documentation for this class was generated from the following files: