diff --git a/src/algorithms/tracking/libs/exponential_smoother.cc b/src/algorithms/tracking/libs/exponential_smoother.cc index 204a1afb1..186882d06 100644 --- a/src/algorithms/tracking/libs/exponential_smoother.cc +++ b/src/algorithms/tracking/libs/exponential_smoother.cc @@ -51,6 +51,24 @@ Exponential_Smoother::Exponential_Smoother() Exponential_Smoother::~Exponential_Smoother() = default; +// Move assignment operator +Exponential_Smoother& Exponential_Smoother::operator=(Exponential_Smoother&& other) +{ + if (this != &other) + { + this->alpha_ = other.alpha_; + this->old_value_ = other.old_value_; + this->one_minus_alpha_ = 1.0 - other.alpha_; + this->samples_for_initialization_ = other.samples_for_initialization_; + this->initializing_ = other.initializing_; + this->init_counter_ = other.init_counter_; + this->min_value_ = other.min_value_; + this->offset_ = other.offset_; + } + return *this; +} + + void Exponential_Smoother::set_alpha(float alpha) { alpha_ = alpha; diff --git a/src/algorithms/tracking/libs/exponential_smoother.h b/src/algorithms/tracking/libs/exponential_smoother.h index f8ff21182..dc7f222d4 100644 --- a/src/algorithms/tracking/libs/exponential_smoother.h +++ b/src/algorithms/tracking/libs/exponential_smoother.h @@ -56,6 +56,7 @@ public: void set_offset(float offset); float smooth(float raw); double smooth(double raw); + Exponential_Smoother& operator=(Exponential_Smoother&& other); //!< Move assignment operator private: float alpha_; // takes value 0.0001 if not set int samples_for_initialization_; diff --git a/src/algorithms/tracking/libs/tracking_loop_filter.cc b/src/algorithms/tracking/libs/tracking_loop_filter.cc index 1d1b679c6..d2b581d2f 100644 --- a/src/algorithms/tracking/libs/tracking_loop_filter.cc +++ b/src/algorithms/tracking/libs/tracking_loop_filter.cc @@ -71,6 +71,25 @@ Tracking_loop_filter::Tracking_loop_filter() Tracking_loop_filter::~Tracking_loop_filter() = default; +// Move assignment operator +Tracking_loop_filter& Tracking_loop_filter::operator=(Tracking_loop_filter&& other) +{ + if (this != &other) + { + this->d_inputs = other.d_inputs; + this->d_outputs = other.d_outputs; + this->d_input_coefficients = other.d_input_coefficients; + this->d_output_coefficients = other.d_output_coefficients; + this->d_loop_order = other.d_loop_order; + this->d_current_index = other.d_current_index; + this->d_include_last_integrator = other.d_include_last_integrator; + this->d_noise_bandwidth = other.d_noise_bandwidth; + this->d_update_interval = other.d_update_interval; + } + return *this; +} + + float Tracking_loop_filter::apply(float current_input) { // Now apply the filter coefficients: diff --git a/src/algorithms/tracking/libs/tracking_loop_filter.h b/src/algorithms/tracking/libs/tracking_loop_filter.h index 0151f3c5a..204b19825 100644 --- a/src/algorithms/tracking/libs/tracking_loop_filter.h +++ b/src/algorithms/tracking/libs/tracking_loop_filter.h @@ -44,6 +44,15 @@ class Tracking_loop_filter { public: + Tracking_loop_filter(); + ~Tracking_loop_filter(); + + Tracking_loop_filter(float update_interval, float noise_bandwidth, + int loop_order = 2, + bool include_last_integrator = false); + + Tracking_loop_filter& operator=(Tracking_loop_filter&& other); //!< Move assignment operator + float get_noise_bandwidth(void) const; float get_update_interval(void) const; bool get_include_last_integrator(void) const; @@ -57,13 +66,6 @@ public: void initialize(float initial_output = 0.0); float apply(float current_input); - Tracking_loop_filter(float update_interval, float noise_bandwidth, - int loop_order = 2, - bool include_last_integrator = false); - - Tracking_loop_filter(); - ~Tracking_loop_filter(); - private: // Store the last inputs and outputs: std::vector d_inputs;