@Override public void update() { update(unfilteredVariable.getDoubleValue()); }
@Override public void update() { update(unfilteredVariable.getDoubleValue()); }
@ContinuousIntegrationTest(estimatedDuration = 0.0) @Test(timeout=60000) public void testNoisyFixedPosition() { // Use a reasonably large alpha for a reasonably large amount of noise YoVariableRegistry registry = new YoVariableRegistry("testRegistry"); YoDouble alpha = new YoDouble("alpha", registry); alpha.set(0.8); YoDouble positionVariable = new YoDouble("positionVariable", registry); AlphaFilteredWrappingYoVariable alphaFilteredWrappingYoVariable = new AlphaFilteredWrappingYoVariable("alphaFilteredWrappingYoVariable", "", registry, positionVariable, alpha, 0.0, 20.0); double pseudoNoise = 0; positionVariable.set(10.0); for (int i = 0; i < 10000; i++) { // Oscillate the position about some uniformly distributed fixed point slightly larger than 10 if (i % 2 == 0) { pseudoNoise = random.nextDouble(); } positionVariable.add(Math.pow(-1, i) * pseudoNoise); alphaFilteredWrappingYoVariable.update(); } assertEquals(10.0, alphaFilteredWrappingYoVariable.getDoubleValue(), 1.0); }
alphaFilteredWrappingYoVariable.update(); assertTrue(MathTools.epsilonEquals(alphaFilteredWrappingYoVariable.getDoubleValue(), -2.0, 1e-10)); alphaFilteredWrappingYoVariable.update(); assertTrue(MathTools.epsilonEquals(alphaFilteredWrappingYoVariable.getDoubleValue(), -2.0, 1e-10)); alphaFilteredWrappingYoVariable.update(); assertTrue(MathTools.epsilonEquals(alphaFilteredWrappingYoVariable.getDoubleValue(), 3.0, 1e-10)); alphaFilteredWrappingYoVariable.update(); assertTrue(MathTools.epsilonEquals(alphaFilteredWrappingYoVariable.getDoubleValue(), -2.0, 1e-10)); alphaFilteredWrappingYoVariable.update(); assertTrue(MathTools.epsilonEquals(alphaFilteredWrappingYoVariable.getDoubleValue(), 2.0, 1e-10)); alphaFilteredWrappingYoVariable.update(); assertTrue(MathTools.epsilonEquals(alphaFilteredWrappingYoVariable.getDoubleValue(), -2.0, 1e-10)); alphaFilteredWrappingYoVariable.update(); assertTrue(MathTools.epsilonEquals(alphaFilteredWrappingYoVariable.getDoubleValue(), 6.5, 1e-10)); alphaFilteredWrappingYoVariable.update(); assertTrue(MathTools.epsilonEquals(alphaFilteredWrappingYoVariable.getDoubleValue(), -2.0, 1e-10));
alphaFilteredWrappingYoVariable.update(); for (int convergeAlphaCount = 0; convergeAlphaCount < 100; convergeAlphaCount++) alphaFilteredWrappingYoVariable.update(); double currentError = getErrorConsideringWrap(alphaFilteredWrappingYoVariable.getDoubleValue(), positionVariable.getDoubleValue(),lowerLimit, upperLimit); assertTrue(Math.abs(currentError) < Math.abs(lastError));