mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
[wpimath] Remove unit suffixes from variable names (#7529)
* Move units into API docs instead because suffixes make user code verbose and hard to read * Rename trackWidth to trackwidth * Make ultrasonic classes use meters instead of a mix of m, cm, mm, ft, and inches
This commit is contained in:
@@ -56,7 +56,7 @@ class Drivetrain {
|
||||
void UpdateOdometry();
|
||||
|
||||
private:
|
||||
static constexpr units::meter_t kTrackWidth = 0.381_m * 2;
|
||||
static constexpr units::meter_t kTrackwidth = 0.381_m * 2;
|
||||
static constexpr double kWheelRadius = 0.0508; // meters
|
||||
static constexpr int kEncoderResolution = 4096;
|
||||
|
||||
@@ -73,7 +73,7 @@ class Drivetrain {
|
||||
|
||||
frc::AnalogGyro m_gyro{0};
|
||||
|
||||
frc::DifferentialDriveKinematics m_kinematics{kTrackWidth};
|
||||
frc::DifferentialDriveKinematics m_kinematics{kTrackwidth};
|
||||
frc::DifferentialDriveOdometry m_odometry{
|
||||
m_gyro.GetRotation2d(), units::meter_t{m_leftEncoder.GetDistance()},
|
||||
units::meter_t{m_rightEncoder.GetDistance()}};
|
||||
|
||||
@@ -111,7 +111,7 @@ class Drivetrain {
|
||||
nt::DoubleArrayEntry& cameraToObjectEntry);
|
||||
|
||||
private:
|
||||
static constexpr units::meter_t kTrackWidth = 0.381_m * 2;
|
||||
static constexpr units::meter_t kTrackwidth = 0.381_m * 2;
|
||||
static constexpr units::meter_t kWheelRadius = 0.0508_m;
|
||||
static constexpr int kEncoderResolution = 4096;
|
||||
|
||||
@@ -146,7 +146,7 @@ class Drivetrain {
|
||||
|
||||
frc::AnalogGyro m_gyro{0};
|
||||
|
||||
frc::DifferentialDriveKinematics m_kinematics{kTrackWidth};
|
||||
frc::DifferentialDriveKinematics m_kinematics{kTrackwidth};
|
||||
|
||||
// Gains are for example purposes only - must be determined for your own
|
||||
// robot!
|
||||
@@ -172,5 +172,5 @@ class Drivetrain {
|
||||
frc::LinearSystemId::IdentifyDrivetrainSystem(
|
||||
1.98_V / 1_mps, 0.2_V / 1_mps_sq, 1.5_V / 1_mps, 0.3_V / 1_mps_sq);
|
||||
frc::sim::DifferentialDrivetrainSim m_drivetrainSimulator{
|
||||
m_drivetrainSystem, kTrackWidth, frc::DCMotor::CIM(2), 8, 2_in};
|
||||
m_drivetrainSystem, kTrackwidth, frc::DCMotor::CIM(2), 8, 2_in};
|
||||
};
|
||||
|
||||
@@ -7,10 +7,10 @@
|
||||
namespace DriveConstants {
|
||||
|
||||
const frc::MecanumDriveKinematics kDriveKinematics{
|
||||
frc::Translation2d{kWheelBase / 2, kTrackWidth / 2},
|
||||
frc::Translation2d{kWheelBase / 2, -kTrackWidth / 2},
|
||||
frc::Translation2d{-kWheelBase / 2, kTrackWidth / 2},
|
||||
frc::Translation2d{-kWheelBase / 2, -kTrackWidth / 2}};
|
||||
frc::Translation2d{kWheelBase / 2, kTrackwidth / 2},
|
||||
frc::Translation2d{kWheelBase / 2, -kTrackwidth / 2},
|
||||
frc::Translation2d{-kWheelBase / 2, kTrackwidth / 2},
|
||||
frc::Translation2d{-kWheelBase / 2, -kTrackwidth / 2}};
|
||||
|
||||
} // namespace DriveConstants
|
||||
|
||||
|
||||
@@ -43,17 +43,17 @@ inline constexpr bool kRearLeftEncoderReversed = true;
|
||||
inline constexpr bool kFrontRightEncoderReversed = false;
|
||||
inline constexpr bool kRearRightEncoderReversed = true;
|
||||
|
||||
inline constexpr auto kTrackWidth =
|
||||
inline constexpr auto kTrackwidth =
|
||||
0.5_m; // Distance between centers of right and left wheels on robot
|
||||
inline constexpr auto kWheelBase =
|
||||
0.7_m; // Distance between centers of front and back wheels on robot
|
||||
extern const frc::MecanumDriveKinematics kDriveKinematics;
|
||||
|
||||
inline constexpr int kEncoderCPR = 1024;
|
||||
inline constexpr double kWheelDiameterMeters = 0.15;
|
||||
inline constexpr auto kWheelDiameter = 0.15_m;
|
||||
inline constexpr double kEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterMeters * std::numbers::pi) /
|
||||
(kWheelDiameter.value() * std::numbers::pi) /
|
||||
static_cast<double>(kEncoderCPR);
|
||||
|
||||
// These are example values only - DO NOT USE THESE FOR YOUR OWN ROBOT!
|
||||
|
||||
@@ -72,7 +72,7 @@ class Drivetrain {
|
||||
void Periodic();
|
||||
|
||||
private:
|
||||
static constexpr units::meter_t kTrackWidth = 0.381_m * 2;
|
||||
static constexpr units::meter_t kTrackwidth = 0.381_m * 2;
|
||||
static constexpr double kWheelRadius = 0.0508; // meters
|
||||
static constexpr int kEncoderResolution = 4096;
|
||||
|
||||
@@ -89,7 +89,7 @@ class Drivetrain {
|
||||
|
||||
frc::AnalogGyro m_gyro{0};
|
||||
|
||||
frc::DifferentialDriveKinematics m_kinematics{kTrackWidth};
|
||||
frc::DifferentialDriveKinematics m_kinematics{kTrackwidth};
|
||||
frc::DifferentialDriveOdometry m_odometry{
|
||||
m_gyro.GetRotation2d(), units::meter_t{m_leftEncoder.GetDistance()},
|
||||
units::meter_t{m_rightEncoder.GetDistance()}};
|
||||
@@ -106,5 +106,5 @@ class Drivetrain {
|
||||
frc::LinearSystemId::IdentifyDrivetrainSystem(
|
||||
1.98_V / 1_mps, 0.2_V / 1_mps_sq, 1.5_V / 1_mps, 0.3_V / 1_mps_sq);
|
||||
frc::sim::DifferentialDrivetrainSim m_drivetrainSimulator{
|
||||
m_drivetrainSystem, kTrackWidth, frc::DCMotor::CIM(2), 8, 2_in};
|
||||
m_drivetrainSystem, kTrackwidth, frc::DCMotor::CIM(2), 8, 2_in};
|
||||
};
|
||||
|
||||
@@ -80,10 +80,10 @@ inline constexpr double kPRearRightVel = 0.5;
|
||||
|
||||
namespace ModuleConstants {
|
||||
inline constexpr int kEncoderCPR = 1024;
|
||||
inline constexpr double kWheelDiameterMeters = 0.15;
|
||||
inline constexpr auto kWheelDiameter = 0.15_m;
|
||||
inline constexpr double kDriveEncoderDistancePerPulse =
|
||||
// Assumes the encoders are directly mounted on the wheel shafts
|
||||
(kWheelDiameterMeters * std::numbers::pi) /
|
||||
(kWheelDiameter.value() * std::numbers::pi) /
|
||||
static_cast<double>(kEncoderCPR);
|
||||
|
||||
inline constexpr double kTurningEncoderDistancePerPulse =
|
||||
|
||||
@@ -88,16 +88,16 @@ class DriveSubsystem : public frc2::SubsystemBase {
|
||||
*/
|
||||
void ResetOdometry(frc::Pose2d pose);
|
||||
|
||||
units::meter_t kTrackWidth =
|
||||
units::meter_t kTrackwidth =
|
||||
0.5_m; // Distance between centers of right and left wheels on robot
|
||||
units::meter_t kWheelBase =
|
||||
0.7_m; // Distance between centers of front and back wheels on robot
|
||||
|
||||
frc::SwerveDriveKinematics<4> kDriveKinematics{
|
||||
frc::Translation2d{kWheelBase / 2, kTrackWidth / 2},
|
||||
frc::Translation2d{kWheelBase / 2, -kTrackWidth / 2},
|
||||
frc::Translation2d{-kWheelBase / 2, kTrackWidth / 2},
|
||||
frc::Translation2d{-kWheelBase / 2, -kTrackWidth / 2}};
|
||||
frc::Translation2d{kWheelBase / 2, kTrackwidth / 2},
|
||||
frc::Translation2d{kWheelBase / 2, -kTrackwidth / 2},
|
||||
frc::Translation2d{-kWheelBase / 2, kTrackwidth / 2},
|
||||
frc::Translation2d{-kWheelBase / 2, -kTrackwidth / 2}};
|
||||
|
||||
private:
|
||||
// Components (e.g. motor controllers and sensors) should generally be
|
||||
|
||||
Reference in New Issue
Block a user