Skip to content

GyroToleranceCompress

roosit edited this page Nov 15, 2026 · 1 revision

GyroToleranceCompress

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 GyroToleranceCompress.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.GyroscopeSensorAtom;

/* Tolerance compression for the gyroscope: angular velocity on three axes. */
public final class GyroToleranceCompress extends ToleranceCompress<GyroscopeSensorAtom> {

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

    /* Step logic version is 1; atoms are GyroscopeSensorAtom. */
    public GyroToleranceCompress() {
        super(NAME, 1, GyroscopeSensorAtom.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(GyroscopeSensorAtom atom, int index) {
        return switch (index) {
            case 0 -> atom.x;
            case 1 -> atom.y;
            default -> atom.z;
        };
    }

    /* Tolerance spinner step is 0.5 °/s. */
    @Override
    protected double toleranceStep() {
        return 0.5;
    }
}

Purpose

The "Tolerance compression: rotation" 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 GyroscopeSensorAtom.

How it works

The algorithm and the tolerance parameter are in ToleranceCompress. The class defines three components (x, y, z), a tolerance spinner step of 0.5 and does not override period(). The tolerance is in °/s (the label "Tolerance, °/s"), the same for all axes.

It is used by the GoPro import plan: a tolerance of 4 °/s after GyroAverageFilter; 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.
  • As in AccelToleranceCompress, any component index except 0 and 1 returns the z axis.

Clone this wiki locally