Skip to content

SpeedThresholdGaps

roosit edited this page Nov 15, 2026 · 1 revision

SpeedThresholdGaps

Up | Previous | Next | Русский

Full source with short explanations

Below is the full source of the class in documentation form. The comments inside the block explain the purpose of the parts of the class, but they are not stored in the working file SpeedThresholdGaps.java: the production code stays clean and the explanations live in the wiki.

package com.velitask.plugin.official.processing.gaps;

import com.velitask.sdk.data.SpeedSensorAtom;

/* Formula "Pauses by stop: speed": the stop and moving thresholds are given in km/h. */
public final class SpeedThresholdGaps extends ThresholdGaps<SpeedSensorAtom> {

    /* Stable step name; localization keys Plugin.ImportStep.speedThresholdGaps.* */
    public static final String NAME = "speedThresholdGaps";

    /* The atom stores the speed in thousandths of km/h. */
    private static final double UNITS_PER_KMH = 1000d;

    public SpeedThresholdGaps() {
        /* The formula works with atoms of the speed sensor (SpeedSensorAtom). */
        super(NAME, 1, SpeedSensorAtom.class);
    }

    @Override
    /* The value for the thresholds is the speed in km/h. */
    protected double value(SpeedSensorAtom atom) {
        return atom.speed / UNITS_PER_KMH;
    }
}

Purpose

SpeedThresholdGaps is the "Pauses by stop: speed" formula (speedThresholdGaps): it sets a pause when the speed dropped below the stop threshold and did not rise above the moving threshold for longer than the given time. It suits recordings where the device keeps recording at a standstill (speed near zero) and the file has no explicit pause. The formula is registered in BuiltinScenarios, but no built-in import scenario uses it: it is chosen in custom scenarios for the speed sensor.

How it works

Data. The class is a subclass of ThresholdGaps for SpeedSensorAtom atoms. The value(...) method returns atom.speed / 1000: the atom stores the speed in thousandths of a kilometre per hour, so the thresholds are entered in km/h.

Parameters. Three parameters of the base class: "Stop threshold", "Moving threshold" (both in km/h) and "Minimal stop, s"; all are 0 by default. The common parameter "Stood if moved less than, m" (stoodMeters, 30) comes from GapsStep. The state machine that looks for stops is described on the ThresholdGaps page.

Features and limitations

  • With the defaults (stop threshold 0) the formula finds no pauses: speed is never below zero. To make it work, a stop threshold greater than zero is needed, for example 1 km/h.
  • It is better to set the moving threshold not lower than the stop threshold, otherwise speed jitter around the threshold splits one pause into several.
  • The speed is taken from the atom itself, without smoothing: a noisy sensor is better smoothed with a filter beforehand.

Clone this wiki locally