Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Skyward Boardcore
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Analyze
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Avionics
Software Development
Skyward Boardcore
Commits
ed1169f7
Commit
ed1169f7
authored
1 year ago
by
Federico Lolli
Browse files
Options
Downloads
Patches
Plain Diff
[LowPass] added config constructor
parent
1fc1e275
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!227
FFT and other Utilities (Filters and Windows)
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/shared/algorithms/Filters/LowPass.cpp
+8
-1
8 additions, 1 deletion
src/shared/algorithms/Filters/LowPass.cpp
src/shared/algorithms/Filters/LowPass.h
+22
-2
22 additions, 2 deletions
src/shared/algorithms/Filters/LowPass.h
with
30 additions
and
3 deletions
src/shared/algorithms/Filters/LowPass.cpp
+
8
−
1
View file @
ed1169f7
...
@@ -26,12 +26,19 @@ namespace Boardcore
...
@@ -26,12 +26,19 @@ namespace Boardcore
{
{
// TODO: WARNING! initialized at 0
// TODO: WARNING! initialized at 0
// WARNING: frequency set by parameters, look for these
anyway
// WARNING: frequency set by parameters, look for these
in any case
LowPass
::
LowPass
(
float
gain
,
float
cutoffFreq
,
float
lambda
)
LowPass
::
LowPass
(
float
gain
,
float
cutoffFreq
,
float
lambda
)
:
gain
(
gain
),
cutoffFreq
(
cutoffFreq
),
lambda
(
lambda
),
output
(
0
)
:
gain
(
gain
),
cutoffFreq
(
cutoffFreq
),
lambda
(
lambda
),
output
(
0
)
{
{
}
}
// TODO: WARNING! initialized at 0
// WARNING: frequency set by parameters, look for these in any case
LowPass
::
LowPass
(
const
LowPassConfig
&
config
)
:
LowPass
(
config
.
gain
,
config
.
cutoffFreq
,
config
.
lambda
)
{
}
float
LowPass
::
filter
(
float
input
)
float
LowPass
::
filter
(
float
input
)
{
{
output
=
lambda
*
output
+
(
gain
/
cutoffFreq
)
*
(
1
-
lambda
)
*
input
;
output
=
lambda
*
output
+
(
gain
/
cutoffFreq
)
*
(
1
-
lambda
)
*
input
;
...
...
This diff is collapsed.
Click to expand it.
src/shared/algorithms/Filters/LowPass.h
+
22
−
2
View file @
ed1169f7
...
@@ -25,21 +25,41 @@
...
@@ -25,21 +25,41 @@
namespace
Boardcore
namespace
Boardcore
{
{
/**
* @brief Online Low Pass filter with frequency-aware parameters
*/
class
LowPass
class
LowPass
{
{
public:
public:
struct
LowPassConfig
{
float
gain
;
float
cutoffFreq
;
float
lambda
;
};
/**
/**
* @brief Construct a
ne
w
Low Pass
object
* @brief Construct a
n onli
ne Low Pass
by providing each parameter
*
*
* @param gain The gain of the filter
* @param gain The gain of the filter
* @param cutoffFreq The cutoff frequency of the filter
* @param cutoffFreq The cutoff frequency of the filter
* @param lambda The lambda parameter of the filter
* @param lambda The lambda parameter of the filter
*
*
* @note WARNING: Initialize output at 0 at first
* @note WARNING: Initialize output at 0 at first
* @note WARNING: frequency set by parameters, look for these
anyway
* @note WARNING: frequency set by parameters, look for these
in any case
*/
*/
LowPass
(
float
gain
,
float
cutoffFreq
,
float
lambda
);
LowPass
(
float
gain
,
float
cutoffFreq
,
float
lambda
);
/**
* @brief Construct an online Low Pass from a configuration
*
* @param config The configuration of the filter
*
* @note WARNING: Initialize output at 0 at first
* @note WARNING: frequency set by parameters, look for these in any case
*/
explicit
LowPass
(
const
LowPassConfig
&
config
);
/**
/**
* @brief Filter the input
* @brief Filter the input
*
*
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment