mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpimath] Use units for LinearSystemId Kv and Ka (#2852)
This commit is contained in:
committed by
GitHub
parent
f24f282442
commit
ac3c336b98
@@ -91,7 +91,9 @@ class Drivetrain {
|
||||
frc::sim::EncoderSim m_rightEncoderSim{m_rightEncoder};
|
||||
frc::Field2d m_fieldSim{};
|
||||
frc::LinearSystem<2, 2, 2> m_drivetrainSystem =
|
||||
frc::LinearSystemId::IdentifyDrivetrainSystem(1.98, 0.2, 1.5, 0.3);
|
||||
frc::LinearSystemId::IdentifyDrivetrainSystem(
|
||||
1.98_V / 1_mps, 0.2_V / 1_mps_sq, 1.5_V / 1_rad_per_s,
|
||||
0.3_V / 1_rad_per_s_sq);
|
||||
frc::sim::DifferentialDrivetrainSim m_drivetrainSimulator{
|
||||
m_drivetrainSystem, kTrackWidth, frc::DCMotor::CIM(2), 8, 2_in};
|
||||
};
|
||||
|
||||
@@ -33,10 +33,10 @@ class Robot : public frc::TimedRobot {
|
||||
static constexpr units::radians_per_second_t kSpinup = 500_rpm;
|
||||
|
||||
// Volts per (radian per second)
|
||||
static constexpr double kFlywheelKv = 0.023;
|
||||
static constexpr auto kFlywheelKv = 0.023_V / 1_rad_per_s;
|
||||
|
||||
// Volts per (radian per second squared)
|
||||
static constexpr double kFlywheelKa = 0.001;
|
||||
static constexpr auto kFlywheelKa = 0.001_V / 1_rad_per_s_sq;
|
||||
|
||||
// The plant holds a state-space model of our flywheel. This system has the
|
||||
// following properties:
|
||||
@@ -47,7 +47,8 @@ class Robot : public frc::TimedRobot {
|
||||
//
|
||||
// The Kv and Ka constants are found using the FRC Characterization toolsuite.
|
||||
frc::LinearSystem<1, 1, 1> m_flywheelPlant =
|
||||
frc::LinearSystemId::IdentifyVelocitySystem(kFlywheelKv, kFlywheelKa);
|
||||
frc::LinearSystemId::IdentifyVelocitySystem<units::radian>(kFlywheelKv,
|
||||
kFlywheelKa);
|
||||
|
||||
// The observer fuses our encoder data and voltage inputs to reject noise.
|
||||
frc::KalmanFilter<1, 1, 1> m_observer{
|
||||
|
||||
Reference in New Issue
Block a user