Skip to content

AccelToleranceCompress

roosit edited this page Nov 15, 2026 · 1 revision

AccelToleranceCompress

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 AccelToleranceCompress.java: the production code stays clean and the explanations live in the wiki.

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

import com.velitask.sdk.data.AccelerometerSensorAtom;

/* Tolerance compression for the accelerometer: three axes X, Y, Z. */
public final class AccelToleranceCompress extends ToleranceCompress<AccelerometerSensorAtom> {

    /* Stable step name; the "Tolerance, mm/s²" strings are looked up by it. */
    public static final String NAME = "accelToleranceCompress";

    /* Step logic version is 1; atoms are AccelerometerSensorAtom. */
    public AccelToleranceCompress() {
        super(NAME, 1, AccelerometerSensorAtom.class);
    }

    /* Three components: x, y, z. */
    @Override
    protected int components() {
        return 3;
    }

    /* Indexes 0 and 1 are the x and y axes; any other one is the z axis (no range check). */
    @Override
    protected double component(AccelerometerSensorAtom atom, int index) {
        return switch (index) {
            case 0 -> atom.x;
            case 1 -> atom.y;
            default -> atom.z;
        };
    }

    /* Tolerance spinner step is 10 mm/s2. */
    @Override
    protected double toleranceStep() {
        return 10;
    }
}

Purpose

The "Tolerance compression: acceleration" step replaces a series of points with straight segments that deviate from the original values by no more than the tolerance. An implementation of ToleranceCompress for AccelerometerSensorAtom.

How it works

The algorithm and the tolerance parameter are in ToleranceCompress. The class defines: three components (x, y, z), period() is not overridden (the values are not angular), the tolerance spinner step is 10. The tolerance is in mm/s² (the label "Tolerance, mm/s²"; the hint says: 1 g ≈ 9807 mm/s²), the same for all three axes.

It is used by the GoPro import plan: a tolerance of 981 mm/s² (about 0.1 g) after AccelAverageFilter; the sensor is disabled in the plan by default. The step is also registered in BuiltinScenarios.steps().

Features and limitations

  • The default tolerance is 0 — lossless; the GoPro plan overrides it.
  • component has no error branch for a wrong index: any index except 0 and 1 gives the z axis (in the averaging filters a wrong index causes IndexOutOfBoundsException). This does not affect the work: components() returns 3.

Clone this wiki locally