mirror of https://github.com/ArduPilot/ardupilot
uncrustify libraries/Filter/DerivativeFilter.h
This commit is contained in:
parent
973dcba9ab
commit
6bfccd13f8
|
@ -17,31 +17,32 @@
|
||||||
#include <Filter.h>
|
#include <Filter.h>
|
||||||
#include <FilterWithBuffer.h>
|
#include <FilterWithBuffer.h>
|
||||||
|
|
||||||
// 1st parameter <T> is the type of data being filtered.
|
// 1st parameter <T> is the type of data being filtered.
|
||||||
// 2nd parameter <FILTER_SIZE> is the number of elements in the filter
|
// 2nd parameter <FILTER_SIZE> is the number of elements in the filter
|
||||||
template <class T, uint8_t FILTER_SIZE>
|
template <class T, uint8_t FILTER_SIZE>
|
||||||
class DerivativeFilter : public FilterWithBuffer<T,FILTER_SIZE>
|
class DerivativeFilter : public FilterWithBuffer<T,FILTER_SIZE>
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
// constructor
|
// constructor
|
||||||
DerivativeFilter() : FilterWithBuffer<T,FILTER_SIZE>() {};
|
DerivativeFilter() : FilterWithBuffer<T,FILTER_SIZE>() {
|
||||||
|
};
|
||||||
|
|
||||||
// update - Add a new raw value to the filter, but don't recalculate
|
// update - Add a new raw value to the filter, but don't recalculate
|
||||||
virtual void update(T sample, uint32_t timestamp);
|
virtual void update(T sample, uint32_t timestamp);
|
||||||
|
|
||||||
// return the derivative value
|
// return the derivative value
|
||||||
virtual float slope(void);
|
virtual float slope(void);
|
||||||
|
|
||||||
// reset - clear the filter
|
// reset - clear the filter
|
||||||
virtual void reset();
|
virtual void reset();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool _new_data;
|
bool _new_data;
|
||||||
float _last_slope;
|
float _last_slope;
|
||||||
|
|
||||||
// microsecond timestamps for samples. This is needed
|
// microsecond timestamps for samples. This is needed
|
||||||
// to cope with non-uniform time spacing of the data
|
// to cope with non-uniform time spacing of the data
|
||||||
uint32_t _timestamps[FILTER_SIZE];
|
uint32_t _timestamps[FILTER_SIZE];
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef DerivativeFilter<float,5> DerivativeFilterFloat_Size5;
|
typedef DerivativeFilter<float,5> DerivativeFilterFloat_Size5;
|
||||||
|
|
Loading…
Reference in New Issue