Skip to content

Commit 97f1531

Browse files
committed
Added checking of asin argument into trajectory tilt angle formula
1 parent 7fea411 commit 97f1531

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/flightlog.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -914,8 +914,12 @@ export function FlightLog(logData) {
914914
Ve = srcFrame[gpsVelNED[1]],
915915
Vd = srcFrame[gpsVelNED[2]];
916916
const velocity = Math.sqrt(Vn * Vn + Ve * Ve + Vd * Vd);
917-
const minVelo = 1;
918-
const trajectoryTiltAngle = velocity > minVelo ? -Math.asin(Vd / velocity) * 180.0 / Math.PI : 0; // [degree], if velo is up then >0
917+
const minVelo = 5; // 5cm/s limit to prevent division by zero and miss tiny noise values
918+
let trajectoryTiltAngle = 0;
919+
if (velocity > minVelo) {
920+
const angleSin = Math.max(-1, Math.min(1, Vd / velocity));
921+
trajectoryTiltAngle = -Math.asin(angleSin) * 180.0 / Math.PI; // [degree], if velo is up then >0
922+
}
919923
destFrame[fieldIndex++] = trajectoryTiltAngle;
920924
} else {
921925
destFrame[fieldIndex++] = 0;

0 commit comments

Comments
 (0)