From fbbb4a1183769dab7c2eef9bd89724d686747f6e Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Sun, 6 Jun 2021 16:47:58 +1000 Subject: [PATCH] AP_Soaring: fixed filter constructor calls fixes valgrind error from copy of filter objects on the stack --- libraries/AP_Soaring/AP_Soaring.cpp | 3 --- libraries/AP_Soaring/AP_Soaring.h | 4 ++-- libraries/AP_Soaring/Variometer.cpp | 3 --- libraries/AP_Soaring/Variometer.h | 5 ++--- 4 files changed, 4 insertions(+), 11 deletions(-) diff --git a/libraries/AP_Soaring/AP_Soaring.cpp b/libraries/AP_Soaring/AP_Soaring.cpp index fdcd66605b..016719c28d 100644 --- a/libraries/AP_Soaring/AP_Soaring.cpp +++ b/libraries/AP_Soaring/AP_Soaring.cpp @@ -149,9 +149,6 @@ SoaringController::SoaringController(AP_SpdHgtControl &spdHgt, const AP_Vehicle: _throttle_suppressed(true) { AP_Param::setup_object_defaults(this, var_info); - - _position_x_filter = LowPassFilter(1.0/60.0); - _position_y_filter = LowPassFilter(1.0/60.0); } void SoaringController::get_target(Location &wp) diff --git a/libraries/AP_Soaring/AP_Soaring.h b/libraries/AP_Soaring/AP_Soaring.h index 8dc2af0149..cc596d3f5e 100644 --- a/libraries/AP_Soaring/AP_Soaring.h +++ b/libraries/AP_Soaring/AP_Soaring.h @@ -56,8 +56,8 @@ class SoaringController { float _thermalability; - LowPassFilter _position_x_filter; - LowPassFilter _position_y_filter; + LowPassFilter _position_x_filter{1/60.0}; + LowPassFilter _position_y_filter{1/60.0}; protected: AP_Int8 soar_active; diff --git a/libraries/AP_Soaring/Variometer.cpp b/libraries/AP_Soaring/Variometer.cpp index 87ca9e23a3..e5e5452b0e 100644 --- a/libraries/AP_Soaring/Variometer.cpp +++ b/libraries/AP_Soaring/Variometer.cpp @@ -9,9 +9,6 @@ Manages the estimation of aircraft total energy, drag and vertical air velocity. Variometer::Variometer(const AP_Vehicle::FixedWing &parms) : _aparm(parms) { - _climb_filter = LowPassFilter(1.0/60.0); - - _vdot_filter2 = LowPassFilter(1.0f/60.0f); } void Variometer::update(const float thermal_bank, const float polar_K, const float polar_Cd0, const float polar_B) diff --git a/libraries/AP_Soaring/Variometer.h b/libraries/AP_Soaring/Variometer.h index 96a2820c54..5070ca90ee 100644 --- a/libraries/AP_Soaring/Variometer.h +++ b/libraries/AP_Soaring/Variometer.h @@ -32,9 +32,8 @@ class Variometer { AverageFilterFloat_Size5 _sp_filter; // low pass filter @ 30s time constant - LowPassFilter _climb_filter; - - LowPassFilter _vdot_filter2; + LowPassFilter _climb_filter{1/60.0}; + LowPassFilter _vdot_filter2{1/60.0}; public: Variometer(const AP_Vehicle::FixedWing &parms);