mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
Remove sendables from SendableRegistry when close() is called (#1917)
This only affected Java (C++ RAII doesn't have the same problem). Needed to add close/AutoCloseable to several classes to add this behavior.
This commit is contained in:
@@ -28,7 +28,7 @@ import static edu.wpi.first.wpilibj.util.ErrorMessages.requireNonNullParam;
|
||||
* given set of PID constants.
|
||||
*/
|
||||
@SuppressWarnings("PMD.TooManyFields")
|
||||
public class PIDBase implements PIDInterface, PIDOutput, Sendable {
|
||||
public class PIDBase implements PIDInterface, PIDOutput, Sendable, AutoCloseable {
|
||||
public static final double kDefaultPeriod = 0.05;
|
||||
private static int instances;
|
||||
|
||||
@@ -191,6 +191,11 @@ public class PIDBase implements PIDInterface, PIDOutput, Sendable {
|
||||
this(Kp, Ki, Kd, 0.0, source, output);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() {
|
||||
SendableRegistry.remove(this);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the input, calculate the output accordingly, and write to the output. This should only be
|
||||
* called by the PIDTask and is created during initialization.
|
||||
|
||||
Reference in New Issue
Block a user