mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +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:
@@ -4,11 +4,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <units/angle.h>
|
||||
#include <units/angular_velocity.h>
|
||||
#include <units/time.h>
|
||||
#include <units/voltage.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
/**
|
||||
* The Constants header provides a convenient place for teams to hold robot-wide
|
||||
@@ -34,7 +35,7 @@ constexpr int kEncoderCPR = 1024;
|
||||
constexpr double kWheelDiameterInches = 6;
|
||||
constexpr double kEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterInches * wpi::numbers::pi) /
|
||||
(kWheelDiameterInches * std::numbers::pi) /
|
||||
static_cast<double>(kEncoderCPR);
|
||||
} // namespace DriveConstants
|
||||
|
||||
@@ -56,7 +57,7 @@ constexpr auto kMaxAcceleration = 10_rad / (1_s * 1_s);
|
||||
constexpr int kEncoderPorts[]{4, 5};
|
||||
constexpr int kEncoderPPR = 256;
|
||||
constexpr auto kEncoderDistancePerPulse =
|
||||
2.0_rad * wpi::numbers::pi / kEncoderPPR;
|
||||
2.0_rad * std::numbers::pi / kEncoderPPR;
|
||||
|
||||
// The offset of the arm from the horizontal in its neutral position,
|
||||
// measured from the horizontal
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <units/angle.h>
|
||||
#include <units/angular_velocity.h>
|
||||
#include <units/time.h>
|
||||
#include <units/voltage.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
/**
|
||||
* The Constants header provides a convenient place for teams to hold robot-wide
|
||||
@@ -34,7 +35,7 @@ constexpr int kEncoderCPR = 1024;
|
||||
constexpr double kWheelDiameterInches = 6;
|
||||
constexpr double kEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterInches * wpi::numbers::pi) /
|
||||
(kWheelDiameterInches * std::numbers::pi) /
|
||||
static_cast<double>(kEncoderCPR);
|
||||
} // namespace DriveConstants
|
||||
|
||||
@@ -56,7 +57,7 @@ constexpr auto kMaxAcceleration = 10_rad / (1_s * 1_s);
|
||||
constexpr int kEncoderPorts[]{4, 5};
|
||||
constexpr int kEncoderPPR = 256;
|
||||
constexpr auto kEncoderDistancePerPulse =
|
||||
2.0_rad * wpi::numbers::pi / kEncoderPPR;
|
||||
2.0_rad * std::numbers::pi / kEncoderPPR;
|
||||
|
||||
// The offset of the arm from the horizontal in its neutral position,
|
||||
// measured from the horizontal
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/Encoder.h>
|
||||
#include <frc/Joystick.h>
|
||||
#include <frc/Preferences.h>
|
||||
@@ -22,7 +24,6 @@
|
||||
#include <frc/util/Color8Bit.h>
|
||||
#include <units/angle.h>
|
||||
#include <units/moment_of_inertia.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
/**
|
||||
* This is a sample program to demonstrate how to use a state-space controller
|
||||
@@ -45,7 +46,7 @@ class Robot : public frc::TimedRobot {
|
||||
// distance per pulse = (angle per revolution) / (pulses per revolution)
|
||||
// = (2 * PI rads) / (4096 pulses)
|
||||
static constexpr double kArmEncoderDistPerPulse =
|
||||
2.0 * wpi::numbers::pi / 4096.0;
|
||||
2.0 * std::numbers::pi / 4096.0;
|
||||
|
||||
// The arm gearbox represents a gearbox containing two Vex 775pro motors.
|
||||
frc::DCMotor m_armGearbox = frc::DCMotor::Vex775Pro(2);
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/AnalogGyro.h>
|
||||
#include <frc/Encoder.h>
|
||||
#include <frc/controller/PIDController.h>
|
||||
@@ -16,7 +18,6 @@
|
||||
#include <units/angular_velocity.h>
|
||||
#include <units/length.h>
|
||||
#include <units/velocity.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
/**
|
||||
* Represents a differential drive style drivetrain.
|
||||
@@ -33,9 +34,9 @@ class Drivetrain {
|
||||
// Set the distance per pulse for the drive encoders. We can simply use the
|
||||
// distance traveled for one rotation of the wheel divided by the encoder
|
||||
// resolution.
|
||||
m_leftEncoder.SetDistancePerPulse(2 * wpi::numbers::pi * kWheelRadius /
|
||||
m_leftEncoder.SetDistancePerPulse(2 * std::numbers::pi * kWheelRadius /
|
||||
kEncoderResolution);
|
||||
m_rightEncoder.SetDistancePerPulse(2 * wpi::numbers::pi * kWheelRadius /
|
||||
m_rightEncoder.SetDistancePerPulse(2 * std::numbers::pi * kWheelRadius /
|
||||
kEncoderResolution);
|
||||
|
||||
m_leftEncoder.Reset();
|
||||
@@ -45,7 +46,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::numbers::pi}; // 1/2 rotation per second
|
||||
std::numbers::pi}; // 1/2 rotation per second
|
||||
|
||||
void SetSpeeds(const frc::DifferentialDriveWheelSpeeds& speeds);
|
||||
void Drive(units::meters_per_second_t xSpeed,
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/AnalogGyro.h>
|
||||
#include <frc/Encoder.h>
|
||||
#include <frc/controller/PIDController.h>
|
||||
@@ -16,7 +18,6 @@
|
||||
#include <units/angular_velocity.h>
|
||||
#include <units/length.h>
|
||||
#include <units/velocity.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
/**
|
||||
* Represents a differential drive style drivetrain.
|
||||
@@ -34,9 +35,9 @@ class Drivetrain {
|
||||
// distance traveled for one rotation of the wheel divided by the encoder
|
||||
// resolution.
|
||||
m_leftEncoder.SetDistancePerPulse(
|
||||
2 * wpi::numbers::pi * kWheelRadius.value() / kEncoderResolution);
|
||||
2 * std::numbers::pi * kWheelRadius.value() / kEncoderResolution);
|
||||
m_rightEncoder.SetDistancePerPulse(
|
||||
2 * wpi::numbers::pi * kWheelRadius.value() / kEncoderResolution);
|
||||
2 * std::numbers::pi * kWheelRadius.value() / kEncoderResolution);
|
||||
|
||||
m_leftEncoder.Reset();
|
||||
m_rightEncoder.Reset();
|
||||
@@ -45,7 +46,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::numbers::pi}; // 1/2 rotation per second
|
||||
std::numbers::pi}; // 1/2 rotation per second
|
||||
|
||||
void SetSpeeds(const frc::DifferentialDriveWheelSpeeds& speeds);
|
||||
void Drive(units::meters_per_second_t xSpeed,
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <units/acceleration.h>
|
||||
#include <units/length.h>
|
||||
#include <units/time.h>
|
||||
#include <units/velocity.h>
|
||||
#include <units/voltage.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
/**
|
||||
* The Constants header provides a convenient place for teams to hold robot-wide
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/Encoder.h>
|
||||
#include <frc/Joystick.h>
|
||||
#include <frc/TimedRobot.h>
|
||||
@@ -12,14 +14,13 @@
|
||||
#include <units/length.h>
|
||||
#include <units/time.h>
|
||||
#include <units/velocity.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
static constexpr units::second_t kDt = 20_ms;
|
||||
|
||||
Robot() {
|
||||
m_encoder.SetDistancePerPulse(1.0 / 360.0 * 2.0 * wpi::numbers::pi * 1.5);
|
||||
m_encoder.SetDistancePerPulse(1.0 / 360.0 * 2.0 * std::numbers::pi * 1.5);
|
||||
}
|
||||
|
||||
void TeleopPeriodic() override {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/Encoder.h>
|
||||
#include <frc/Joystick.h>
|
||||
#include <frc/RobotController.h>
|
||||
@@ -23,7 +25,6 @@
|
||||
#include <units/angle.h>
|
||||
#include <units/length.h>
|
||||
#include <units/moment_of_inertia.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
/**
|
||||
* This is a sample program to demonstrate how to use a state-space controller
|
||||
@@ -46,7 +47,7 @@ class Robot : public frc::TimedRobot {
|
||||
// distance per pulse = (distance per revolution) / (pulses per revolution)
|
||||
// = (Pi * D) / ppr
|
||||
static constexpr double kArmEncoderDistPerPulse =
|
||||
2.0 * wpi::numbers::pi * kElevatorDrumRadius.value() / 4096.0;
|
||||
2.0 * std::numbers::pi * kElevatorDrumRadius.value() / 4096.0;
|
||||
|
||||
// This gearbox represents a gearbox containing 4 Vex 775pro motors.
|
||||
frc::DCMotor m_elevatorGearbox = frc::DCMotor::Vex775Pro(4);
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/Joystick.h>
|
||||
#include <frc/TimedRobot.h>
|
||||
#include <frc/controller/SimpleMotorFeedforward.h>
|
||||
@@ -11,7 +13,6 @@
|
||||
#include <units/time.h>
|
||||
#include <units/velocity.h>
|
||||
#include <units/voltage.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
#include "ExampleSmartMotorController.h"
|
||||
|
||||
|
||||
@@ -2,10 +2,11 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/Encoder.h>
|
||||
#include <frc/TimedRobot.h>
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
/**
|
||||
* Sample program displaying the value of a quadrature encoder on the
|
||||
@@ -40,7 +41,7 @@ class Robot : public frc::TimedRobot {
|
||||
* inch diameter (1.5inch radius) wheel, and that we want to measure
|
||||
* distance in inches.
|
||||
*/
|
||||
m_encoder.SetDistancePerPulse(1.0 / 360.0 * 2.0 * wpi::numbers::pi * 1.5);
|
||||
m_encoder.SetDistancePerPulse(1.0 / 360.0 * 2.0 * std::numbers::pi * 1.5);
|
||||
|
||||
/* Defines the lowest rate at which the encoder will not be considered
|
||||
* stopped, for the purposes of the GetStopped() method. Units are in
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <units/angle.h>
|
||||
#include <units/time.h>
|
||||
#include <units/voltage.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
/**
|
||||
* The Constants header provides a convenient place for teams to hold robot-wide
|
||||
@@ -33,7 +34,7 @@ constexpr int kEncoderCPR = 1024;
|
||||
constexpr double kWheelDiameterInches = 6;
|
||||
constexpr double kEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterInches * wpi::numbers::pi) /
|
||||
(kWheelDiameterInches * std::numbers::pi) /
|
||||
static_cast<double>(kEncoderCPR);
|
||||
} // namespace DriveConstants
|
||||
|
||||
|
||||
@@ -4,10 +4,11 @@
|
||||
|
||||
#include "subsystems/Drivetrain.h"
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/Joystick.h>
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
#include <units/length.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
Drivetrain::Drivetrain() {
|
||||
// We need to invert one side of the drivetrain so that positive voltages
|
||||
@@ -26,9 +27,9 @@ Drivetrain::Drivetrain() {
|
||||
#else
|
||||
// Circumference = diameter * pi. 360 tick simulated encoders.
|
||||
m_leftEncoder.SetDistancePerPulse(units::foot_t{4_in}.value() *
|
||||
wpi::numbers::pi / 360.0);
|
||||
std::numbers::pi / 360.0);
|
||||
m_rightEncoder.SetDistancePerPulse(units::foot_t{4_in}.value() *
|
||||
wpi::numbers::pi / 360.0);
|
||||
std::numbers::pi / 360.0);
|
||||
#endif
|
||||
SetName("Drivetrain");
|
||||
// Let's show everything on the LiveWindow
|
||||
|
||||
@@ -4,9 +4,10 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <units/angle.h>
|
||||
#include <units/angular_velocity.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
/**
|
||||
* The Constants header provides a convenient place for teams to hold robot-wide
|
||||
@@ -32,7 +33,7 @@ constexpr int kEncoderCPR = 1024;
|
||||
constexpr double kWheelDiameterInches = 6;
|
||||
constexpr double kEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterInches * wpi::numbers::pi) /
|
||||
(kWheelDiameterInches * std::numbers::pi) /
|
||||
static_cast<double>(kEncoderCPR);
|
||||
|
||||
constexpr bool kGyroReversed = true;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/numbers>
|
||||
#include <numbers>
|
||||
|
||||
/**
|
||||
* The Constants header provides a convenient place for teams to hold robot-wide
|
||||
@@ -30,7 +30,7 @@ constexpr int kEncoderCPR = 1024;
|
||||
constexpr double kWheelDiameterInches = 6;
|
||||
constexpr double kEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterInches * wpi::numbers::pi) /
|
||||
(kWheelDiameterInches * std::numbers::pi) /
|
||||
static_cast<double>(kEncoderCPR);
|
||||
} // namespace DriveConstants
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <wpi/numbers>
|
||||
#include <numbers>
|
||||
|
||||
/**
|
||||
* The Constants header provides a convenient place for teams to hold robot-wide
|
||||
@@ -30,7 +30,7 @@ constexpr int kEncoderCPR = 1024;
|
||||
constexpr double kWheelDiameterInches = 6;
|
||||
constexpr double kEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterInches * wpi::numbers::pi) /
|
||||
(kWheelDiameterInches * std::numbers::pi) /
|
||||
static_cast<double>(kEncoderCPR);
|
||||
} // namespace DriveConstants
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/AnalogGyro.h>
|
||||
#include <frc/Encoder.h>
|
||||
#include <frc/controller/PIDController.h>
|
||||
@@ -13,7 +15,6 @@
|
||||
#include <frc/kinematics/MecanumDriveOdometry.h>
|
||||
#include <frc/kinematics/MecanumDriveWheelSpeeds.h>
|
||||
#include <frc/motorcontrol/PWMSparkMax.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
/**
|
||||
* Represents a mecanum drive style drivetrain.
|
||||
@@ -39,7 +40,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::numbers::pi}; // 1/2 rotation per second
|
||||
std::numbers::pi}; // 1/2 rotation per second
|
||||
|
||||
private:
|
||||
frc::PWMSparkMax m_frontLeftMotor{1};
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/geometry/Translation2d.h>
|
||||
#include <frc/kinematics/MecanumDriveKinematics.h>
|
||||
#include <frc/trajectory/TrapezoidProfile.h>
|
||||
@@ -13,7 +15,6 @@
|
||||
#include <units/time.h>
|
||||
#include <units/velocity.h>
|
||||
#include <units/voltage.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -52,7 +53,7 @@ constexpr int kEncoderCPR = 1024;
|
||||
constexpr double kWheelDiameterMeters = 0.15;
|
||||
constexpr double kEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterMeters * wpi::numbers::pi) /
|
||||
(kWheelDiameterMeters * std::numbers::pi) /
|
||||
static_cast<double>(kEncoderCPR);
|
||||
|
||||
// These are example values only - DO NOT USE THESE FOR YOUR OWN ROBOT!
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/AnalogGyro.h>
|
||||
#include <frc/Encoder.h>
|
||||
#include <frc/controller/PIDController.h>
|
||||
@@ -14,7 +16,6 @@
|
||||
#include <frc/kinematics/MecanumDriveOdometry.h>
|
||||
#include <frc/kinematics/MecanumDriveWheelSpeeds.h>
|
||||
#include <frc/motorcontrol/PWMSparkMax.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
/**
|
||||
* Represents a mecanum drive style drivetrain.
|
||||
@@ -39,7 +40,7 @@ class Drivetrain {
|
||||
|
||||
static constexpr auto kMaxSpeed = 3.0_mps; // 3 meters per second
|
||||
static constexpr units::radians_per_second_t kMaxAngularSpeed{
|
||||
wpi::numbers::pi}; // 1/2 rotation per second
|
||||
std::numbers::pi}; // 1/2 rotation per second
|
||||
|
||||
private:
|
||||
frc::PWMSparkMax m_frontLeftMotor{1};
|
||||
|
||||
@@ -2,12 +2,13 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/Encoder.h>
|
||||
#include <frc/Joystick.h>
|
||||
#include <frc/TimedRobot.h>
|
||||
#include <frc/motorcontrol/PWMSparkMax.h>
|
||||
#include <frc/smartdashboard/SmartDashboard.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
/**
|
||||
* This sample program shows how to control a motor using a joystick. In the
|
||||
@@ -35,7 +36,7 @@ class Robot : public frc::TimedRobot {
|
||||
void RobotInit() override {
|
||||
// Use SetDistancePerPulse to set the multiplier for GetDistance
|
||||
// This is set up assuming a 6 inch wheel with a 360 CPR encoder.
|
||||
m_encoder.SetDistancePerPulse((wpi::numbers::pi * 6) / 360.0);
|
||||
m_encoder.SetDistancePerPulse((std::numbers::pi * 6) / 360.0);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/kinematics/DifferentialDriveKinematics.h>
|
||||
#include <frc/trajectory/constraint/DifferentialDriveKinematicsConstraint.h>
|
||||
#include <units/acceleration.h>
|
||||
@@ -10,7 +12,6 @@
|
||||
#include <units/time.h>
|
||||
#include <units/velocity.h>
|
||||
#include <units/voltage.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -41,7 +42,7 @@ constexpr int kEncoderCPR = 1024;
|
||||
constexpr double kWheelDiameterInches = 6;
|
||||
constexpr double kEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterInches * wpi::numbers::pi) /
|
||||
(kWheelDiameterInches * std::numbers::pi) /
|
||||
static_cast<double>(kEncoderCPR);
|
||||
|
||||
// These are example values only - DO NOT USE THESE FOR YOUR OWN ROBOT!
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/AnalogGyro.h>
|
||||
#include <frc/Encoder.h>
|
||||
#include <frc/controller/PIDController.h>
|
||||
@@ -14,7 +16,6 @@
|
||||
#include <frc/motorcontrol/PWMSparkMax.h>
|
||||
#include <units/angular_velocity.h>
|
||||
#include <units/length.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
/**
|
||||
* Represents a differential drive style drivetrain.
|
||||
@@ -32,9 +33,9 @@ class Drivetrain {
|
||||
// Set the distance per pulse for the drive encoders. We can simply use the
|
||||
// distance traveled for one rotation of the wheel divided by the encoder
|
||||
// resolution.
|
||||
m_leftEncoder.SetDistancePerPulse(2 * wpi::numbers::pi * kWheelRadius /
|
||||
m_leftEncoder.SetDistancePerPulse(2 * std::numbers::pi * kWheelRadius /
|
||||
kEncoderResolution);
|
||||
m_rightEncoder.SetDistancePerPulse(2 * wpi::numbers::pi * kWheelRadius /
|
||||
m_rightEncoder.SetDistancePerPulse(2 * std::numbers::pi * kWheelRadius /
|
||||
kEncoderResolution);
|
||||
|
||||
m_leftEncoder.Reset();
|
||||
@@ -44,7 +45,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::numbers::pi}; // 1/2 rotation per second
|
||||
std::numbers::pi}; // 1/2 rotation per second
|
||||
|
||||
void SetSpeeds(const frc::DifferentialDriveWheelSpeeds& speeds);
|
||||
void Drive(units::meters_per_second_t xSpeed,
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
|
||||
#include "commands/TurnDegrees.h"
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <units/math.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
void TurnDegrees::Initialize() {
|
||||
// Set motors to stop, read encoder values for starting point
|
||||
@@ -26,7 +27,7 @@ bool TurnDegrees::IsFinished() {
|
||||
// found here https://www.pololu.com/category/203/romi-chassis-kits, has a
|
||||
// wheel placement diameter (149 mm) - width of the wheel (8 mm) = 141 mm
|
||||
// or 5.551 inches. We then take into consideration the width of the tires.
|
||||
static auto inchPerDegree = (5.551_in * wpi::numbers::pi) / 360_deg;
|
||||
static auto inchPerDegree = (5.551_in * std::numbers::pi) / 360_deg;
|
||||
|
||||
// Compare distance traveled from start to distance based on degree turn.
|
||||
return GetAverageTurningDistance() >= inchPerDegree * m_angle;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
|
||||
#include "subsystems/Drivetrain.h"
|
||||
|
||||
#include <wpi/numbers>
|
||||
#include <numbers>
|
||||
|
||||
#include "Constants.h"
|
||||
|
||||
@@ -20,9 +20,9 @@ Drivetrain::Drivetrain() {
|
||||
// gearbox is constructed, you might have to invert the left side instead.
|
||||
m_rightMotor.SetInverted(true);
|
||||
|
||||
m_leftEncoder.SetDistancePerPulse(wpi::numbers::pi * kWheelDiameter.value() /
|
||||
m_leftEncoder.SetDistancePerPulse(std::numbers::pi * kWheelDiameter.value() /
|
||||
kCountsPerRevolution);
|
||||
m_rightEncoder.SetDistancePerPulse(wpi::numbers::pi * kWheelDiameter.value() /
|
||||
m_rightEncoder.SetDistancePerPulse(std::numbers::pi * kWheelDiameter.value() /
|
||||
kCountsPerRevolution);
|
||||
ResetEncoders();
|
||||
}
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/AnalogGyro.h>
|
||||
#include <frc/Encoder.h>
|
||||
#include <frc/controller/PIDController.h>
|
||||
@@ -22,7 +24,6 @@
|
||||
#include <units/angular_velocity.h>
|
||||
#include <units/length.h>
|
||||
#include <units/velocity.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
/**
|
||||
* Represents a differential drive style drivetrain.
|
||||
@@ -40,9 +41,9 @@ class Drivetrain {
|
||||
// Set the distance per pulse for the drive encoders. We can simply use the
|
||||
// distance traveled for one rotation of the wheel divided by the encoder
|
||||
// resolution.
|
||||
m_leftEncoder.SetDistancePerPulse(2 * wpi::numbers::pi * kWheelRadius /
|
||||
m_leftEncoder.SetDistancePerPulse(2 * std::numbers::pi * kWheelRadius /
|
||||
kEncoderResolution);
|
||||
m_rightEncoder.SetDistancePerPulse(2 * wpi::numbers::pi * kWheelRadius /
|
||||
m_rightEncoder.SetDistancePerPulse(2 * std::numbers::pi * kWheelRadius /
|
||||
kEncoderResolution);
|
||||
|
||||
m_leftEncoder.Reset();
|
||||
@@ -56,7 +57,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::numbers::pi}; // 1/2 rotation per second
|
||||
std::numbers::pi}; // 1/2 rotation per second
|
||||
|
||||
void SetSpeeds(const frc::DifferentialDriveWheelSpeeds& speeds);
|
||||
void Drive(units::meters_per_second_t xSpeed,
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/Encoder.h>
|
||||
#include <frc/TimedRobot.h>
|
||||
#include <frc/XboxController.h>
|
||||
@@ -15,7 +17,6 @@
|
||||
#include <frc/trajectory/TrapezoidProfile.h>
|
||||
#include <units/angle.h>
|
||||
#include <units/moment_of_inertia.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
/**
|
||||
* This is a sample program to demonstrate how to use a state-space controller
|
||||
@@ -63,8 +64,8 @@ class Robot : public frc::TimedRobot {
|
||||
// qelms. Velocity error tolerance, in radians and radians per second.
|
||||
// Decrease this to more heavily penalize state excursion, or make the
|
||||
// controller behave more aggressively.
|
||||
{1.0 * 2.0 * wpi::numbers::pi / 360.0,
|
||||
10.0 * 2.0 * wpi::numbers::pi / 360.0},
|
||||
{1.0 * 2.0 * std::numbers::pi / 360.0,
|
||||
10.0 * 2.0 * std::numbers::pi / 360.0},
|
||||
// relms. Control effort (voltage) tolerance. Decrease this to more
|
||||
// heavily penalize control effort, or make the controller less
|
||||
// aggressive. 12 is a good starting point because that is the
|
||||
@@ -93,7 +94,7 @@ class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override {
|
||||
// We go 2 pi radians per 4096 clicks.
|
||||
m_encoder.SetDistancePerPulse(2.0 * wpi::numbers::pi / 4096.0);
|
||||
m_encoder.SetDistancePerPulse(2.0 * std::numbers::pi / 4096.0);
|
||||
}
|
||||
|
||||
void TeleopInit() override {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/kinematics/DifferentialDriveKinematics.h>
|
||||
#include <frc/system/plant/DCMotor.h>
|
||||
#include <frc/system/plant/LinearSystemId.h>
|
||||
@@ -12,7 +14,6 @@
|
||||
#include <units/time.h>
|
||||
#include <units/velocity.h>
|
||||
#include <units/voltage.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -43,7 +44,7 @@ constexpr int kEncoderCPR = 1024;
|
||||
constexpr auto kWheelDiameter = 6_in;
|
||||
constexpr double kEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameter.value() * wpi::numbers::pi) /
|
||||
(kWheelDiameter.value() * std::numbers::pi) /
|
||||
static_cast<double>(kEncoderCPR);
|
||||
|
||||
// These are example values only - DO NOT USE THESE FOR YOUR OWN ROBOT!
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/Encoder.h>
|
||||
#include <frc/TimedRobot.h>
|
||||
#include <frc/XboxController.h>
|
||||
@@ -17,7 +19,6 @@
|
||||
#include <units/length.h>
|
||||
#include <units/mass.h>
|
||||
#include <units/velocity.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
/**
|
||||
* This is a sample program to demonstrate how to use a state-space controller
|
||||
@@ -90,7 +91,7 @@ class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override {
|
||||
// Circumference = pi * d, so distance per click = pi * d / counts
|
||||
m_encoder.SetDistancePerPulse(2.0 * wpi::numbers::pi * kDrumRadius.value() /
|
||||
m_encoder.SetDistancePerPulse(2.0 * std::numbers::pi * kDrumRadius.value() /
|
||||
4096.0);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/DriverStation.h>
|
||||
#include <frc/Encoder.h>
|
||||
#include <frc/TimedRobot.h>
|
||||
@@ -14,7 +16,6 @@
|
||||
#include <frc/system/plant/DCMotor.h>
|
||||
#include <frc/system/plant/LinearSystemId.h>
|
||||
#include <units/angular_velocity.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
/**
|
||||
* This is a sample program to demonstrate how to use a state-space controller
|
||||
@@ -81,7 +82,7 @@ class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override {
|
||||
// We go 2 pi radians per 4096 clicks.
|
||||
m_encoder.SetDistancePerPulse(2.0 * wpi::numbers::pi / 4096.0);
|
||||
m_encoder.SetDistancePerPulse(2.0 * std::numbers::pi / 4096.0);
|
||||
}
|
||||
|
||||
void TeleopInit() override {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/DriverStation.h>
|
||||
#include <frc/Encoder.h>
|
||||
#include <frc/TimedRobot.h>
|
||||
@@ -13,7 +15,6 @@
|
||||
#include <frc/system/LinearSystemLoop.h>
|
||||
#include <frc/system/plant/DCMotor.h>
|
||||
#include <frc/system/plant/LinearSystemId.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
/**
|
||||
* This is a sample program to demonstrate how to use a state-space controller
|
||||
@@ -81,7 +82,7 @@ class Robot : public frc::TimedRobot {
|
||||
public:
|
||||
void RobotInit() override {
|
||||
// We go 2 pi radians per 4096 clicks.
|
||||
m_encoder.SetDistancePerPulse(2.0 * wpi::numbers::pi / 4096.0);
|
||||
m_encoder.SetDistancePerPulse(2.0 * std::numbers::pi / 4096.0);
|
||||
}
|
||||
|
||||
void TeleopInit() override {
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
|
||||
#include "SwerveModule.h"
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/geometry/Rotation2d.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
SwerveModule::SwerveModule(const int driveMotorChannel,
|
||||
const int turningMotorChannel,
|
||||
@@ -20,19 +21,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::numbers::pi * kWheelRadius /
|
||||
m_driveEncoder.SetDistancePerPulse(2 * std::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::numbers::pi)
|
||||
// This is the the angle through an entire rotation (2 * std::numbers::pi)
|
||||
// divided by the encoder resolution.
|
||||
m_turningEncoder.SetDistancePerPulse(2 * wpi::numbers::pi /
|
||||
m_turningEncoder.SetDistancePerPulse(2 * std::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::numbers::pi}, units::radian_t{wpi::numbers::pi});
|
||||
-units::radian_t{std::numbers::pi}, units::radian_t{std::numbers::pi});
|
||||
}
|
||||
|
||||
frc::SwerveModuleState SwerveModule::GetState() const {
|
||||
|
||||
@@ -4,11 +4,12 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/AnalogGyro.h>
|
||||
#include <frc/geometry/Translation2d.h>
|
||||
#include <frc/kinematics/SwerveDriveKinematics.h>
|
||||
#include <frc/kinematics/SwerveDriveOdometry.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
#include "SwerveModule.h"
|
||||
|
||||
@@ -27,7 +28,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::numbers::pi}; // 1/2 rotation per second
|
||||
std::numbers::pi}; // 1/2 rotation per second
|
||||
|
||||
private:
|
||||
frc::Translation2d m_frontLeftLocation{+0.381_m, +0.381_m};
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/Encoder.h>
|
||||
#include <frc/controller/PIDController.h>
|
||||
#include <frc/controller/ProfiledPIDController.h>
|
||||
@@ -14,7 +16,6 @@
|
||||
#include <units/time.h>
|
||||
#include <units/velocity.h>
|
||||
#include <units/voltage.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
class SwerveModule {
|
||||
public:
|
||||
@@ -29,9 +30,9 @@ class SwerveModule {
|
||||
static constexpr int kEncoderResolution = 4096;
|
||||
|
||||
static constexpr auto kModuleMaxAngularVelocity =
|
||||
wpi::numbers::pi * 1_rad_per_s; // radians per second
|
||||
std::numbers::pi * 1_rad_per_s; // radians per second
|
||||
static constexpr auto kModuleMaxAngularAcceleration =
|
||||
wpi::numbers::pi * 2_rad_per_s / 1_s; // radians per second^2
|
||||
std::numbers::pi * 2_rad_per_s / 1_s; // radians per second^2
|
||||
|
||||
frc::PWMSparkMax m_driveMotor;
|
||||
frc::PWMSparkMax m_turningMotor;
|
||||
|
||||
@@ -66,8 +66,8 @@ frc2::Command* RobotContainer::GetAutonomousCommand() {
|
||||
AutoConstants::kPThetaController, 0, 0,
|
||||
AutoConstants::kThetaControllerConstraints};
|
||||
|
||||
thetaController.EnableContinuousInput(units::radian_t{-wpi::numbers::pi},
|
||||
units::radian_t{wpi::numbers::pi});
|
||||
thetaController.EnableContinuousInput(units::radian_t{-std::numbers::pi},
|
||||
units::radian_t{std::numbers::pi});
|
||||
|
||||
frc2::SwerveControllerCommand<4> swerveControllerCommand(
|
||||
exampleTrajectory, [this]() { return m_drive.GetPose(); },
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
|
||||
#include "subsystems/SwerveModule.h"
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/geometry/Rotation2d.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
#include "Constants.h"
|
||||
|
||||
@@ -27,7 +28,7 @@ SwerveModule::SwerveModule(int driveMotorChannel, int turningMotorChannel,
|
||||
ModuleConstants::kDriveEncoderDistancePerPulse);
|
||||
|
||||
// Set the distance (in this case, angle) per pulse for the turning encoder.
|
||||
// This is the the angle through an entire rotation (2 * wpi::numbers::pi)
|
||||
// This is the the angle through an entire rotation (2 * std::numbers::pi)
|
||||
// divided by the encoder resolution.
|
||||
m_turningEncoder.SetDistancePerPulse(
|
||||
ModuleConstants::kTurningEncoderDistancePerPulse);
|
||||
@@ -35,7 +36,7 @@ SwerveModule::SwerveModule(int driveMotorChannel, int turningMotorChannel,
|
||||
// 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::numbers::pi}, units::radian_t{wpi::numbers::pi});
|
||||
units::radian_t{-std::numbers::pi}, units::radian_t{std::numbers::pi});
|
||||
}
|
||||
|
||||
frc::SwerveModuleState SwerveModule::GetState() {
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
// Open Source Software; you can modify and/or share it under the terms of
|
||||
// the WPILib BSD license file in the root directory of this project.
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/geometry/Translation2d.h>
|
||||
#include <frc/kinematics/SwerveDriveKinematics.h>
|
||||
#include <frc/trajectory/TrapezoidProfile.h>
|
||||
@@ -13,7 +15,6 @@
|
||||
#include <units/time.h>
|
||||
#include <units/velocity.h>
|
||||
#include <units/voltage.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
#pragma once
|
||||
|
||||
@@ -77,12 +78,12 @@ constexpr int kEncoderCPR = 1024;
|
||||
constexpr double kWheelDiameterMeters = 0.15;
|
||||
constexpr double kDriveEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterMeters * wpi::numbers::pi) /
|
||||
(kWheelDiameterMeters * std::numbers::pi) /
|
||||
static_cast<double>(kEncoderCPR);
|
||||
|
||||
constexpr double kTurningEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(wpi::numbers::pi * 2) / static_cast<double>(kEncoderCPR);
|
||||
(std::numbers::pi * 2) / static_cast<double>(kEncoderCPR);
|
||||
|
||||
constexpr double kPModuleTurningController = 1;
|
||||
constexpr double kPModuleDriveController = 1;
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/Encoder.h>
|
||||
#include <frc/controller/PIDController.h>
|
||||
#include <frc/controller/ProfiledPIDController.h>
|
||||
@@ -11,7 +13,6 @@
|
||||
#include <frc/kinematics/SwerveModuleState.h>
|
||||
#include <frc/motorcontrol/Spark.h>
|
||||
#include <frc/trajectory/TrapezoidProfile.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
#include "Constants.h"
|
||||
|
||||
@@ -33,9 +34,9 @@ class SwerveModule {
|
||||
// meters per second squared.
|
||||
|
||||
static constexpr auto kModuleMaxAngularVelocity =
|
||||
units::radians_per_second_t{wpi::numbers::pi};
|
||||
units::radians_per_second_t{std::numbers::pi};
|
||||
static constexpr auto kModuleMaxAngularAcceleration =
|
||||
units::radians_per_second_squared_t{wpi::numbers::pi * 2.0};
|
||||
units::radians_per_second_squared_t{std::numbers::pi * 2.0};
|
||||
|
||||
frc::Spark m_driveMotor;
|
||||
frc::Spark m_turningMotor;
|
||||
|
||||
@@ -4,8 +4,9 @@
|
||||
|
||||
#include "SwerveModule.h"
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/geometry/Rotation2d.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
SwerveModule::SwerveModule(const int driveMotorChannel,
|
||||
const int turningMotorChannel,
|
||||
@@ -20,19 +21,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::numbers::pi *
|
||||
m_driveEncoder.SetDistancePerPulse(2 * std::numbers::pi *
|
||||
kWheelRadius.value() / 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::numbers::pi)
|
||||
// This is the the angle through an entire rotation (2 * std::numbers::pi)
|
||||
// divided by the encoder resolution.
|
||||
m_turningEncoder.SetDistancePerPulse(2 * wpi::numbers::pi /
|
||||
m_turningEncoder.SetDistancePerPulse(2 * std::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::numbers::pi}, units::radian_t{wpi::numbers::pi});
|
||||
-units::radian_t{std::numbers::pi}, units::radian_t{std::numbers::pi});
|
||||
}
|
||||
|
||||
frc::SwerveModuleState SwerveModule::GetState() const {
|
||||
|
||||
@@ -4,12 +4,13 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/AnalogGyro.h>
|
||||
#include <frc/estimator/SwerveDrivePoseEstimator.h>
|
||||
#include <frc/geometry/Translation2d.h>
|
||||
#include <frc/kinematics/SwerveDriveKinematics.h>
|
||||
#include <frc/kinematics/SwerveDriveOdometry.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
#include "SwerveModule.h"
|
||||
|
||||
@@ -27,7 +28,7 @@ class Drivetrain {
|
||||
|
||||
static constexpr auto kMaxSpeed = 3.0_mps; // 3 meters per second
|
||||
static constexpr units::radians_per_second_t kMaxAngularSpeed{
|
||||
wpi::numbers::pi}; // 1/2 rotation per second
|
||||
std::numbers::pi}; // 1/2 rotation per second
|
||||
|
||||
private:
|
||||
frc::Translation2d m_frontLeftLocation{+0.381_m, +0.381_m};
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <frc/Encoder.h>
|
||||
#include <frc/controller/PIDController.h>
|
||||
#include <frc/controller/ProfiledPIDController.h>
|
||||
@@ -14,7 +16,6 @@
|
||||
#include <units/time.h>
|
||||
#include <units/velocity.h>
|
||||
#include <units/voltage.h>
|
||||
#include <wpi/numbers>
|
||||
|
||||
class SwerveModule {
|
||||
public:
|
||||
@@ -29,9 +30,9 @@ class SwerveModule {
|
||||
static constexpr int kEncoderResolution = 4096;
|
||||
|
||||
static constexpr auto kModuleMaxAngularVelocity =
|
||||
wpi::numbers::pi * 1_rad_per_s; // radians per second
|
||||
std::numbers::pi * 1_rad_per_s; // radians per second
|
||||
static constexpr auto kModuleMaxAngularAcceleration =
|
||||
wpi::numbers::pi * 2_rad_per_s / 1_s; // radians per second^2
|
||||
std::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