mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
PIDController now supports composition (#976)
For example, an outer position feedback controller can now drive the reference of an inner velocity feedback controller.
This commit is contained in:
committed by
Peter Johnson
parent
5cc7573574
commit
df182f382e
@@ -25,7 +25,7 @@ import static java.util.Objects.requireNonNull;
|
||||
* and derivative calculations. Therefore, the sample rate affects the controller's behavior for a
|
||||
* given set of PID constants.
|
||||
*/
|
||||
public class PIDBase extends SendableBase implements PIDInterface {
|
||||
public class PIDBase extends SendableBase implements PIDInterface, PIDOutput {
|
||||
public static final double kDefaultPeriod = 0.05;
|
||||
private static int instances = 0;
|
||||
|
||||
@@ -765,6 +765,20 @@ public class PIDBase extends SendableBase implements PIDInterface {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Passes the output directly to setSetpoint().
|
||||
*
|
||||
* <p>PIDControllers can be nested by passing a PIDController as another PIDController's output.
|
||||
* In that case, the output of the parent controller becomes the input (i.e., the reference) of
|
||||
* the child.
|
||||
*
|
||||
* <p>It is the caller's responsibility to put the data into a valid form for setSetpoint().
|
||||
*/
|
||||
@Override
|
||||
public void pidWrite(double output) {
|
||||
setSetpoint(output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void initSendable(SendableBuilder builder) {
|
||||
builder.setSmartDashboardType("PIDController");
|
||||
|
||||
Reference in New Issue
Block a user