Skip to content

Commit cb53f08

Browse files
demvladhaslinghuis
andauthored
Resolved issue of wrong throttle values at spectrum chart when not all log parameters are selected in blackbox settings (#713)
* The conditions for resolving calculated fields are synchronized by adding fields names and their values * Update js/flightlog.js Co-authored-by: Mark Haslinghuis <[email protected]> * Update js/flightlog.js Co-authored-by: Mark Haslinghuis <[email protected]> * Update js/flightlog.js Co-authored-by: Mark Haslinghuis <[email protected]> * Update js/flightlog.js Code style improvement Co-authored-by: Mark Haslinghuis <[email protected]> * code style improvement * code style improvement --------- Co-authored-by: Mark Haslinghuis <[email protected]>
1 parent 7113208 commit cb53f08

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

js/flightlog.js

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ function FlightLog(logData) {
209209
} else
210210
return false;
211211
};
212-
212+
213213
function buildFieldNames() {
214214
// Make an independent copy
215215
fieldNames = parser.frameDefs.I.name.slice(0);
@@ -239,7 +239,7 @@ function FlightLog(logData) {
239239
if (!that.isFieldDisabled().SETPOINT) {
240240
fieldNames.push("rcCommands[0]", "rcCommands[1]", "rcCommands[2]", "rcCommands[3]"); // Custom calculated scaled rccommand
241241
}
242-
if (!(that.isFieldDisabled().GYRO || that.isFieldDisabled().PID)) {
242+
if (!that.isFieldDisabled().GYRO && !that.isFieldDisabled().PID) {
243243
fieldNames.push("axisError[0]", "axisError[1]", "axisError[2]"); // Custom calculated error field
244244
}
245245

@@ -385,8 +385,8 @@ function FlightLog(logData) {
385385
destFrame,
386386
destFrame_currentIndex;
387387

388-
// The G frames need to be processed always. They are "invalid" if not H (Home) has been detected
389-
// before, but if not processed the viewer shows cuts and gaps. This happens if the quad takes off before
388+
// The G frames need to be processed always. They are "invalid" if not H (Home) has been detected
389+
// before, but if not processed the viewer shows cuts and gaps. This happens if the quad takes off before
390390
// fixing enough satellites.
391391
if (frameValid || (frameType == 'G' && frame)) {
392392
switch (frameType) {
@@ -419,7 +419,7 @@ function FlightLog(logData) {
419419
destFrame[slowFrameIndex + destFrame_currentIndex] = lastSlow[slowFrameIndex] === undefined ? null : lastSlow[slowFrameIndex];
420420
}
421421
destFrame_currentIndex += slowFrameLength;
422-
422+
423423
// Also merge last seen gps-frame data
424424
for (let gpsFrameIndex = 0; gpsFrameIndex < lastGPSLength; gpsFrameIndex++) {
425425
destFrame[gpsFrameIndex + destFrame_currentIndex] = lastGPS[gpsFrameIndex] === undefined ? null : lastGPS[gpsFrameIndex];
@@ -617,7 +617,7 @@ function FlightLog(logData) {
617617
destFrame = destChunk.frames[i],
618618
fieldIndex = destFrame.length - ADDITIONAL_COMPUTED_FIELD_COUNT;
619619

620-
if (gyroADC) { //don't calculate attitude if no gyro data
620+
if (!that.isFieldDisabled().GYRO) { //don't calculate attitude if no gyro data
621621
attitude = chunkIMU.updateEstimatedAttitude(
622622
[srcFrame[gyroADC[0]], srcFrame[gyroADC[1]], srcFrame[gyroADC[2]]],
623623
[srcFrame[accSmooth[0]], srcFrame[accSmooth[1]], srcFrame[accSmooth[2]]],
@@ -632,7 +632,7 @@ function FlightLog(logData) {
632632
}
633633

634634
// Add the Feedforward PID sum (P+I+D+F)
635-
if (axisPID) {
635+
if (!that.isFieldDisabled().GYRO && !that.isFieldDisabled().PID) {
636636
for (var axis = 0; axis < 3; axis++) {
637637
let pidSum =
638638
(axisPID[axis][0] !== undefined ? srcFrame[axisPID[axis][0]] : 0) +
@@ -647,7 +647,7 @@ function FlightLog(logData) {
647647
}
648648

649649
// Assign value
650-
destFrame[fieldIndex++] = pidSum;
650+
destFrame[fieldIndex++] = pidSum;
651651
}
652652
}
653653

@@ -657,29 +657,31 @@ function FlightLog(logData) {
657657
// Calculate the Scaled rcCommand (setpoint) (in deg/s, % for throttle)
658658
var fieldIndexRcCommands = fieldIndex;
659659

660-
// Since version 4.0 is not more a virtual field. Copy the real field to the virtual one to maintain the name, workspaces, etc.
661-
if (sysConfig.firmwareType == FIRMWARE_TYPE_BETAFLIGHT && semver.gte(sysConfig.firmwareVersion, '4.0.0')) {
662-
// Roll, pitch and yaw
663-
for (var axis = 0; axis <= AXIS.YAW; axis++) {
664-
destFrame[fieldIndex++] = srcFrame[setpoint[axis]];
665-
}
666-
// Throttle
667-
destFrame[fieldIndex++] = srcFrame[setpoint[AXIS.YAW + 1]]/10;
660+
if (!that.isFieldDisabled().SETPOINT) {
668661

669-
// Versions earlier to 4.0 we must calculate the expected setpoint
670-
} else {
671-
// Roll, pitch and yaw
672-
for (var axis = 0; axis <= AXIS.YAW; axis++) {
662+
// Since version 4.0 is not more a virtual field. Copy the real field to the virtual one to maintain the name, workspaces, etc.
663+
if (sysConfig.firmwareType == FIRMWARE_TYPE_BETAFLIGHT && semver.gte(sysConfig.firmwareVersion, '4.0.0')) {
664+
// Roll, pitch and yaw
665+
for (let axis = 0; axis <= AXIS.YAW; axis++) {
666+
destFrame[fieldIndex++] = srcFrame[setpoint[axis]];
667+
}
668+
// Throttle
669+
destFrame[fieldIndex++] = srcFrame[setpoint[AXIS.YAW + 1]]/10;
670+
671+
// Versions earlier to 4.0 we must calculate the expected setpoint
672+
} else {
673+
// Roll, pitch and yaw
674+
for (let axis = 0; axis <= AXIS.YAW; axis++) {
675+
destFrame[fieldIndex++] = rcCommand[axis] !== undefined ? that.rcCommandRawToDegreesPerSecond(srcFrame[rcCommand[axis]], axis, currentFlightMode) : 0;
676+
}
677+
// Throttle
673678
destFrame[fieldIndex++] =
674-
(rcCommand[axis] !== undefined ? that.rcCommandRawToDegreesPerSecond(srcFrame[rcCommand[axis]], axis, currentFlightMode) : 0);
675-
}
676-
// Throttle
677-
destFrame[fieldIndex++] =
678-
(rcCommand[AXIS.YAW + 1] !== undefined ? that.rcCommandRawToThrottle(srcFrame[rcCommand[AXIS.YAW + 1]]) : 0);
679+
(rcCommand[AXIS.YAW + 1] !== undefined ? that.rcCommandRawToThrottle(srcFrame[rcCommand[AXIS.YAW + 1]]) : 0);
680+
}
679681
}
680682

681683
// Calculate the PID Error
682-
if (axisPID && gyroADC) {
684+
if (!that.isFieldDisabled().GYRO && !that.isFieldDisabled().PID) {
683685
for (var axis = 0; axis < 3; axis++) {
684686
let gyroADCdegrees = (gyroADC[axis] !== undefined ? that.gyroRawToDegreesPerSecond(srcFrame[gyroADC[axis]]) : 0);
685687
destFrame[fieldIndex++] = destFrame[fieldIndexRcCommands + axis] - gyroADCdegrees;
@@ -1085,7 +1087,7 @@ FlightLog.prototype.rcCommandRawToDegreesPerSecond = function(value, axis, curre
10851087
}
10861088

10871089
var rcRate = sysConfig["rc_rates"][axis] / 100.0;
1088-
if (rcRate > 2.0) {
1090+
if (rcRate > 2.0) {
10891091
rcRate += RC_RATE_INCREMENTAL * (rcRate - 2.0);
10901092
}
10911093

0 commit comments

Comments
 (0)