mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-27 02:01:42 +00:00
[wpilib] Deprecate Accelerometer and Gyro interfaces (#5445)
Accelerometer is hyper-specific to ADXL accelerometers, and Gyro is less useful now that 3D IMUs are prevalent, and if those IMUs want to support the Gyro interface, they also need to provide a way to set the axis used for the Gyro interface, which is confusing. Higher-order functions (e.g., lambdas) are a more flexible interface boundary than interfaces, but they didn't exist when these interfaces were created.
This commit is contained in:
@@ -10,7 +10,7 @@
|
||||
#include <wpi/sendable/Sendable.h>
|
||||
#include <wpi/sendable/SendableHelper.h>
|
||||
|
||||
#include "frc/interfaces/Gyro.h"
|
||||
#include "frc/geometry/Rotation2d.h"
|
||||
|
||||
namespace frc {
|
||||
|
||||
@@ -29,8 +29,7 @@ class AnalogInput;
|
||||
*
|
||||
* This class is for gyro sensors that connect to an analog input.
|
||||
*/
|
||||
class AnalogGyro : public Gyro,
|
||||
public wpi::Sendable,
|
||||
class AnalogGyro : public wpi::Sendable,
|
||||
public wpi::SendableHelper<AnalogGyro> {
|
||||
public:
|
||||
static constexpr int kOversampleBits = 10;
|
||||
@@ -118,7 +117,7 @@ class AnalogGyro : public Gyro,
|
||||
* @return The current heading of the robot in degrees. This heading is based
|
||||
* on integration of the returned rate from the gyro.
|
||||
*/
|
||||
double GetAngle() const override;
|
||||
double GetAngle() const;
|
||||
|
||||
/**
|
||||
* Return the rate of rotation of the gyro
|
||||
@@ -127,7 +126,7 @@ class AnalogGyro : public Gyro,
|
||||
*
|
||||
* @return the current rate in degrees per second
|
||||
*/
|
||||
double GetRate() const override;
|
||||
double GetRate() const;
|
||||
|
||||
/**
|
||||
* Return the gyro center value. If run after calibration,
|
||||
@@ -174,7 +173,7 @@ class AnalogGyro : public Gyro,
|
||||
* significant drift in the gyro and it needs to be recalibrated after it has
|
||||
* been running.
|
||||
*/
|
||||
void Reset() final;
|
||||
void Reset();
|
||||
|
||||
/**
|
||||
* Initialize the gyro.
|
||||
@@ -183,7 +182,32 @@ class AnalogGyro : public Gyro,
|
||||
*/
|
||||
void InitGyro();
|
||||
|
||||
void Calibrate() final;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
void Calibrate();
|
||||
|
||||
/**
|
||||
* Return the heading of the robot as a Rotation2d.
|
||||
*
|
||||
* The angle is continuous, that is it will continue from 360 to 361 degrees.
|
||||
* This allows algorithms that wouldn't want to see a discontinuity in the
|
||||
* gyro output as it sweeps past from 360 to 0 on the second time around.
|
||||
*
|
||||
* The angle is expected to increase as the gyro turns counterclockwise when
|
||||
* looked at from the top. It needs to follow the NWU axis convention.
|
||||
*
|
||||
* @return the current heading of the robot as a Rotation2d. This heading is
|
||||
* based on integration of the returned rate from the gyro.
|
||||
*/
|
||||
Rotation2d GetRotation2d() const;
|
||||
|
||||
/**
|
||||
* Gets the analog input for the gyro.
|
||||
|
||||
Reference in New Issue
Block a user