org.android.activityminer.logic.filter
Class GravitationFilter

Package class diagram package GravitationFilter
java.lang.Object
  extended by org.android.activityminer.logic.filter.GravitationFilter

public class GravitationFilter
extends Object

Adaption of the original android 2.3.7 gravity filter reference implementation from API-Level 10 source. (Quelle: https://github.com/android/platform_frameworks_base/blob/gingerbread-release/services/sensorservice/GravitySensor.cpp).


Field Summary
private  ButterworthLowPassFilter.BWFilter bwFilter
          The filter for coefficient calculation
private  ButterworthLowPassFilter.CascadedBiquadIIRBWFilter[] cbqFilter
          The filters for gravitation component in the three axis values.
static double DEFAULT_CORNER_FREQUENCY
          The default corner frequency for the butterworth filter
(package private)  long lastDt
          The last time differences
 
Constructor Summary
GravitationFilter(double fc)
          Constructor
GravitationFilter(double fc, int order)
          Constructor
 
Method Summary
 double[] filter(double[] currentSample, double[] a, long dt)
          The filter method.
 double[] init(double[] currentSample, double[] a)
          Initialization with the previous x value.
 double[] init(double[] currentSample, double[] a, long dt)
          Initialization with the previous x value.
static boolean validateCutOffFreq(double fc, long samplerate)
          Cut-Off frequency validation.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_CORNER_FREQUENCY

public static final double DEFAULT_CORNER_FREQUENCY
The default corner frequency for the butterworth filter

See Also:
Constant Field Values

cbqFilter

private final ButterworthLowPassFilter.CascadedBiquadIIRBWFilter[] cbqFilter
The filters for gravitation component in the three axis values.


bwFilter

private final ButterworthLowPassFilter.BWFilter bwFilter
The filter for coefficient calculation


lastDt

long lastDt
The last time differences

Constructor Detail

GravitationFilter

public GravitationFilter(double fc)
Constructor

Parameters:
fc - the corner frequency

GravitationFilter

public GravitationFilter(double fc,
                         int order)
Constructor

Parameters:
fc - the corner frequency
order - the filter order
Method Detail

init

public final double[] init(double[] currentSample,
                           double[] a)
Initialization with the previous x value.

Parameters:
currentSample - the current sample to store values in
a - the current raw acceleration values
Returns:
the current sample

init

public final double[] init(double[] currentSample,
                           double[] a,
                           long dt)
Initialization with the previous x value.

Parameters:
currentSample - the current sample to store values in
a - the current raw acceleration values
dt - the current time delta between samples in milliseconds
Returns:
the current sample

filter

public double[] filter(double[] currentSample,
                       double[] a,
                       long dt)
The filter method.

Parameters:
currentSample - the current sample to store values in
a - the current raw acceleration values
dt - the current time delta between samples in milliseconds
Returns:
the current sample

validateCutOffFreq

public static boolean validateCutOffFreq(double fc,
                                         long samplerate)
Cut-Off frequency validation.

Parameters:
fc - the cut-off frequency
samplerate - the current maximum sample rate
Returns:
true if valid, false otherwise