mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +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:
@@ -33,13 +33,13 @@ class WPILIB_DLLEXPORT DifferentialDriveKinematics
|
||||
/**
|
||||
* Constructs a differential drive kinematics object.
|
||||
*
|
||||
* @param trackWidth The track width of the drivetrain. Theoretically, this is
|
||||
* @param trackwidth The trackwidth of the drivetrain. Theoretically, this is
|
||||
* the distance between the left wheels and right wheels. However, the
|
||||
* empirical value may be larger than the physical measured value due to
|
||||
* scrubbing effects.
|
||||
*/
|
||||
constexpr explicit DifferentialDriveKinematics(units::meter_t trackWidth)
|
||||
: trackWidth(trackWidth) {
|
||||
constexpr explicit DifferentialDriveKinematics(units::meter_t trackwidth)
|
||||
: trackwidth(trackwidth) {
|
||||
if (!std::is_constant_evaluated()) {
|
||||
wpi::math::MathSharedStore::ReportUsage("DifferentialDriveKinematics",
|
||||
"");
|
||||
@@ -56,7 +56,7 @@ class WPILIB_DLLEXPORT DifferentialDriveKinematics
|
||||
constexpr ChassisSpeeds ToChassisSpeeds(
|
||||
const DifferentialDriveWheelSpeeds& wheelSpeeds) const override {
|
||||
return {(wheelSpeeds.left + wheelSpeeds.right) / 2.0, 0_mps,
|
||||
(wheelSpeeds.right - wheelSpeeds.left) / trackWidth * 1_rad};
|
||||
(wheelSpeeds.right - wheelSpeeds.left) / trackwidth * 1_rad};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -69,8 +69,8 @@ class WPILIB_DLLEXPORT DifferentialDriveKinematics
|
||||
*/
|
||||
constexpr DifferentialDriveWheelSpeeds ToWheelSpeeds(
|
||||
const ChassisSpeeds& chassisSpeeds) const override {
|
||||
return {chassisSpeeds.vx - trackWidth / 2 * chassisSpeeds.omega / 1_rad,
|
||||
chassisSpeeds.vx + trackWidth / 2 * chassisSpeeds.omega / 1_rad};
|
||||
return {chassisSpeeds.vx - trackwidth / 2 * chassisSpeeds.omega / 1_rad,
|
||||
chassisSpeeds.vx + trackwidth / 2 * chassisSpeeds.omega / 1_rad};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,7 +84,7 @@ class WPILIB_DLLEXPORT DifferentialDriveKinematics
|
||||
constexpr Twist2d ToTwist2d(const units::meter_t leftDistance,
|
||||
const units::meter_t rightDistance) const {
|
||||
return {(leftDistance + rightDistance) / 2, 0_m,
|
||||
(rightDistance - leftDistance) / trackWidth * 1_rad};
|
||||
(rightDistance - leftDistance) / trackwidth * 1_rad};
|
||||
}
|
||||
|
||||
constexpr Twist2d ToTwist2d(
|
||||
@@ -100,7 +100,7 @@ class WPILIB_DLLEXPORT DifferentialDriveKinematics
|
||||
}
|
||||
|
||||
/// Differential drive trackwidth.
|
||||
units::meter_t trackWidth;
|
||||
units::meter_t trackwidth;
|
||||
};
|
||||
} // namespace frc
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ struct WPILIB_DLLEXPORT wpi::Struct<frc::DifferentialDriveKinematics> {
|
||||
return "DifferentialDriveKinematics";
|
||||
}
|
||||
static constexpr size_t GetSize() { return 8; }
|
||||
static constexpr std::string_view GetSchema() { return "double track_width"; }
|
||||
static constexpr std::string_view GetSchema() { return "double trackwidth"; }
|
||||
|
||||
static frc::DifferentialDriveKinematics Unpack(std::span<const uint8_t> data);
|
||||
static void Pack(std::span<uint8_t> data,
|
||||
|
||||
@@ -419,7 +419,7 @@ class WPILIB_DLLEXPORT LinearSystemId {
|
||||
* @param motor The motor (or gearbox) driving the drivetrain.
|
||||
* @param mass The mass of the robot in kilograms.
|
||||
* @param r The radius of the wheels in meters.
|
||||
* @param rb The radius of the base (half of the track width), in meters.
|
||||
* @param rb The radius of the base (half of the trackwidth), in meters.
|
||||
* @param J The moment of inertia of the robot.
|
||||
* @param gearing Gear ratio from motor to wheel.
|
||||
* @throws std::domain_error if mass <= 0, r <= 0, rb <= 0, J <= 0, or
|
||||
|
||||
@@ -90,18 +90,18 @@ class WPILIB_DLLEXPORT DifferentialDriveVoltageConstraint
|
||||
if (speed == 0_mps) {
|
||||
maxChassisAcceleration =
|
||||
maxWheelAcceleration /
|
||||
(1 + m_kinematics.trackWidth * units::math::abs(curvature) / (2_rad));
|
||||
(1 + m_kinematics.trackwidth * units::math::abs(curvature) / (2_rad));
|
||||
minChassisAcceleration =
|
||||
minWheelAcceleration /
|
||||
(1 + m_kinematics.trackWidth * units::math::abs(curvature) / (2_rad));
|
||||
(1 + m_kinematics.trackwidth * units::math::abs(curvature) / (2_rad));
|
||||
} else {
|
||||
maxChassisAcceleration =
|
||||
maxWheelAcceleration /
|
||||
(1 + m_kinematics.trackWidth * units::math::abs(curvature) *
|
||||
(1 + m_kinematics.trackwidth * units::math::abs(curvature) *
|
||||
wpi::sgn(speed) / (2_rad));
|
||||
minChassisAcceleration =
|
||||
minWheelAcceleration /
|
||||
(1 - m_kinematics.trackWidth * units::math::abs(curvature) *
|
||||
(1 - m_kinematics.trackwidth * units::math::abs(curvature) *
|
||||
wpi::sgn(speed) / (2_rad));
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ class WPILIB_DLLEXPORT DifferentialDriveVoltageConstraint
|
||||
// wheel when this happens. We can accurately account for this by simply
|
||||
// negating the inner wheel.
|
||||
|
||||
if ((m_kinematics.trackWidth / 2) > 1_rad / units::math::abs(curvature)) {
|
||||
if ((m_kinematics.trackwidth / 2) > 1_rad / units::math::abs(curvature)) {
|
||||
if (speed > 0_mps) {
|
||||
minChassisAcceleration = -minChassisAcceleration;
|
||||
} else if (speed < 0_mps) {
|
||||
|
||||
Reference in New Issue
Block a user