mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51: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:
@@ -93,7 +93,6 @@ void ADXL362::SetRange(Range range) {
|
||||
m_gsPerLSB = 0.002;
|
||||
break;
|
||||
case kRange_8G:
|
||||
case kRange_16G: // 16G not supported; treat as 8G
|
||||
m_gsPerLSB = 0.004;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -140,6 +140,10 @@ void ADXRS450_Gyro::Calibrate() {
|
||||
m_spi.ResetAccumulator();
|
||||
}
|
||||
|
||||
Rotation2d ADXRS450_Gyro::GetRotation2d() const {
|
||||
return units::degree_t{-GetAngle()};
|
||||
}
|
||||
|
||||
int ADXRS450_Gyro::GetPort() const {
|
||||
return m_port;
|
||||
}
|
||||
|
||||
@@ -133,6 +133,10 @@ void AnalogGyro::Calibrate() {
|
||||
FRC_CheckErrorStatus(status, "Channel {}", m_analog->GetChannel());
|
||||
}
|
||||
|
||||
Rotation2d AnalogGyro::GetRotation2d() const {
|
||||
return units::degree_t{-GetAngle()};
|
||||
}
|
||||
|
||||
std::shared_ptr<AnalogInput> AnalogGyro::GetAnalogInput() const {
|
||||
return m_analog;
|
||||
}
|
||||
|
||||
@@ -22,11 +22,6 @@ BuiltInAccelerometer::BuiltInAccelerometer(Range range) {
|
||||
}
|
||||
|
||||
void BuiltInAccelerometer::SetRange(Range range) {
|
||||
if (range == kRange_16G) {
|
||||
throw FRC_MakeError(err::ParameterOutOfRange,
|
||||
"16G range not supported (use k2G, k4G, or k8G)");
|
||||
}
|
||||
|
||||
HAL_SetAccelerometerActive(false);
|
||||
HAL_SetAccelerometerRange(static_cast<HAL_AccelerometerRange>(range));
|
||||
HAL_SetAccelerometerActive(true);
|
||||
|
||||
Reference in New Issue
Block a user