Cadence Estimator

Table of Contents


The Cadence Estimator allows you to monitor the cadence of the user carrying the client device using collected accelerometer data. The Cadence Estimator implements a modified version of the peak detection algorithm described in to estimate the cadence of the runner by detecting and counting steps taken. This estimator will continually collect accelerometer data, and the accelerometer data will be processed in order estimate cadence at a specified rate.

This tutorial will cover how to initialize the estimator and read cadence estimates periodically.

Initializing The Cadence Estimator

The Cadence Estimator will continually collect accelerometer data into a buffer, and analysis on this buffered data will be performed at a specified period in order to extract cadence information. However, analysis will only be performed when there is more than half a second of useful accelerometer data, meaning that the specified period should be greater than half a second. The Cadence Estimator can be instantiated with the following lines of code:

int period = 3 * 1000; // Three Seconds

DataJobIdentifier cadenceJobId = new DataJobIdentifier("Cadence");

BackableEncapsulator<TimeZoneStampedObject<CadenceContainer>> cadenceData = 
                    new BackableEncapsulator<TimeZoneTimeStampedObject<CadenceContainer>>(cadenceJobId);

CadenceEstimator cadenceEstimator = 
                    new CadenceEstimator(cadenceData, period, this.getApplicationContext());

Prerequisites and Starting the Cadence Estimator

In order to estimate the cadence of a client, the client device must be equipped with a triaxial accelerometer. Most smartphones and other Android-capable devices come equipped with an accelerometer, so we make the assumption that the current device does as well. In the case that the estimator has some requirements, and it does not meet them, it will throw an ExtractorPrerequisiteUnsatisfiedException instead of returning void . In the code snippet below, we have a try-catch to demonstrate this. The estimator can be started using the start()  method of the estimator, and can be terminated using the  terminate()  method.

try {
} catch (ExtractorPrerequisiteUnsatisfiedException e) {
    // Prerequisites of the estimator were not met

// Keep collecting until

Lastly, as described in the extractors and estimators page, a SendDataAtFullListener()  listener can be registered with the Backable Encapsulator that holds the cadence data to send the cadence data points to the server when full.

cadenceEstimator.addListener(new SendDataAtFullListener());

That’s it!

Running Example

(TODO: complete)