001/*----------------------------------------------------------------------------*/ 002/* Copyright (c) FIRST 2014-2017. All Rights Reserved. */ 003/* Open Source Software - may be modified and shared by FRC teams. The code */ 004/* must be accompanied by the FIRST BSD license file in the root directory of */ 005/* the project. */ 006/*----------------------------------------------------------------------------*/ 007 008package edu.wpi.first.wpilibj.interfaces; 009 010/** 011 * Interface for yaw rate gyros. 012 */ 013public interface Gyro { 014 /** 015 * Calibrate the gyro by running for a number of samples and computing the center value. Then use 016 * the center value as the Accumulator center value for subsequent measurements. It's important to 017 * make sure that the robot is not moving while the centering calculations are in progress, this 018 * is typically done when the robot is first turned on while it's sitting at rest before the 019 * competition starts. 020 */ 021 void calibrate(); 022 023 /** 024 * Reset the gyro. Resets the gyro to a heading of zero. This can be used if there is significant 025 * drift in the gyro and it needs to be recalibrated after it has been running. 026 */ 027 void reset(); 028 029 /** 030 * Return the actual angle in degrees that the robot is currently facing. 031 * 032 * <p>The angle is based on the current accumulator value corrected by the oversampling rate, the 033 * gyro type and the A/D calibration values. The angle is continuous, that is it will continue 034 * from 360 to 361 degrees. This allows algorithms that wouldn't want to see a discontinuity in 035 * the gyro output as it sweeps past from 360 to 0 on the second time around. 036 * 037 * <p>This heading is based on integration of the returned rate from the gyro. 038 * 039 * @return the current heading of the robot in degrees. 040 */ 041 double getAngle(); 042 043 /** 044 * Return the rate of rotation of the gyro. 045 * 046 * <p>The rate is based on the most recent reading of the gyro analog value 047 * 048 * @return the current rate in degrees per second 049 */ 050 double getRate(); 051 052 /** 053 * Free the resources used by the gyro. 054 */ 055 void free(); 056}