Deprecated internal filter of PID controller (#746)

This was replaced with an external LinearDigitalFilter.
This commit is contained in:
Tyler Veness
2017-12-04 20:05:02 -08:00
committed by Peter Johnson
parent b428d1e4b3
commit 59c4984ed6
5 changed files with 17 additions and 6 deletions

View File

@@ -8,7 +8,7 @@ def windowsLinkerArgs = [ '/DEBUG:FULL' ]
def windowsReleaseLinkerArgs = [ '/OPT:REF', '/OPT:ICF' ]
def linuxCompilerArgs = ['-std=c++1y', '-Wformat=2', '-Wall', '-Wextra', '-Werror', '-pedantic', '-Wno-psabi', '-g',
'-Wno-unused-parameter', '-fPIC', '-rdynamic', '-pthread']
'-Wno-unused-parameter', '-Wno-error=deprecated-declarations', '-fPIC', '-rdynamic', '-pthread']
def linuxLinkerArgs = ['-rdynamic', '-pthread']
def linuxReleaseCompilerArgs = ['-O2']
def linuxDebugCompilerArgs = ['-O0']

View File

@@ -69,7 +69,7 @@ class PIDController : public LiveWindowSendable, public PIDInterface {
virtual double GetError() const;
WPI_DEPRECATED("Use GetError() instead, which is now already filtered.")
WPI_DEPRECATED("Use a LinearDigitalFilter as the input and GetError().")
virtual double GetAvgError() const;
virtual void SetPIDSourceType(PIDSourceType pidSource);
@@ -79,7 +79,10 @@ class PIDController : public LiveWindowSendable, public PIDInterface {
virtual void SetTolerance(double percent);
virtual void SetAbsoluteTolerance(double absValue);
virtual void SetPercentTolerance(double percentValue);
WPI_DEPRECATED("Use a LinearDigitalFilter as the input.")
virtual void SetToleranceBuffer(int buf = 1);
virtual bool OnTarget() const;
void Enable() override;

View File

@@ -6,6 +6,7 @@
/*----------------------------------------------------------------------------*/
#include "Encoder.h"
#include "Filters/LinearDigitalFilter.h"
#include "Jaguar.h"
#include "PIDController.h"
#include "Talon.h"
@@ -44,6 +45,7 @@ class MotorEncoderTest : public testing::TestWithParam<MotorEncoderTestType> {
protected:
SpeedController* m_speedController;
Encoder* m_encoder;
LinearDigitalFilter* m_filter;
void SetUp() override {
switch (GetParam()) {
@@ -65,16 +67,20 @@ class MotorEncoderTest : public testing::TestWithParam<MotorEncoderTestType> {
TestBench::kTalonEncoderChannelB);
break;
}
m_filter = new LinearDigitalFilter(LinearDigitalFilter::MovingAverage(
std::shared_ptr<PIDSource>(m_encoder, NullDeleter<PIDSource>()), 50));
}
void TearDown() override {
delete m_speedController;
delete m_encoder;
delete m_filter;
}
void Reset() {
m_speedController->Set(0.0);
m_encoder->Reset();
m_filter->Reset();
}
};
@@ -158,9 +164,8 @@ TEST_P(MotorEncoderTest, VelocityPIDController) {
Reset();
m_encoder->SetPIDSourceType(PIDSourceType::kRate);
PIDController pid(1e-5, 0.0, 3e-5, 8e-5, m_encoder, m_speedController);
PIDController pid(1e-5, 0.0, 3e-5, 8e-5, m_filter, m_speedController);
pid.SetAbsoluteTolerance(200.0);
pid.SetToleranceBuffer(50);
pid.SetOutputRange(-0.3, 0.3);
pid.SetSetpoint(600);

View File

@@ -589,8 +589,10 @@ public class PIDController implements PIDInterface, LiveWindowSendable, Controll
* erroneous measurements when the mechanism is on target. However, the mechanism will not
* register as on target for at least the specified bufLength cycles.
*
* @deprecated Use a LinearDigitalFilter as the input.
* @param bufLength Number of previous cycles to average.
*/
@Deprecated
public synchronized void setToleranceBuffer(int bufLength) {
m_filter = LinearDigitalFilter.movingAverage(m_origSource, bufLength);
m_pidInput = m_filter;

View File

@@ -19,6 +19,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.logging.Logger;
import edu.wpi.first.wpilibj.filters.LinearDigitalFilter;
import edu.wpi.first.wpilibj.fixtures.MotorEncoderFixture;
import edu.wpi.first.wpilibj.test.AbstractComsSetup;
import edu.wpi.first.wpilibj.test.TestBench;
@@ -194,10 +195,10 @@ public class MotorEncoderTest extends AbstractComsSetup {
@Test
public void testVelocityPIDController() {
me.getEncoder().setPIDSourceType(PIDSourceType.kRate);
LinearDigitalFilter filter = LinearDigitalFilter.movingAverage(me.getEncoder(), 50);
PIDController pid =
new PIDController(1e-5, 0.0, 3e-5, 8e-5, me.getEncoder(), me.getMotor());
new PIDController(1e-5, 0.0, 3e-5, 8e-5, filter, me.getMotor());
pid.setAbsoluteTolerance(200);
pid.setToleranceBuffer(50);
pid.setOutputRange(-0.3, 0.3);
pid.setSetpoint(600);