Hummingbird Flight Software
Flight software for the Hummingbird FCU quadcopter flight controller. Designed to run on the Teensy 4.1. Developed with VSCode+PlatformIO.
low_pass_filter.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // DISCRETE LOW PASS FILTER IMPLEMENTATION
3 //
4 // Code By: Michael Wrona
5 // Created: 3 Feb 2021
6 // ----------------------------------------------------------------------------
13 #pragma once
14 
15 #include <Arduino.h>
16 #include "constants.h"
17 #include "maths/math_functs.h"
18 #include "hummingbird_config.h"
19 
20 
21 // ------------------------------------
22 // Low Pass Filter Class
23 // ------------------------------------
25 {
26 public:
27  LowPassFilter();
29  void SetSmoothingFactor(float newSF = 1.0f);
30  float Filter(float rawPoint);
31  float dt;
32 protected:
33 private:
34  bool _setsf; // Set smoothing factor?
35  float _outPoint; // Previously filtered point
36  float _a; // Filter smoothing factor, [0, 1]
37 };
This is a simple implementation of a discrete low pass filter to filter noisy signals.
Definition: low_pass_filter.h:25
~LowPassFilter()
Definition: low_pass_filter.cpp:76
float _a
Definition: low_pass_filter.h:36
float _outPoint
Definition: low_pass_filter.h:35
LowPassFilter()
This is a simple implementation of a discrete low pass filter to filter noisy signals.
Definition: low_pass_filter.cpp:29
float Filter(float rawPoint)
Apply the LFP (defined by the smoothing factor) to a new point and output the filtered value.
Definition: low_pass_filter.cpp:62
void SetSmoothingFactor(float newSF=1.0f)
Set the filter's smoothing factor (alpha) between [0, 1].
Definition: low_pass_filter.cpp:45
bool _setsf
Definition: low_pass_filter.h:34
float dt
Definition: low_pass_filter.h:31