45 DCMotor driveMotor,
double gearingRatio, units::meter_t wheelRadius,
46 const std::array<double, 7>& measurementStdDevs = {});
71 frc::DCMotor driveMotor,
double gearing, units::kilogram_square_meter_t J,
72 units::kilogram_t mass, units::meter_t wheelRadius,
73 units::meter_t trackWidth,
74 const std::array<double, 7>& measurementStdDevs = {});
92 void SetInputs(units::volt_t leftVoltage, units::volt_t rightVoltage);
194 static constexpr int kX = 0;
195 static constexpr int kY = 1;
215 static constexpr double k8p45 = 8.45;
216 static constexpr double k7p31 = 7.31;
217 static constexpr double k5p95 = 5.95;
256 frc::DCMotor motor,
double gearing, units::meter_t wheelSize,
257 const std::array<double, 7>& measurementStdDevs = {}) {
259 units::kilogram_square_meter_t batteryMoi = 12.5_lb * 10_in * 10_in;
260 units::kilogram_square_meter_t gearboxMoi = (2.8_lb + 2.0_lb) *
262 * (26_in / 2) * (26_in / 2);
265 motor, gearing, batteryMoi + gearboxMoi, 60_lb,
266 wheelSize / 2.0, 26_in, measurementStdDevs};
285 frc::DCMotor motor,
double gearing, units::meter_t wheelSize,
286 units::kilogram_square_meter_t J,
287 const std::array<double, 7>& measurementStdDevs = {}) {
289 motor, gearing, J, 60_lb, wheelSize / 2.0, 26_in, measurementStdDevs};
298 double GetOutput(
int output)
const;
303 Vectord<7> GetOutput()
const;
311 double GetState(
int state)
const;
316 Vectord<7> GetState()
const;
318 LinearSystem<2, 2, 2> m_plant;
320 units::meter_t m_wheelRadius;
324 double m_originalGearing;
325 double m_currentGearing;
330 std::array<double, 7> m_measurementStdDevs;
Holds the constants for a DC motor.
Definition: DCMotor.h:20
static constexpr DCMotor Falcon500(int numMotors=1)
Returns instance of Falcon 500 brushless motor.
Definition: DCMotor.h:194
static constexpr DCMotor CIM(int numMotors=1)
Returns instance of CIM.
Definition: DCMotor.h:124
static constexpr DCMotor NEO(int numMotors=1)
Returns instance of NEO brushless motor.
Definition: DCMotor.h:180
static constexpr DCMotor MiniCIM(int numMotors=1)
Returns instance of MiniCIM.
Definition: DCMotor.h:131
Represents a 2D pose containing translational and rotational elements.
Definition: Pose2d.h:25
A rotation in a 2D coordinate frame represented by a point on the unit circle (cosine and sine).
Definition: Rotation2d.h:26
Represents a gearing option of the Toughbox mini.
Definition: DifferentialDrivetrainSim.h:211
static constexpr double k10p71
Definition: DifferentialDrivetrainSim.h:214
static constexpr double k5p95
Definition: DifferentialDrivetrainSim.h:217
static constexpr double k8p45
Definition: DifferentialDrivetrainSim.h:215
static constexpr double k7p31
Definition: DifferentialDrivetrainSim.h:216
static constexpr double k12p75
Definition: DifferentialDrivetrainSim.h:213
Definition: DifferentialDrivetrainSim.h:220
static constexpr frc::DCMotor DualNEOPerSide
Definition: DifferentialDrivetrainSim.h:232
static constexpr frc::DCMotor DualFalcon500PerSide
Definition: DifferentialDrivetrainSim.h:229
static constexpr frc::DCMotor SingleNEOPerSide
Definition: DifferentialDrivetrainSim.h:231
static constexpr frc::DCMotor SingleMiniCIMPerSide
Definition: DifferentialDrivetrainSim.h:224
static constexpr frc::DCMotor SingleCIMPerSide
Definition: DifferentialDrivetrainSim.h:222
static constexpr frc::DCMotor DualCIMPerSide
Definition: DifferentialDrivetrainSim.h:223
static constexpr frc::DCMotor DualMiniCIMPerSide
Definition: DifferentialDrivetrainSim.h:226
static constexpr frc::DCMotor SingleFalcon500PerSide
Definition: DifferentialDrivetrainSim.h:227
Definition: DifferentialDrivetrainSim.h:235
static constexpr units::meter_t kTenInch
Definition: DifferentialDrivetrainSim.h:239
static constexpr units::meter_t kSixInch
Definition: DifferentialDrivetrainSim.h:237
static constexpr units::meter_t kEightInch
Definition: DifferentialDrivetrainSim.h:238
Definition: DifferentialDrivetrainSim.h:192
static constexpr int kLeftVelocity
Definition: DifferentialDrivetrainSim.h:197
static constexpr int kX
Definition: DifferentialDrivetrainSim.h:194
static constexpr int kY
Definition: DifferentialDrivetrainSim.h:195
static constexpr int kLeftPosition
Definition: DifferentialDrivetrainSim.h:199
static constexpr int kHeading
Definition: DifferentialDrivetrainSim.h:196
static constexpr int kRightPosition
Definition: DifferentialDrivetrainSim.h:200
static constexpr int kRightVelocity
Definition: DifferentialDrivetrainSim.h:198
Definition: DifferentialDrivetrainSim.h:19
units::ampere_t GetCurrentDraw() const
Returns the currently drawn current.
DifferentialDrivetrainSim(frc::DCMotor driveMotor, double gearing, units::kilogram_square_meter_t J, units::kilogram_t mass, units::meter_t wheelRadius, units::meter_t trackWidth, const std::array< double, 7 > &measurementStdDevs={})
Create a SimDrivetrain.
void Update(units::second_t dt)
Updates the simulation.
units::meter_t GetRightPosition() const
Get the right encoder position in meters.
Definition: DifferentialDrivetrainSim.h:133
void SetGearing(double newGearing)
Sets the gearing reduction on the drivetrain.
Pose2d GetPose() const
Returns the current pose.
units::meter_t GetLeftPosition() const
Get the left encoder position in meters.
Definition: DifferentialDrivetrainSim.h:149
static DifferentialDrivetrainSim CreateKitbotSim(frc::DCMotor motor, double gearing, units::meter_t wheelSize, const std::array< double, 7 > &measurementStdDevs={})
Create a sim for the standard FRC kitbot.
Definition: DifferentialDrivetrainSim.h:255
units::meters_per_second_t GetLeftVelocity() const
Get the left encoder velocity in meters per second.
Definition: DifferentialDrivetrainSim.h:157
units::ampere_t GetLeftCurrentDraw() const
Returns the currently drawn current for the left side.
void SetState(const Vectord< 7 > &state)
Sets the system state.
units::meters_per_second_t GetRightVelocity() const
Get the right encoder velocity in meters per second.
Definition: DifferentialDrivetrainSim.h:141
void SetPose(const frc::Pose2d &pose)
Sets the system pose.
units::ampere_t GetRightCurrentDraw() const
Returns the currently drawn current for the right side.
Vectord< 2 > ClampInput(const Vectord< 2 > &u)
Clamp the input vector such that no element exceeds the battery voltage.
double GetGearing() const
Returns the current gearing reduction of the drivetrain, as output over input.
void SetInputs(units::volt_t leftVoltage, units::volt_t rightVoltage)
Sets the applied voltage to the drivetrain.
Vectord< 7 > Dynamics(const Vectord< 7 > &x, const Vectord< 2 > &u)
static DifferentialDrivetrainSim CreateKitbotSim(frc::DCMotor motor, double gearing, units::meter_t wheelSize, units::kilogram_square_meter_t J, const std::array< double, 7 > &measurementStdDevs={})
Create a sim for the standard FRC kitbot.
Definition: DifferentialDrivetrainSim.h:284
DifferentialDrivetrainSim(LinearSystem< 2, 2, 2 > plant, units::meter_t trackWidth, DCMotor driveMotor, double gearingRatio, units::meter_t wheelRadius, const std::array< double, 7 > &measurementStdDevs={})
Create a SimDrivetrain.
Rotation2d GetHeading() const
Returns the direction the robot is pointing.
Definition: AnalogOutputSim.h:15
Eigen::Vector< double, Size > Vectord
Definition: EigenCore.h:12