From 77f3b60b6f8cb49721000b1a99a13519796b8bf9 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 8 Aug 2012 11:25:48 +1000 Subject: [PATCH] Filter: make the DerivativeFilter test GNUPlot friendly makes testing easier --- .../Filter/examples/Derivative/Derivative.pde | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/libraries/Filter/examples/Derivative/Derivative.pde b/libraries/Filter/examples/Derivative/Derivative.pde index 4f4ee2cfcb..d108a68ebc 100644 --- a/libraries/Filter/examples/Derivative/Derivative.pde +++ b/libraries/Filter/examples/Derivative/Derivative.pde @@ -35,16 +35,13 @@ mavlink_system_t mavlink_system; FastSerialPort0(Serial); // FTDI/console -DerivativeFilter derivative; +DerivativeFilter derivative; // setup routine void setup() { // Open up a serial connection Serial.begin(115200); - - // introduction - Serial.printf("ArduPilot DerivativeFilter test\n"); } static float noise(void) @@ -58,12 +55,10 @@ void loop() delay(50); float t = millis()*1.0e-3; float s = sin(t); - s += noise(); + //s += noise(); uint32_t t1 = micros(); - float output = derivative.apply(s, t1) * 1.0e6; + derivative.update(s, t1); + float output = derivative.slope() * 1.0e6; uint32_t t2 = micros(); - Serial.printf("cos(t)=%.2f filter=%.2f tdiff=%u\n", - cos(t), output, t2-t1); + Serial.printf("%f %f %f %f\n", t, output, s, cos(t)); } - -