From 42212ec9124bec8d489e649d005d991ce611fd2b Mon Sep 17 00:00:00 2001 From: Donovan Baarda Date: Wed, 15 Oct 2014 23:01:01 +1100 Subject: Simplify first_run handling to only initialize filter states. Make reset() set first_run=true; --- ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp | 4 +--- ftnoir_filter_ewma2/ftnoir_filter_ewma2.h | 2 +- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp index d4aa62b0..a29aa9e5 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp @@ -42,16 +42,14 @@ void FTNoIR_Filter::FilterHeadPoseData(const double *target_camera_position, double new_delta, new_noise, norm_noise; double alpha; - //On the first run, initialize to output=target and return. + //On the first run, initialize filter states to target intput. if (first_run==true) { for (int i=0;i<6;i++) { - new_camera_position[i] = target_camera_position[i]; current_camera_position[i] = target_camera_position[i]; delta[i] = 0.0; noise[i] = 0.0; } first_run=false; - return; } // Calculate the new camera position. diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h index 8863348c..ab01781b 100644 --- a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.h @@ -24,7 +24,7 @@ class FTNoIR_Filter : public IFilter { public: FTNoIR_Filter(); - void reset() {} + void reset() { first_run=true; } void FilterHeadPoseData(const double *target_camera_position, double *new_camera_position); void receiveSettings(); -- cgit v1.2.3