1
0
Fork 0
mirror of https://github.com/betaflight/betaflight-configurator.git synced 2025-07-17 13:25:24 +03:00

Add Thrust Linearization

Adds Thrust Linearization to the PID Tuning tab.
This commit is contained in:
Hans Christian Olaussen 2020-10-11 21:21:40 +02:00
parent 14d98c4dea
commit 55c106be61
5 changed files with 41 additions and 1 deletions

View file

@ -3707,6 +3707,15 @@
"pidTuningVbatSagValue": { "pidTuningVbatSagValue": {
"message": "%" "message": "%"
}, },
"pidTuningThrustLinearization": {
"message": "Thrust Linearization"
},
"pidTuningThrustLinearizationHelp": {
"message": "Compensates for the non-linear relationship between throttle and thrust by applying an inverse motor curve to the motor output. The amount of compensation can be varied between 0 and 150%."
},
"pidTuningThrustLinearValue": {
"message": "%"
},
"pidTuningItermRotation": { "pidTuningItermRotation": {
"message": "I Term Rotation" "message": "I Term Rotation"
}, },

View file

@ -466,6 +466,7 @@ const FC = {
ff_smooth_factor: 0, ff_smooth_factor: 0,
ff_boost: 0, ff_boost: 0,
vbat_sag_compensation: 0, vbat_sag_compensation: 0,
thrustLinearization: 0,
}; };
this.ADVANCED_TUNING_ACTIVE = { ...this.ADVANCED_TUNING }; this.ADVANCED_TUNING_ACTIVE = { ...this.ADVANCED_TUNING };

View file

@ -1166,6 +1166,7 @@ MspHelper.prototype.process_data = function(dataHandler) {
FC.ADVANCED_TUNING.ff_smooth_factor = data.readU8(); FC.ADVANCED_TUNING.ff_smooth_factor = data.readU8();
FC.ADVANCED_TUNING.ff_boost = data.readU8(); FC.ADVANCED_TUNING.ff_boost = data.readU8();
FC.ADVANCED_TUNING.vbat_sag_compensation = data.readU8(); FC.ADVANCED_TUNING.vbat_sag_compensation = data.readU8();
FC.ADVANCED_TUNING.thrustLinearization = data.readU8();
} }
} }
} }
@ -2112,7 +2113,8 @@ MspHelper.prototype.crunch = function(code) {
buffer.push8(FC.ADVANCED_TUNING.ff_interpolate_sp) buffer.push8(FC.ADVANCED_TUNING.ff_interpolate_sp)
.push8(FC.ADVANCED_TUNING.ff_smooth_factor) .push8(FC.ADVANCED_TUNING.ff_smooth_factor)
.push8(FC.ADVANCED_TUNING.ff_boost) .push8(FC.ADVANCED_TUNING.ff_boost)
.push8(FC.ADVANCED_TUNING.vbat_sag_compensation); .push8(FC.ADVANCED_TUNING.vbat_sag_compensation)
.push8(FC.ADVANCED_TUNING.thrustLinearization);
} }
} }
} }

View file

@ -483,9 +483,21 @@ TABS.pid_tuning.initialize = function (callback) {
const checked = $(this).is(':checked'); const checked = $(this).is(':checked');
$('.vbatSagCompensation .suboption').toggle(checked); $('.vbatSagCompensation .suboption').toggle(checked);
}).change(); }).change();
// Thrust Linearization
const thrustLinearizationCheck = $('input[id="thrustLinearization"]');
thrustLinearizationCheck.prop('checked', FC.ADVANCED_TUNING.thrustLinearization !== 0);
$('input[name="thrustLinearValue"]').val(FC.ADVANCED_TUNING.thrustLinearization > 0 ? FC.ADVANCED_TUNING.thrustLinearization : 20);
thrustLinearizationCheck.change(function() {
const checked = $(this).is(':checked');
$('.thrustLinearization .suboption').toggle(checked);
}).change();
} else { } else {
$('.ffInterpolateSp').hide(); $('.ffInterpolateSp').hide();
$('.vbatSagCompensation').hide(); $('.vbatSagCompensation').hide();
$('.thrustLinearization').hide();
} }
$('input[id="useIntegratedYaw"]').change(function() { $('input[id="useIntegratedYaw"]').change(function() {
@ -955,6 +967,7 @@ TABS.pid_tuning.initialize = function (callback) {
FC.ADVANCED_TUNING.ff_boost = parseInt($('input[name="ffBoost"]').val()); FC.ADVANCED_TUNING.ff_boost = parseInt($('input[name="ffBoost"]').val());
FC.FILTER_CONFIG.dyn_lpf_curve_expo = parseInt($('.pid_filter input[name="dtermLowpassDynExpo"]').val()); FC.FILTER_CONFIG.dyn_lpf_curve_expo = parseInt($('.pid_filter input[name="dtermLowpassDynExpo"]').val());
FC.ADVANCED_TUNING.vbat_sag_compensation = $('input[id="vbatSagCompensation"]').is(':checked') ? parseInt($('input[name="vbatSagValue"]').val()) : 0; FC.ADVANCED_TUNING.vbat_sag_compensation = $('input[id="vbatSagCompensation"]').is(':checked') ? parseInt($('input[name="vbatSagValue"]').val()) : 0;
FC.ADVANCED_TUNING.thrustLinearization = $('input[id="thrustLinearization"]').is(':checked') ? parseInt($('input[name="thrustLinearValue"]').val()) : 0;
} }
} }

View file

@ -611,6 +611,21 @@
</td> </td>
</tr> </tr>
<tr class="thrustLinearization">
<td><input type="checkbox" id="thrustLinearization" class="toggle" /></td>
<td colspan="2">
<span i18n="pidTuningThrustLinearization"></span>
<div class="helpicon cf_tip" i18n_title="pidTuningThrustLinearizationHelp"></div>
<span class="thrustLinearValue suboption">
<input type="number" name="thrustLinearValue" step="1" min="1" max="150" />
<label for="thrustLinearValue">
<span i18n="pidTuningThrustLinearValue"></span>
</label>
</span>
</td>
</tr>
<tr class="smartfeedforward"> <tr class="smartfeedforward">
<td><input type="checkbox" id="smartfeedforward" class="toggle" /></td> <td><input type="checkbox" id="smartfeedforward" class="toggle" /></td>
<td colspan="2"> <td colspan="2">