[wpiutil] Deprecate wpi::math constants in favor of wpi::numbers (#3383)

The constants were moved from std::math to std::numbers before
ratification in C++20.
This commit is contained in:
Tyler Veness
2021-05-26 00:09:36 -07:00
committed by GitHub
parent 393bf23c0c
commit a238cec12b
73 changed files with 322 additions and 284 deletions

View File

@@ -5,7 +5,7 @@
#include "SwerveModule.h"
#include <frc/geometry/Rotation2d.h>
#include <wpi/math>
#include <wpi/numbers>
SwerveModule::SwerveModule(const int driveMotorChannel,
const int turningMotorChannel,
@@ -20,18 +20,19 @@ SwerveModule::SwerveModule(const int driveMotorChannel,
// Set the distance per pulse for the drive encoder. We can simply use the
// distance traveled for one rotation of the wheel divided by the encoder
// resolution.
m_driveEncoder.SetDistancePerPulse(2 * wpi::math::pi * kWheelRadius /
m_driveEncoder.SetDistancePerPulse(2 * wpi::numbers::pi * kWheelRadius /
kEncoderResolution);
// Set the distance (in this case, angle) per pulse for the turning encoder.
// This is the the angle through an entire rotation (2 * wpi::math::pi)
// This is the the angle through an entire rotation (2 * wpi::numbers::pi)
// divided by the encoder resolution.
m_turningEncoder.SetDistancePerPulse(2 * wpi::math::pi / kEncoderResolution);
m_turningEncoder.SetDistancePerPulse(2 * wpi::numbers::pi /
kEncoderResolution);
// Limit the PID Controller's input range between -pi and pi and set the input
// to be continuous.
m_turningPIDController.EnableContinuousInput(-units::radian_t(wpi::math::pi),
units::radian_t(wpi::math::pi));
m_turningPIDController.EnableContinuousInput(
-units::radian_t(wpi::numbers::pi), units::radian_t(wpi::numbers::pi));
}
frc::SwerveModuleState SwerveModule::GetState() const {

View File

@@ -8,7 +8,7 @@
#include <frc/geometry/Translation2d.h>
#include <frc/kinematics/SwerveDriveKinematics.h>
#include <frc/kinematics/SwerveDriveOdometry.h>
#include <wpi/math>
#include <wpi/numbers>
#include "SwerveModule.h"
@@ -27,7 +27,7 @@ class Drivetrain {
static constexpr units::meters_per_second_t kMaxSpeed =
3.0_mps; // 3 meters per second
static constexpr units::radians_per_second_t kMaxAngularSpeed{
wpi::math::pi}; // 1/2 rotation per second
wpi::numbers::pi}; // 1/2 rotation per second
private:
frc::Translation2d m_frontLeftLocation{+0.381_m, +0.381_m};

View File

@@ -14,7 +14,7 @@
#include <units/time.h>
#include <units/velocity.h>
#include <units/voltage.h>
#include <wpi/math>
#include <wpi/numbers>
class SwerveModule {
public:
@@ -29,9 +29,9 @@ class SwerveModule {
static constexpr int kEncoderResolution = 4096;
static constexpr auto kModuleMaxAngularVelocity =
wpi::math::pi * 1_rad_per_s; // radians per second
wpi::numbers::pi * 1_rad_per_s; // radians per second
static constexpr auto kModuleMaxAngularAcceleration =
wpi::math::pi * 2_rad_per_s / 1_s; // radians per second^2
wpi::numbers::pi * 2_rad_per_s / 1_s; // radians per second^2
frc::PWMSparkMax m_driveMotor;
frc::PWMSparkMax m_turningMotor;