Commit Graph

133 Commits

Author SHA1 Message Date
Andrew Tridgell bd07e8516f Filter: use GCS_SEND_TEXT() 2020-04-29 07:36:55 +10:00
Andy Piper 8407648316 Filter: make sure the center frequency can never be zero 2020-04-28 09:32:02 +10:00
Andy Piper 1dbde3af09 Filter: add support for double harmonic notches to more effectively target wider noise peaks 2020-04-28 09:32:02 +10:00
Andy Piper 4c1816a983 Copter: port betaflight in-flight fft analysis to arducopter and expose as a log message
add harmonic notch tracking mode
call AP_GyroFFT::update_freq_hover() from update_throttle_hover()
move gyrofft configuration and control to AP_Vehicle
move fft logging to fft library
2020-02-22 11:15:37 +11:00
Andy Piper 6f5b991f28 Filter: add harmonic notch dynamic tracking mode
move definition of HNF_MAX_HARMONICS
2020-02-22 11:15:37 +11:00
Andrew Tridgell f6c3c73037 Filter: switch harmomic notch mode to enum class 2019-11-19 07:08:01 +08:00
Andy Piper 22111f59e8 Filter: add harmonic notch dynamic tracking mode
update harmonic notch REF docs
2019-10-31 11:18:40 +08:00
Andy Piper ef7f8531fb Filter: set the harmonic notch filter ref default to zero (disabled)
Modify parameter descriptions for tradheli
2019-10-10 20:26:02 +09:00
Leonard Hall 6f3be90147 Filter: Alter Notch filter formula to remove /0 and allow perfect notch.
This formulation of the notch equations lets the user specify the depth of the Notch. The presence of a diveide by A prevents the gain going to zero and therefore achieving a perfect notch. It also provides the risk that a user may attempt to do this and cause a divide by zero error. This change adds the ability to achive a perfect notch and removes the possibility of a divide by zero.

Add Notch Filter parameter checking
2019-09-11 18:41:05 +10:00
Andy Piper 9b9fb0d593 Filter: sanity check the harmonic notch sample rate on initialization. do not allow harmonics to go above the nyquist frequency 2019-09-11 18:41:05 +10:00
Andy Piper bc5916ebc9 Filter: comment on reserved config. cope with notch allocation failure. 2019-09-11 18:41:05 +10:00
Andy Piper 334ebadd5a Filter: add comments and address review comments for harmonic notch 2019-09-11 18:41:05 +10:00
Andy Piper 366bc06089 Filter: New HarmonicNotchFilter
This delegates updates to a bank of NotchFilters located at an rpm frequency and harmonics. Center frequency can be updated dynamically. Notch parameters are configurable, including the number of harmonics to filter on. Updates to the filter parameters are optimized across the notch bank. Convert notch bandwidth and frequency to floats.

allow all filter harmonics to be controlled.

add destructor to harmonic notch.

