mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-05 03:21:42 +00:00
[wpilib] Rename drivetrain sim enums to all caps
This commit is contained in:
@@ -86,18 +86,18 @@ double DifferentialDrivetrainSim::GetState(int state) const {
|
||||
}
|
||||
|
||||
wpi::math::Rotation2d DifferentialDrivetrainSim::GetHeading() const {
|
||||
return wpi::units::radian_t{GetOutput(State::kHeading)};
|
||||
return wpi::units::radian_t{GetOutput(State::HEADING)};
|
||||
}
|
||||
|
||||
wpi::math::Pose2d DifferentialDrivetrainSim::GetPose() const {
|
||||
return wpi::math::Pose2d{wpi::units::meter_t{GetOutput(State::kX)},
|
||||
wpi::units::meter_t{GetOutput(State::kY)},
|
||||
return wpi::math::Pose2d{wpi::units::meter_t{GetOutput(State::X)},
|
||||
wpi::units::meter_t{GetOutput(State::Y)},
|
||||
GetHeading()};
|
||||
}
|
||||
|
||||
wpi::units::ampere_t DifferentialDrivetrainSim::GetLeftCurrentDraw() const {
|
||||
return m_motor.Current(
|
||||
wpi::units::radians_per_second_t{m_x(State::kLeftVelocity) *
|
||||
wpi::units::radians_per_second_t{m_x(State::LEFT_VELOCITY) *
|
||||
m_currentGearing /
|
||||
m_wheelRadius.value()},
|
||||
wpi::units::volt_t{m_u(0)}) *
|
||||
@@ -106,7 +106,7 @@ wpi::units::ampere_t DifferentialDrivetrainSim::GetLeftCurrentDraw() const {
|
||||
|
||||
wpi::units::ampere_t DifferentialDrivetrainSim::GetRightCurrentDraw() const {
|
||||
return m_motor.Current(
|
||||
wpi::units::radians_per_second_t{m_x(State::kRightVelocity) *
|
||||
wpi::units::radians_per_second_t{m_x(State::RIGHT_VELOCITY) *
|
||||
m_currentGearing /
|
||||
m_wheelRadius.value()},
|
||||
wpi::units::volt_t{m_u(1)}) *
|
||||
@@ -122,11 +122,11 @@ void DifferentialDrivetrainSim::SetState(const wpi::math::Vectord<7>& state) {
|
||||
}
|
||||
|
||||
void DifferentialDrivetrainSim::SetPose(const wpi::math::Pose2d& pose) {
|
||||
m_x(State::kX) = pose.X().value();
|
||||
m_x(State::kY) = pose.Y().value();
|
||||
m_x(State::kHeading) = pose.Rotation().Radians().value();
|
||||
m_x(State::kLeftPosition) = 0;
|
||||
m_x(State::kRightPosition) = 0;
|
||||
m_x(State::X) = pose.X().value();
|
||||
m_x(State::Y) = pose.Y().value();
|
||||
m_x(State::HEADING) = pose.Rotation().Radians().value();
|
||||
m_x(State::LEFT_POSITION) = 0;
|
||||
m_x(State::RIGHT_POSITION) = 0;
|
||||
}
|
||||
|
||||
wpi::math::Vectord<7> DifferentialDrivetrainSim::Dynamics(
|
||||
@@ -147,13 +147,13 @@ wpi::math::Vectord<7> DifferentialDrivetrainSim::Dynamics(
|
||||
A.block<2, 2>(2, 0).setIdentity();
|
||||
A.block<4, 2>(0, 2).setZero();
|
||||
|
||||
double v = (x(State::kLeftVelocity) + x(State::kRightVelocity)) / 2.0;
|
||||
double v = (x(State::LEFT_VELOCITY) + x(State::RIGHT_VELOCITY)) / 2.0;
|
||||
|
||||
wpi::math::Vectord<7> xdot;
|
||||
xdot(0) = v * std::cos(x(State::kHeading));
|
||||
xdot(1) = v * std::sin(x(State::kHeading));
|
||||
xdot(0) = v * std::cos(x(State::HEADING));
|
||||
xdot(1) = v * std::sin(x(State::HEADING));
|
||||
xdot(2) =
|
||||
((x(State::kRightVelocity) - x(State::kLeftVelocity)) / (2.0 * m_rb))
|
||||
((x(State::RIGHT_VELOCITY) - x(State::LEFT_VELOCITY)) / (2.0 * m_rb))
|
||||
.value();
|
||||
xdot.block<4, 1>(3, 0) = A * x.block<4, 1>(3, 0) + B * u;
|
||||
return xdot;
|
||||
|
||||
@@ -131,7 +131,7 @@ class DifferentialDrivetrainSim {
|
||||
* @return The encoder position.
|
||||
*/
|
||||
wpi::units::meter_t GetRightPosition() const {
|
||||
return wpi::units::meter_t{GetOutput(State::kRightPosition)};
|
||||
return wpi::units::meter_t{GetOutput(State::RIGHT_POSITION)};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,7 +139,7 @@ class DifferentialDrivetrainSim {
|
||||
* @return The encoder velocity.
|
||||
*/
|
||||
wpi::units::meters_per_second_t GetRightVelocity() const {
|
||||
return wpi::units::meters_per_second_t{GetOutput(State::kRightVelocity)};
|
||||
return wpi::units::meters_per_second_t{GetOutput(State::RIGHT_VELOCITY)};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,7 +147,7 @@ class DifferentialDrivetrainSim {
|
||||
* @return The encoder position.
|
||||
*/
|
||||
wpi::units::meter_t GetLeftPosition() const {
|
||||
return wpi::units::meter_t{GetOutput(State::kLeftPosition)};
|
||||
return wpi::units::meter_t{GetOutput(State::LEFT_POSITION)};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -155,7 +155,7 @@ class DifferentialDrivetrainSim {
|
||||
* @return The encoder velocity.
|
||||
*/
|
||||
wpi::units::meters_per_second_t GetLeftVelocity() const {
|
||||
return wpi::units::meters_per_second_t{GetOutput(State::kLeftVelocity)};
|
||||
return wpi::units::meters_per_second_t{GetOutput(State::LEFT_VELOCITY)};
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,13 +199,13 @@ class DifferentialDrivetrainSim {
|
||||
|
||||
class State {
|
||||
public:
|
||||
static constexpr int kX = 0;
|
||||
static constexpr int kY = 1;
|
||||
static constexpr int kHeading = 2;
|
||||
static constexpr int kLeftVelocity = 3;
|
||||
static constexpr int kRightVelocity = 4;
|
||||
static constexpr int kLeftPosition = 5;
|
||||
static constexpr int kRightPosition = 6;
|
||||
static constexpr int X = 0;
|
||||
static constexpr int Y = 1;
|
||||
static constexpr int HEADING = 2;
|
||||
static constexpr int LEFT_VELOCITY = 3;
|
||||
static constexpr int RIGHT_VELOCITY = 4;
|
||||
static constexpr int LEFT_POSITION = 5;
|
||||
static constexpr int RIGHT_POSITION = 6;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -219,15 +219,15 @@ class DifferentialDrivetrainSim {
|
||||
class KitbotGearing {
|
||||
public:
|
||||
/// Gear ratio of 12.75:1.
|
||||
static constexpr double k12p75 = 12.75;
|
||||
static constexpr double RATIO_12P75 = 12.75;
|
||||
/// Gear ratio of 10.71:1.
|
||||
static constexpr double k10p71 = 10.71;
|
||||
static constexpr double RATIO_10P71 = 10.71;
|
||||
/// Gear ratio of 8.45:1.
|
||||
static constexpr double k8p45 = 8.45;
|
||||
static constexpr double RATIO_8P45 = 8.45;
|
||||
/// Gear ratio of 7.31:1.
|
||||
static constexpr double k7p31 = 7.31;
|
||||
static constexpr double RATIO_7P31 = 7.31;
|
||||
/// Gear ratio of 5.95:1.
|
||||
static constexpr double k5p95 = 5.95;
|
||||
static constexpr double RATIO_5P95 = 5.95;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -236,28 +236,28 @@ class DifferentialDrivetrainSim {
|
||||
class KitbotMotor {
|
||||
public:
|
||||
/// One CIM motor per drive side.
|
||||
static constexpr wpi::math::DCMotor SingleCIMPerSide =
|
||||
static constexpr wpi::math::DCMotor SINGLE_CIM_PER_SIDE =
|
||||
wpi::math::DCMotor::CIM(1);
|
||||
/// Two CIM motors per drive side.
|
||||
static constexpr wpi::math::DCMotor DualCIMPerSide =
|
||||
static constexpr wpi::math::DCMotor DUAL_CIM_PER_SIDE =
|
||||
wpi::math::DCMotor::CIM(2);
|
||||
/// One Mini CIM motor per drive side.
|
||||
static constexpr wpi::math::DCMotor SingleMiniCIMPerSide =
|
||||
static constexpr wpi::math::DCMotor SINGLE_MINI_CIM_PER_SIDE =
|
||||
wpi::math::DCMotor::MiniCIM(1);
|
||||
/// Two Mini CIM motors per drive side.
|
||||
static constexpr wpi::math::DCMotor DualMiniCIMPerSide =
|
||||
static constexpr wpi::math::DCMotor DUAL_MINI_CIM_PER_SIDE =
|
||||
wpi::math::DCMotor::MiniCIM(2);
|
||||
/// One Falcon 500 motor per drive side.
|
||||
static constexpr wpi::math::DCMotor SingleFalcon500PerSide =
|
||||
static constexpr wpi::math::DCMotor SINGLE_FALCON_500_PER_SIDE =
|
||||
wpi::math::DCMotor::Falcon500(1);
|
||||
/// Two Falcon 500 motors per drive side.
|
||||
static constexpr wpi::math::DCMotor DualFalcon500PerSide =
|
||||
static constexpr wpi::math::DCMotor DUAL_FALCON_500_PER_SIDE =
|
||||
wpi::math::DCMotor::Falcon500(2);
|
||||
/// One NEO motor per drive side.
|
||||
static constexpr wpi::math::DCMotor SingleNEOPerSide =
|
||||
static constexpr wpi::math::DCMotor SINGLE_NEO_PER_SIDE =
|
||||
wpi::math::DCMotor::NEO(1);
|
||||
/// Two NEO motors per drive side.
|
||||
static constexpr wpi::math::DCMotor DualNEOPerSide =
|
||||
static constexpr wpi::math::DCMotor DUAL_NEO_PER_SIDE =
|
||||
wpi::math::DCMotor::NEO(2);
|
||||
};
|
||||
|
||||
@@ -267,11 +267,11 @@ class DifferentialDrivetrainSim {
|
||||
class KitbotWheelSize {
|
||||
public:
|
||||
/// Six inch diameter wheels.
|
||||
static constexpr wpi::units::meter_t kSixInch = 6_in;
|
||||
static constexpr wpi::units::meter_t SIX_INCH = 6_in;
|
||||
/// Eight inch diameter wheels.
|
||||
static constexpr wpi::units::meter_t kEightInch = 8_in;
|
||||
static constexpr wpi::units::meter_t EIGHT_INCH = 8_in;
|
||||
/// Ten inch diameter wheels.
|
||||
static constexpr wpi::units::meter_t kTenInch = 10_in;
|
||||
static constexpr wpi::units::meter_t TEN_INCH = 10_in;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user