blob: 8317ca57031e5a1c7e8eca5ec9957b68cb5546c2 [file] [log] [blame]
Brian Silverman26e4e522015-12-17 01:56:40 -05001/*----------------------------------------------------------------------------*/
2/* Copyright (c) FIRST 2014. 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 $(WIND_BASE)/WPILib. */
5/*----------------------------------------------------------------------------*/
6#pragma once
7
8/**
9 * Interface for yaw rate gyros
10 */
11class Gyro {
12 public:
13 virtual ~Gyro() = default;
14
15 /**
16 * Calibrate the gyro by running for a number of samples and computing the
17 * center value. Then use the center value as the Accumulator center value for
18 * subsequent measurements. It's important to make sure that the robot is not
19 * moving while the centering calculations are in progress, this is typically
20 * done when the robot is first turned on while it's sitting at rest before
21 * the competition starts.
22 */
23 virtual void Calibrate() = 0;
24
25 /**
26 * Reset the gyro. Resets the gyro to a heading of zero. This can be used if
27 * there is significant drift in the gyro and it needs to be recalibrated
28 * after it has been running.
29 */
30 virtual void Reset() = 0;
31
32 /**
33 * Return the actual angle in degrees that the robot is currently facing.
34 *
35 * The angle is based on the current accumulator value corrected by the
36 * oversampling rate, the gyro type and the A/D calibration values. The angle
37 * is continuous, that is it will continue from 360 to 361 degrees. This
38 * allows algorithms that wouldn't want to see a discontinuity in the gyro
39 * output as it sweeps past from 360 to 0 on the second time around.
40 *
41 * @return the current heading of the robot in degrees. This heading is based
42 * on integration of the returned rate from the gyro.
43 */
44 virtual float GetAngle() const = 0;
45
46 /**
47 * Return the rate of rotation of the gyro
48 *
49 * The rate is based on the most recent reading of the gyro analog value
50 *
51 * @return the current rate in degrees per second
52 */
53 virtual double GetRate() const = 0;
54};