mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Upgrade to C++20 (#4239)
* Use explicit this capture required by C++20 * Use C++20 span * Replace wpi::numbers with std::numbers * Fix C++20 clang-tidy warning false positive in fmt * Remove ciso646 include since C++20 removed that header * Fix global-buffer-overflow asan warnings in ntcore tests * Add DIOSetProxy constructor to HAL * Upgrade MSVC compiler to 2022 * Bump native-utils to 2023.2.7 (changes to std=c++20) Co-authored-by: Peter Johnson <johnson.peter@gmail.com>
This commit is contained in:
@@ -19,11 +19,11 @@
|
||||
#include <frc/Timer.h>
|
||||
|
||||
#include <cmath>
|
||||
#include <numbers>
|
||||
#include <string>
|
||||
|
||||
#include <hal/HAL.h>
|
||||
#include <networktables/NTSendableBuilder.h>
|
||||
#include <wpi/numbers>
|
||||
#include <wpi/sendable/SendableRegistry.h>
|
||||
|
||||
#include "frc/Errors.h"
|
||||
@@ -647,29 +647,29 @@ void ADIS16470_IMU::Acquire() {
|
||||
|
||||
/* Complementary filter functions */
|
||||
double ADIS16470_IMU::FormatFastConverge(double compAngle, double accAngle) {
|
||||
if (compAngle > accAngle + wpi::numbers::pi) {
|
||||
compAngle = compAngle - 2.0 * wpi::numbers::pi;
|
||||
} else if (accAngle > compAngle + wpi::numbers::pi) {
|
||||
compAngle = compAngle + 2.0 * wpi::numbers::pi;
|
||||
if (compAngle > accAngle + std::numbers::pi) {
|
||||
compAngle = compAngle - 2.0 * std::numbers::pi;
|
||||
} else if (accAngle > compAngle + std::numbers::pi) {
|
||||
compAngle = compAngle + 2.0 * std::numbers::pi;
|
||||
}
|
||||
return compAngle;
|
||||
}
|
||||
|
||||
double ADIS16470_IMU::FormatRange0to2PI(double compAngle) {
|
||||
while (compAngle >= 2 * wpi::numbers::pi) {
|
||||
compAngle = compAngle - 2.0 * wpi::numbers::pi;
|
||||
while (compAngle >= 2 * std::numbers::pi) {
|
||||
compAngle = compAngle - 2.0 * std::numbers::pi;
|
||||
}
|
||||
while (compAngle < 0.0) {
|
||||
compAngle = compAngle + 2.0 * wpi::numbers::pi;
|
||||
compAngle = compAngle + 2.0 * std::numbers::pi;
|
||||
}
|
||||
return compAngle;
|
||||
}
|
||||
|
||||
double ADIS16470_IMU::FormatAccelRange(double accelAngle, double accelZ) {
|
||||
if (accelZ < 0.0) {
|
||||
accelAngle = wpi::numbers::pi - accelAngle;
|
||||
accelAngle = std::numbers::pi - accelAngle;
|
||||
} else if (accelZ > 0.0 && accelAngle < 0.0) {
|
||||
accelAngle = 2.0 * wpi::numbers::pi + accelAngle;
|
||||
accelAngle = 2.0 * std::numbers::pi + accelAngle;
|
||||
}
|
||||
return accelAngle;
|
||||
}
|
||||
@@ -680,8 +680,8 @@ double ADIS16470_IMU::CompFilterProcess(double compAngle, double accelAngle,
|
||||
compAngle =
|
||||
m_alpha * (compAngle + omega * m_dt) + (1.0 - m_alpha) * accelAngle;
|
||||
compAngle = FormatRange0to2PI(compAngle);
|
||||
if (compAngle > wpi::numbers::pi) {
|
||||
compAngle = compAngle - 2.0 * wpi::numbers::pi;
|
||||
if (compAngle > std::numbers::pi) {
|
||||
compAngle = compAngle - 2.0 * std::numbers::pi;
|
||||
}
|
||||
return compAngle;
|
||||
}
|
||||
@@ -809,5 +809,5 @@ int ADIS16470_IMU::GetPort() const {
|
||||
void ADIS16470_IMU::InitSendable(nt::NTSendableBuilder& builder) {
|
||||
builder.SetSmartDashboardType("ADIS16470 IMU");
|
||||
builder.AddDoubleProperty(
|
||||
"Yaw Angle", [=] { return GetAngle().value(); }, nullptr);
|
||||
"Yaw Angle", [=, this] { return GetAngle().value(); }, nullptr);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user