mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpimath] Fix drivetrain system identification (#3406)
The units for angular Kv and Ka were inconsistent with the derivation. A second factory function overload was added for angular units that uses a trackwidth to convert to the other form. Notice how section 15.2 of https://file.tavsys.net/control/controls-engineering-in-frc.pdf defines the angular feedforward as u = Kv,angular v instead of u = Kv,angular + omega. The units cancel for elements of A but not B, so just the B matrix was incorrect in our code. This breaks existing C++ code since the units are part of the function signature.
This commit is contained in:
@@ -98,8 +98,7 @@ class Drivetrain {
|
||||
frc::Field2d m_fieldSim;
|
||||
frc::LinearSystem<2, 2, 2> m_drivetrainSystem =
|
||||
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);
|
||||
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};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user