v1.1.0
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Modules Pages
Public Member Functions | List of all members
Sifteo::MotionMedian Class Reference

Calculate median, minimum, and maximum statistics from a MotionBuffer. More...

#include <sifteo/motion.h>

Public Member Functions

void calculate (_SYSMotionBuffer *mbuf, unsigned duration)
 Calculate the component-wise median of recent motion data. More...
 
Byte3 maximum () const
 Return the maximum values for each axis, as a vector.
 
Byte3 median () const
 Return the median itself, as a vector.
 
Byte3 minimum () const
 Return the minimum values for each axis, as a vector.
 
 MotionMedian ()
 Construct an uninitialized MotionMedian.
 
 MotionMedian (_SYSMotionBuffer *mbuf, unsigned duration)
 Construct a MotionMedian with data calculated from the supplied MotionBuffer.
 
Int3 range () const
 Return the difference between maximum and minimum, as a vector.
 

Detailed Description

Calculate median, minimum, and maximum statistics from a MotionBuffer.

This structure contains the results of a median calculation, including the median vector itself as well as min/max stats that we get "for free" as a result of the median calculation.

Member Function Documentation

void Sifteo::MotionMedian::calculate ( _SYSMotionBuffer *  mbuf,
unsigned  duration 
)
inline

Calculate the component-wise median of recent motion data.

The duration is specified in units as defined by TICK_NS, TICK_US, and TICK_HZ. The median accelerometer sample over this duration is calculated and returned. Medians are calculated independently for each of the three channels. No scaling is applied.

The result is written to the supplied MotionMedian buffer. This includes the median itself, as well as the maximum and minimum values, which we get 'for free' as a result of the median calculation.

Unlike the moving-average filter that can be built with integrate(), this algorithm provides a way of filtering data which is very good at eliminating brief spikes but preserving hard edges. The 'duration' parameter will set the latency at which we detect these edges. Spikes up to half this duration can be completely eliminated from the output, unlike in a typical low-pass filter where such spikes just end up 'smeared' into your data.


The documentation for this class was generated from the following file: