summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorDonovan Baarda <abo@minkirri.apana.org.au>2014-10-15 23:01:01 +1100
committerDonovan Baarda <abo@minkirri.apana.org.au>2014-10-15 23:01:01 +1100
commit42212ec9124bec8d489e649d005d991ce611fd2b (patch)
tree893f1be024ccdd4ccd99c95e3aacc35e1fa3680b
parenteb4ff50cfab9fe229f85236c9bca76951dd2893d (diff)
Simplify first_run handling to only initialize filter states.
Make reset() set first_run=true;
-rw-r--r--ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp4
-rw-r--r--ftnoir_filter_ewma2/ftnoir_filter_ewma2.h2
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();