don't allocate sub-filters for harmonic notch if no harmonics set.
2019-09-11 18:41:05 +10:00
Andy Piper 52e4676564 Filter: Allow all filter frequencies to be 16bit. 2019-06-06 17:09:17 +10:00
Andy Piper 1a8475cf9f Filter: Decouple notch filter configuration from the filter itself.
Allow multiple notch filters to be instantiated using the same configuration.
2019-06-06 17:09:17 +10:00
Peter Barker 30749b92d9 Filter: add missing override keyword 2019-02-20 19:23:54 +11:00
Peter Barker deb25ed9a9 Filter: remove keywords.txt 2019-02-17 00:29:38 -08:00
Andrew Tridgell 6c09b268d8 Filter: fixed crash on zero cutoff frequency
this fixes #10435
2019-02-08 13:54:54 +11:00
Peter Barker 1056321457 Filter: add override keyword 2018-11-08 11:30:12 +11:00
Andrew Tridgell 50dcca39bd Filter: added a notch filter
maths from Leonard
2017-08-29 13:52:29 +10:00
Pierre Kancir 892a999ba5 Filter: example fix travis warning
missing function declaration
implicit cast
some style fix
2017-04-13 19:56:16 +01:00
Andrew Tridgell b165e025d9 Filter: added new constructor for 1p filter
allow both sample rate and cutoff to be specified in constructor
2016-11-25 17:49:57 +11:00
Andrew Tridgell f94e4b4375 Filter: allow 1P LowPassFilter to work without alpha recalc per sample
this makes the 1P filter optionally syntax compatible with the 2P
filter and much more CPU efficient.
2016-11-10 11:43:29 +11:00
Mathieu OTHACEHE 152edf7189 Global: remove mode line from headers
Using a global .dir-locals.el file is a better alternative than
reincluding the same emacs header in every file of the project.
2016-10-24 09:42:01 -02:00
Lucas De Marchi ae53920e5b build: don't build examples with old build system
We currently check examples are buildable with waf which doesn't need
the libraries to be specified in a make.inc file.  Having the makefiles
there is misleading since people try to build and realize the build is
broken.
2016-10-11 13:03:08 +11:00
Lucas De Marchi 18f1f8bea8 Filter: add AverageFilter variant to save current sum
When the the variable in which we are saving the current sum is of
integral type we can use a much more optimized apply() method: instead
of looping the entire number of samples adding them up, we always keep
the current sum in a member.  It also allows the caller to decide the
type it wants to use to get the average: this may be dictated by another
interface it uses or it may want to avoid the implicit truncate in the
return of apply().
2016-05-10 14:24:59 -03:00
Ricardo de Almeida Gonzaga 5bd034a5a8 Global: start using cmath instead of math.h 2016-04-05 21:06:19 -07:00
dgrat 5148e41c1a AP_Math: Cleaned macro definitions
Moved Definitions into a separate header. Replaced PI with M_PI and
removed the M_PI_*_F macros.
2016-02-27 02:51:33 -03:00
Lucas De Marchi edd3e3c34a Filter: silence warning about unused function
../../libraries/Filter/examples/Derivative/Derivative.cpp:16:14: warning: ‘float noise()’ defined but not used [-Wunused-function]
 static float noise(void)
              ^
2016-02-19 11:51:49 -02:00
Lucas De Marchi 98904825cb Filter: replace header guard with pragma once 2016-02-18 14:52:35 -02:00
Gustavo Jose de Sousa c2e3f05dbf waf: ardupilotwaf: prefix build context methods with ap_
It helps to distinguish between things from waf and things from ardupilotwaf.
2016-01-22 20:10:29 -02:00
Gustavo Jose de Sousa 3d22490397 waf: examples: use methods from bld instead of ardupilotwaf 2016-01-22 20:10:29 -02:00
Gustavo Jose de Sousa d281067bcc waf: make example binaries be placed in 'examples' dir
This commit makes examples' wscripts use ardupilotwaf.example() instead of
ardupilot.program().
2016-01-15 16:46:41 -02:00
Lucas De Marchi a096703b06 Global: don't link with AP_Progmem
AP_Progmem is not used anymore.
2015-12-27 15:58:12 -02:00
Robert Lefebvre 77877ba5fc ModeFilter: Add get() method and support for Float type 2015-12-08 08:25:18 +11:00
Tom Pittenger 4ee2fb6c7a Filter: compiler warnings - unused template <double> 2015-12-07 15:50:00 +09:00
Caio Marcelo de Oliveira Filho 6e7b73610d waf: add waf support 2015-12-03 07:54:30 +11:00
Andrew Tridgell 5b7f2a3de3 Filter: added reset method on vector filters 2015-11-22 17:30:29 +11:00
Caio Marcelo de Oliveira Filho 51a6455ac0 Filter: use millis/micros/panic functions 2015-11-20 12:35:25 +09:00
Andrew Tridgell 3549c717db Filter: removed reference to old 'Desktop' build 2015-11-16 08:06:05 +11:00
Andrew Tridgell 8f4ce7f20b build: removed all nocore.inoflag files
these were APM2 specific
2015-11-16 08:05:17 +11:00
Andrew Tridgell a9372ad5d7 Filter: fixed example builds 2015-11-16 07:58:55 +11:00
Lucas De Marchi 825d10c81a Filter: remove filter with double type
We are currently not using LowPassFilter2p<double> and it just generates
a lot of warnings on PX4 while instantiating it due to implicitly
promoting float to double:

