Skip to content

Commit

Permalink
Merge pull request #2053 from mikeller/fix_sliders_resetting
Browse files Browse the repository at this point in the history
Fixed PID tuning sliders disabling on certain values.
  • Loading branch information
mikeller authored Jun 9, 2020
2 parents 0ee367b + 81c41d3 commit b8d0481
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/js/TuningSliders.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ var TuningSliders = {
expertMode: false,
};

const D_MIN_RATIO = 0.85;

TuningSliders.initialize = function() {
this.PID_DEFAULT = FC.getPidDefaults();
this.FILTER_DEFAULT = FC.getFilterDefaults();
Expand All @@ -49,7 +51,7 @@ TuningSliders.setDMinFeatureEnabled = function(dMinFeatureEnabled) {
if (this.dMinFeatureEnabled) {
this.defaultPDRatio = this.PID_DEFAULT[2] / this.PID_DEFAULT[0];
} else {
this.defaultPDRatio = this.PID_DEFAULT[2] / (this.PID_DEFAULT[0] * 1.18);
this.defaultPDRatio = this.PID_DEFAULT[2] / (this.PID_DEFAULT[0] * (1 / D_MIN_RATIO));
}
};

Expand Down Expand Up @@ -88,7 +90,7 @@ TuningSliders.initPidSlidersPosition = function() {
if (this.dMinFeatureEnabled) {
this.PDGainSliderValue = Math.round(ADVANCED_TUNING.dMinRoll / this.PDRatioSliderValue / this.MasterSliderValue / this.PID_DEFAULT[3] * 10) / 10;
} else {
this.PDGainSliderValue = Math.round(PIDs[0][0] / this.MasterSliderValue / (this.PID_DEFAULT[2] * 1.18) * 10) / 10;
this.PDGainSliderValue = Math.round(PIDs[0][0] / this.MasterSliderValue / (this.PID_DEFAULT[2] * (1 / D_MIN_RATIO)) * 10) / 10;
}
this.ResponseSliderValue = Math.round(ADVANCED_TUNING.feedforwardRoll / this.MasterSliderValue / this.PID_DEFAULT[4] * 10) / 10;

Expand Down Expand Up @@ -258,8 +260,8 @@ TuningSliders.calculateNewPids = function() {
} else {
ADVANCED_TUNING.dMinRoll = 0;
ADVANCED_TUNING.dMinPitch = 0;
PIDs[0][2] = Math.round((this.PID_DEFAULT[2] * 0.85) * this.PDGainSliderValue * this.PDRatioSliderValue);
PIDs[1][2] = Math.round((this.PID_DEFAULT[7] * 0.85) * this.PDGainSliderValue * this.PDRatioSliderValue);
PIDs[0][2] = Math.round((this.PID_DEFAULT[2] * D_MIN_RATIO) * this.PDGainSliderValue * this.PDRatioSliderValue);
PIDs[1][2] = Math.round((this.PID_DEFAULT[7] * D_MIN_RATIO) * this.PDGainSliderValue * this.PDRatioSliderValue);
}
// p
PIDs[0][0] = Math.round(this.PID_DEFAULT[0] * this.PDGainSliderValue);
Expand Down

0 comments on commit b8d0481

Please sign in to comment.