[wpilib] Clamp input voltage in sim classes (#2955)

This commit is contained in:
Matt
2020-12-28 13:03:31 -08:00
committed by GitHub
parent dd494d4ab7
commit 9005cd59e5
5 changed files with 66 additions and 4 deletions

View File

@@ -72,6 +72,16 @@ class DifferentialDrivetrainSim {
units::meter_t trackWidth,
const std::array<double, 7>& measurementStdDevs = {});
/**
* Clamp the input vector such that no element exceeds the given voltage. If
* any does, the relative magnitudes of the input will be maintained.
*
* @param u The input vector.
* @param maxVoltage The maximum voltage.
* @return The normalized input.
*/
Eigen::Matrix<double, 2, 1> ClampInput(Eigen::Matrix<double, 2, 1> u);
/**
* Sets the applied voltage to the drivetrain. Note that positive voltage must
* make that side of the drivetrain travel forward (+X).