mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[wpimath] Remove LinearSystem from LinearSystemLoop (#2968)
The system wasn't being used internally, and as LinearSystem is stateless, it doesn't need to be held by LinearSystemLoop.
This commit is contained in:
@@ -18,7 +18,7 @@ import edu.wpi.first.wpiutil.math.Num;
|
||||
import edu.wpi.first.wpiutil.math.numbers.N1;
|
||||
|
||||
/**
|
||||
* Combines a plant, controller, and observer for controlling a mechanism with
|
||||
* Combines a controller, feedforward, and observer for controlling a mechanism with
|
||||
* full state feedback.
|
||||
*
|
||||
* <p>For everything in this file, "inputs" and "outputs" are defined from the
|
||||
@@ -35,7 +35,6 @@ import edu.wpi.first.wpiutil.math.numbers.N1;
|
||||
public class LinearSystemLoop<States extends Num, Inputs extends Num,
|
||||
Outputs extends Num> {
|
||||
|
||||
private final LinearSystem<States, Inputs, Outputs> m_plant;
|
||||
private final LinearQuadraticRegulator<States, Inputs, Outputs> m_controller;
|
||||
private final LinearPlantInversionFeedforward<States, Inputs, Outputs> m_feedforward;
|
||||
private final KalmanFilter<States, Inputs, Outputs> m_observer;
|
||||
@@ -59,7 +58,7 @@ public class LinearSystemLoop<States extends Num, Inputs extends Num,
|
||||
KalmanFilter<States, Inputs, Outputs> observer,
|
||||
double maxVoltageVolts,
|
||||
double dtSeconds) {
|
||||
this(plant, controller,
|
||||
this(controller,
|
||||
new LinearPlantInversionFeedforward<>(plant, dtSeconds), observer,
|
||||
u -> StateSpaceUtil.normalizeInputVector(u, maxVoltageVolts));
|
||||
}
|
||||
@@ -80,49 +79,44 @@ public class LinearSystemLoop<States extends Num, Inputs extends Num,
|
||||
KalmanFilter<States, Inputs, Outputs> observer,
|
||||
Function<Matrix<Inputs, N1>, Matrix<Inputs, N1>> clampFunction,
|
||||
double dtSeconds) {
|
||||
this(plant, controller, new LinearPlantInversionFeedforward<>(plant, dtSeconds),
|
||||
this(controller, new LinearPlantInversionFeedforward<>(plant, dtSeconds),
|
||||
observer, clampFunction);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a state-space loop with the given plant, controller, and
|
||||
* Constructs a state-space loop with the given controller, feedforward and
|
||||
* observer. By default, the initial reference is all zeros. Users should
|
||||
* call reset with the initial system state before enabling the loop.
|
||||
*
|
||||
* @param plant State-space plant.
|
||||
* @param controller State-space controller.
|
||||
* @param feedforward Plant inversion feedforward.
|
||||
* @param observer State-space observer.
|
||||
* @param maxVoltageVolts The maximum voltage that can be applied. Assumes that the
|
||||
* inputs are voltages.
|
||||
*/
|
||||
public LinearSystemLoop(LinearSystem<States, Inputs, Outputs> plant,
|
||||
LinearQuadraticRegulator<States, Inputs, Outputs> controller,
|
||||
public LinearSystemLoop(LinearQuadraticRegulator<States, Inputs, Outputs> controller,
|
||||
LinearPlantInversionFeedforward<States, Inputs, Outputs> feedforward,
|
||||
KalmanFilter<States, Inputs, Outputs> observer,
|
||||
double maxVoltageVolts
|
||||
) {
|
||||
this(plant, controller, feedforward,
|
||||
this(controller, feedforward,
|
||||
observer, u -> StateSpaceUtil.normalizeInputVector(u, maxVoltageVolts));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a state-space loop with the given plant, controller, and
|
||||
* Constructs a state-space loop with the given controller, feedforward, and
|
||||
* observer. By default, the initial reference is all zeros. Users should
|
||||
* call reset with the initial system state before enabling the loop.
|
||||
*
|
||||
* @param plant State-space plant.
|
||||
* @param controller State-space controller.
|
||||
* @param feedforward Plant inversion feedforward.
|
||||
* @param observer State-space observer.
|
||||
* @param clampFunction The function used to clamp the input U.
|
||||
*/
|
||||
public LinearSystemLoop(LinearSystem<States, Inputs, Outputs> plant,
|
||||
LinearQuadraticRegulator<States, Inputs, Outputs> controller,
|
||||
public LinearSystemLoop(LinearQuadraticRegulator<States, Inputs, Outputs> controller,
|
||||
LinearPlantInversionFeedforward<States, Inputs, Outputs> feedforward,
|
||||
KalmanFilter<States, Inputs, Outputs> observer,
|
||||
Function<Matrix<Inputs, N1>, Matrix<Inputs, N1>> clampFunction) {
|
||||
this.m_plant = plant;
|
||||
this.m_controller = controller;
|
||||
this.m_feedforward = feedforward;
|
||||
this.m_observer = observer;
|
||||
@@ -232,15 +226,6 @@ public class LinearSystemLoop<States extends Num, Inputs extends Num,
|
||||
return getU().get(row, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the plant used internally.
|
||||
*
|
||||
* @return the plant used internally.
|
||||
*/
|
||||
public LinearSystem<States, Inputs, Outputs> getPlant() {
|
||||
return m_plant;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the controller used internally.
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user