mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[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:
@@ -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,
|
||||
@@ -21,17 +21,18 @@ SwerveModule::SwerveModule(const int driveMotorChannel,
|
||||
// distance traveled for one rotation of the wheel divided by the encoder
|
||||
// resolution.
|
||||
m_driveEncoder.SetDistancePerPulse(
|
||||
2 * wpi::math::pi * kWheelRadius.to<double>() / kEncoderResolution);
|
||||
2 * wpi::numbers::pi * kWheelRadius.to<double>() / 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 {
|
||||
|
||||
@@ -9,7 +9,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 auto 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};
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user