[wpimath] Remove rho overload from LinearQuadraticRegulator constructors (#2687)

It was added as part of Bryson's rule described in
https://file.tavsys.net/control/controls-engineering-in-frc.pdf. It
doesn't really simplify usage though, and the same thing can be
replicated by multiplying the elements of Q by rho manually. It's easier
to do it that way, it's how 3512 has been doing controller debugging for
a while, and it's probably what other teams will do as well instead of
using the "more structured" way.

Removing these unhelpful overloads also simplifies the LQR interface.
This commit is contained in:
Tyler Veness
2020-09-03 20:53:17 -07:00
committed by GitHub
parent 8edc17dac9
commit 35790a8990
10 changed files with 16 additions and 216 deletions

View File

@@ -61,28 +61,8 @@ public class LinearQuadraticRegulator<States extends Num, Inputs extends Num,
Vector<Inputs> relms,
double dtSeconds
) {
this(plant.getA(), plant.getB(), qelms, 1.0, relms, dtSeconds);
}
/**
* Constructs a controller with the given coefficients and plant.
*
* @param plant The plant being controlled.
* @param qelms The maximum desired error tolerance for each state.
* @param rho A weighting factor that balances control effort and state excursion.
* Greater values penalize state excursion more heavily. 1 is a good starting
* value.
* @param relms The maximum desired control effort for each input.
* @param dtSeconds Discretization timestep.
*/
public LinearQuadraticRegulator(
LinearSystem<States, Inputs, Outputs> plant,
Vector<States> qelms,
double rho,
Vector<Inputs> relms,
double dtSeconds
) {
this(plant.getA(), plant.getB(), qelms, rho, relms, dtSeconds);
this(plant.getA(), plant.getB(), StateSpaceUtil.makeCostMatrix(qelms),
StateSpaceUtil.makeCostMatrix(relms), dtSeconds);
}
/**
@@ -99,28 +79,8 @@ public class LinearQuadraticRegulator<States extends Num, Inputs extends Num,
Vector<States> qelms, Vector<Inputs> relms,
double dtSeconds
) {
this(A, B, qelms, 1.0, relms, dtSeconds);
}
/**
* Constructs a controller with the given coefficients and plant.
*
* @param A Continuous system matrix of the plant being controlled.
* @param B Continuous input matrix of the plant being controlled.
* @param qelms The maximum desired error tolerance for each state.
* @param rho A weighting factor that balances control effort and state excursion.
* Greater
* values penalize state excursion more heavily. 1 is a good starting value.
* @param relms The maximum desired control effort for each input.
* @param dtSeconds Discretization timestep.
*/
@SuppressWarnings({"ParameterName", "LocalVariableName"})
public LinearQuadraticRegulator(Matrix<States, States> A, Matrix<States, Inputs> B,
Vector<States> qelms, double rho, Vector<Inputs> relms,
double dtSeconds
) {
this(A, B, StateSpaceUtil.makeCostMatrix(qelms).times(rho),
StateSpaceUtil.makeCostMatrix(relms), dtSeconds);
this(A, B, StateSpaceUtil.makeCostMatrix(qelms), StateSpaceUtil.makeCostMatrix(relms),
dtSeconds);
}
/**