libraries/Filter/LowPassFilter2p.cpp: In instantiation of
	'T DigitalBiquadFilter<T>::apply(const T&, const DigitalBiquadFilter<T>::biquad_params&) [with T = double]':
libraries/Filter/LowPassFilter2p.cpp:86:41:   required from 'T LowPassFilter2p<T>::apply(const T&) [with T = double]'
libraries/Filter/LowPassFilter2p.cpp:98:16:   required from here
libraries/Filter/LowPassFilter2p.cpp:20:82: warning: implicit conversion from 'float' to 'double' to match other
	operand of binary expression [-Wdouble-promotion]
     T delay_element_0 = sample - _delay_element_1 * params.a1 - _delay_element_2 * params.a2;
                                                                                  ^
2015-11-10 12:43:21 +09:00
Caio Marcelo de Oliveira Filho d32207008d Filter: remove unnecessary includes from examples 2015-10-21 09:16:10 +11:00
Caio Marcelo de Oliveira Filho ec52df991c build: compile only the HAL files needed by the board
Instead of requiring every program to specify the HAL related modules,
let the build system do it (in practice everything we compiled depended
on HAL anyway). This allow including only the necessary files in the
compilation.
2015-10-21 09:16:07 +11:00
Caio Marcelo de Oliveira Filho 2e464a53c2 AP_HAL: make code not depend on concrete HAL implementations
The switching between different AP_HAL was happening by giving different
definitions of AP_HAL_BOARD_DRIVER, and the programs would use it to
instantiate.

A program or library code would have to explicitly include (and depend)
on the concrete implementation of the HAL, even when using it only via
interface.

The proposed change move this dependency to be link time. There is a
AP_HAL::get_HAL() function that is used by the client code. Each
implementation of HAL provides its own definition of this function,
returning the appropriate concrete instance.

Since this replaces the job of AP_HAL_BOARD_DRIVER, the definition was
removed.

The static variables for PX4 and VRBRAIN were named differently to avoid
shadowing the extern symbol 'hal'.
2015-10-21 09:16:07 +11:00
Grant Morphett 1b67e49df4 exampleLowPassFilter2p: fixed simple typo error - now build success 2015-08-28 15:36:50 +09:00
dgrat 58e2ac4e56 Filter: Template implementation for <Filter>
There are implementations for float, Vector2f and Vector3f for the Low
Pass Filter and the *2p filter.  I tried to implement these filters
with one common template implementation.  This implementation saves
some lines of code and reduced the redundancy.  One could save even
more code if the currently overloaded isinf/isnan functions and checks
can be removed.

Signed-off-by: Daniel Frenzel <dgdanielf@gmail.com>
2015-08-23 11:17:02 +10:00
Gustavo Jose de Sousa a1af0c2051 Filter: standardize inclusion of libaries headers
This commit changes the way libraries headers are included in source files:

 - If the header is in the same directory the source belongs to, so the
 notation '#include ""' is used with the path relative to the directory
 containing the source.

 - If the header is outside the directory containing the source, then we use
 the notation '#include <>' with the path relative to libraries folder.

Some of the advantages of such approach:

 - Only one search path for libraries headers.

 - OSs like Windows may have a better lookup time.
2015-08-11 16:38:24 +10:00
Randy Mackay 1289208244 LowPassFilter: add get method 2015-06-12 21:36:24 +09:00