mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-28 08:43:34 +08:00
Auto Formatting with clang-format-6.0 (#727)
* Add clang-format * Auto-format AlphaFilter and RingBuffer * Update to tab=8spaces * Allow for 120 width
This commit is contained in:
+8
-16
@@ -38,34 +38,26 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
template<typename T>
|
||||
class AlphaFilter final
|
||||
{
|
||||
template <typename T>
|
||||
class AlphaFilter final {
|
||||
public:
|
||||
AlphaFilter() = default;
|
||||
~AlphaFilter() = default;
|
||||
|
||||
void reset(const T &val) { _x = val; }
|
||||
|
||||
void update(const T &input, float tau, float dt)
|
||||
{
|
||||
const float alpha = dt / tau;
|
||||
void update(const T &input, float tau, float dt) {
|
||||
const float alpha = dt / tau;
|
||||
update(input, alpha);
|
||||
}
|
||||
|
||||
void update(const T &input, float alpha)
|
||||
{
|
||||
_x = (1.f - alpha) * _x + alpha * input;
|
||||
}
|
||||
void update(const T &input, float alpha) { _x = (1.f - alpha) * _x + alpha * input; }
|
||||
|
||||
// Typical 0.9/0.1 lowpass filter
|
||||
void update(const T &input)
|
||||
{
|
||||
update(input, 0.1f);
|
||||
}
|
||||
void update(const T &input) { update(input, 0.1f); }
|
||||
|
||||
const T& getState() const { return _x; }
|
||||
const T &getState() const { return _x; }
|
||||
|
||||
private:
|
||||
T _x{}; ///< current state of the filter
|
||||
T _x{}; ///< current state of the filter
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user