Repository navigation
AttitudeToleranceCompress
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 AttitudeToleranceCompress.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.AttitudeSensorAtom;
/* Tolerance compression for orientation angles: yaw, pitch, roll in degrees. */
public final class AttitudeToleranceCompress extends ToleranceCompress<AttitudeSensorAtom> {
/* Stable step name; the "Tolerance, °" strings are looked up by it. */
public static final String NAME = "attitudeToleranceCompress";
/* Step logic version is 1; atoms are AttitudeSensorAtom. */
public AttitudeToleranceCompress() {
super(NAME, 1, AttitudeSensorAtom.class);
}
/* Three components: yaw, pitch, roll. */
@Override
protected int components() {
return 3;
}
/* Indexes 0 and 1 are yaw and pitch; any other one is roll (no range check). */
@Override
protected double component(AttitudeSensorAtom atom, int index) {
return switch (index) {
case 0 -> atom.yaw;
case 1 -> atom.pitch;
default -> atom.roll;
};
}
/* Period is 360 degrees: the angles are unwrapped, the 359 -> 1 transition is not counted as a jump. */
@Override
protected double period() {
return 360;
}
/* Tolerance spinner step is 0.1 degrees (as in the base class). */
@Override
protected double toleranceStep() {
return 0.1;
}
}The "Tolerance compression: angles" 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 AttitudeSensorAtom: yaw, pitch and roll of the body or gimbal of a drone.
The algorithm and the tolerance parameter are in ToleranceCompress. The class defines three components (yaw, pitch, roll), a period of 360 and a tolerance spinner step of 0.1. The tolerance is in degrees (the label "Tolerance, °"), the same for all three angles. In the base class the period turns on the unwrapping of the angles and limits a link to a half period (180°).
It is used by the DJI import plans (video with telemetry) and DJI SRT: a tolerance of 1° after AttitudeAverageFilter (in these plans the averaging window is 0). The step is also registered in BuiltinScenarios.steps().
- The
toleranceStep()method is overridden with the value 0.1, equal to the default of the base class; the behavior does not change because of this. - Any component index except 0 and 1 returns
roll. - The default tolerance is 0 — lossless; the DJI plans override it to 1.
- This is the last page of the code page chain: according to the table of contents Code there are no pages after it.