mirror of
https://github.com/betaflight/betaflight-configurator.git
synced 2025-07-23 16:25:22 +03:00
Add feedforward support
This commit is contained in:
parent
863708ad94
commit
25e4e7f6ca
6 changed files with 103 additions and 20 deletions
|
@ -376,6 +376,10 @@ var FC = {
|
|||
absoluteControlGain: 0,
|
||||
throttleBoost: 0,
|
||||
acroTrainerAngleLimit: 0,
|
||||
feedforwardRoll: 0,
|
||||
feedforwardPitch: 0,
|
||||
feedforwardYaw: 0,
|
||||
feedforwardTransition: 0,
|
||||
};
|
||||
|
||||
SENSOR_CONFIG = {
|
||||
|
|
|
@ -878,7 +878,11 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
|||
ADVANCED_TUNING.deltaMethod = data.readU8();
|
||||
ADVANCED_TUNING.vbatPidCompensation = data.readU8();
|
||||
if (semver.gte(CONFIG.apiVersion, "1.20.0")) {
|
||||
ADVANCED_TUNING.dtermSetpointTransition = data.readU8();
|
||||
if (semver.gte(CONFIG.apiVersion, "1.40.0")) {
|
||||
ADVANCED_TUNING.feedforwardTransition = data.readU8();
|
||||
} else {
|
||||
ADVANCED_TUNING.dtermSetpointTransition = data.readU8();
|
||||
}
|
||||
ADVANCED_TUNING.dtermSetpointWeight = data.readU8();
|
||||
ADVANCED_TUNING.toleranceBand = data.readU8();
|
||||
ADVANCED_TUNING.toleranceBandReduction = data.readU8();
|
||||
|
@ -904,6 +908,9 @@ MspHelper.prototype.process_data = function(dataHandler) {
|
|||
ADVANCED_TUNING.absoluteControlGain = data.readU8();
|
||||
ADVANCED_TUNING.throttleBoost = data.readU8();
|
||||
ADVANCED_TUNING.acroTrainerAngleLimit = data.readU8();
|
||||
ADVANCED_TUNING.feedforwardRoll = data.readU16();
|
||||
ADVANCED_TUNING.feedforwardPitch = data.readU16();
|
||||
ADVANCED_TUNING.feedforwardYaw = data.readU16();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1542,14 +1549,20 @@ MspHelper.prototype.crunch = function(code) {
|
|||
.push16(ADVANCED_TUNING.yawItermIgnoreRate)
|
||||
.push16(ADVANCED_TUNING.yaw_p_limit)
|
||||
.push8(ADVANCED_TUNING.deltaMethod)
|
||||
.push8(ADVANCED_TUNING.vbatPidCompensation)
|
||||
.push8(ADVANCED_TUNING.dtermSetpointTransition)
|
||||
.push8(Math.min(ADVANCED_TUNING.dtermSetpointWeight, 254))
|
||||
.push8(ADVANCED_TUNING.toleranceBand)
|
||||
.push8(ADVANCED_TUNING.toleranceBandReduction)
|
||||
.push8(ADVANCED_TUNING.itermThrottleGain)
|
||||
.push16(ADVANCED_TUNING.pidMaxVelocity)
|
||||
.push16(ADVANCED_TUNING.pidMaxVelocityYaw);
|
||||
.push8(ADVANCED_TUNING.vbatPidCompensation);
|
||||
|
||||
if (semver.gte(CONFIG.apiVersion, "1.40.0")) {
|
||||
buffer.push8(ADVANCED_TUNING.feedforwardTransition);
|
||||
} else {
|
||||
buffer.push8(ADVANCED_TUNING.dtermSetpointTransition);
|
||||
}
|
||||
|
||||
buffer.push8(Math.min(ADVANCED_TUNING.dtermSetpointWeight, 254))
|
||||
.push8(ADVANCED_TUNING.toleranceBand)
|
||||
.push8(ADVANCED_TUNING.toleranceBandReduction)
|
||||
.push8(ADVANCED_TUNING.itermThrottleGain)
|
||||
.push16(ADVANCED_TUNING.pidMaxVelocity)
|
||||
.push16(ADVANCED_TUNING.pidMaxVelocityYaw);
|
||||
|
||||
if (semver.gte(CONFIG.apiVersion, "1.24.0")) {
|
||||
buffer.push8(ADVANCED_TUNING.levelAngleLimit)
|
||||
|
@ -1569,9 +1582,11 @@ MspHelper.prototype.crunch = function(code) {
|
|||
.push8(ADVANCED_TUNING.itermRelaxType)
|
||||
.push8(ADVANCED_TUNING.absoluteControlGain)
|
||||
.push8(ADVANCED_TUNING.throttleBoost)
|
||||
.push8(ADVANCED_TUNING.acroTrainerAngleLimit);
|
||||
.push8(ADVANCED_TUNING.acroTrainerAngleLimit)
|
||||
.push16(ADVANCED_TUNING.feedforwardRoll)
|
||||
.push16(ADVANCED_TUNING.feedforwardPitch)
|
||||
.push16(ADVANCED_TUNING.feedforwardYaw);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -370,6 +370,28 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
});
|
||||
acroTrainerAngleLimitNumberElement.val(ADVANCED_TUNING.acroTrainerAngleLimit).change();
|
||||
|
||||
// Yaw D
|
||||
$('.pid_tuning .YAW input[name="d"]').val(PIDs[2][2]); // PID Yaw D
|
||||
|
||||
// Feedforward
|
||||
$('.pid_tuning .ROLL input[name="f"]').val(ADVANCED_TUNING.feedforwardRoll);
|
||||
$('.pid_tuning .PITCH input[name="f"]').val(ADVANCED_TUNING.feedforwardPitch);
|
||||
$('.pid_tuning .YAW input[name="f"]').val(ADVANCED_TUNING.feedforwardYaw);
|
||||
|
||||
var feedforwardTransitionNumberElement = $('input[name="feedforwardTransition-number"]');
|
||||
var feedforwardTransitionRangeElement = $('input[name="feedforwardTransition-range"]');
|
||||
|
||||
feedforwardTransitionNumberElement.val(ADVANCED_TUNING.feedforwardTransition / 100);
|
||||
feedforwardTransitionRangeElement.val(ADVANCED_TUNING.feedforwardTransition / 100);
|
||||
|
||||
feedforwardTransitionNumberElement.change(function () {
|
||||
feedforwardTransitionRangeElement.val($(this).val());
|
||||
});
|
||||
feedforwardTransitionRangeElement.change(function () {
|
||||
feedforwardTransitionNumberElement.val($(this).val());
|
||||
});
|
||||
|
||||
|
||||
} else {
|
||||
$('.itermrotation').hide();
|
||||
$('.smartfeedforward').hide();
|
||||
|
@ -377,6 +399,11 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
$('.absoluteControlGain').hide();
|
||||
$('.throttleBoost').hide();
|
||||
$('.acroTrainerAngleLimit').hide();
|
||||
$('.pid_tuning .YAW input[name="d"]').hide();
|
||||
$('.pid_tuning .ROLL input[name="f"]').hide();
|
||||
$('.pid_tuning .PITCH input[name="f"]').hide();
|
||||
$('.pid_tuning .YAW input[name="f"]').hide();
|
||||
$('#pid-tuning .feedForwardTransition').hide();
|
||||
}
|
||||
|
||||
$('input[id="gyroNotch1Enabled"]').change(function() {
|
||||
|
@ -609,6 +636,7 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
}
|
||||
|
||||
if (semver.gte(CONFIG.apiVersion, "1.40.0")) {
|
||||
|
||||
ADVANCED_TUNING.itermRotation = $('input[id="itermrotation"]').is(':checked') ? 1 : 0;
|
||||
ADVANCED_TUNING.smartFeedforward = $('input[id="smartfeedforward"]').is(':checked') ? 1 : 0;
|
||||
|
||||
|
@ -620,8 +648,13 @@ TABS.pid_tuning.initialize = function (callback) {
|
|||
ADVANCED_TUNING.throttleBoost = $('input[name="throttleBoost-number"]').val();
|
||||
|
||||
ADVANCED_TUNING.acroTrainerAngleLimit = $('input[name="acroTrainerAngleLimit-number"]').val();
|
||||
}
|
||||
|
||||
ADVANCED_TUNING.feedforwardRoll = parseInt($('.pid_tuning .ROLL input[name="f"]').val());
|
||||
ADVANCED_TUNING.feedforwardPitch = parseInt($('.pid_tuning .PITCH input[name="f"]').val());
|
||||
ADVANCED_TUNING.feedforwardYaw = parseInt($('.pid_tuning .YAW input[name="f"]').val());
|
||||
|
||||
ADVANCED_TUNING.feedforwardTransition = parseInt($('input[name="feedforwardTransition-number"]').val() * 100);
|
||||
}
|
||||
}
|
||||
|
||||
function showAllPids() {
|
||||
|
@ -1467,8 +1500,13 @@ TABS.pid_tuning.updatePidControllerParameters = function () {
|
|||
} else {
|
||||
$('.pid_tuning .YAW_JUMP_PREVENTION').hide();
|
||||
|
||||
$('#pid-tuning .dtermSetpointTransition').show();
|
||||
$('#pid-tuning .dtermSetpoint').show();
|
||||
if (semver.gte(CONFIG.apiVersion, "1.40.0")) {
|
||||
$('#pid-tuning .dtermSetpointTransition').hide();
|
||||
$('#pid-tuning .dtermSetpoint').hide();
|
||||
} else {
|
||||
$('#pid-tuning .dtermSetpointTransition').show();
|
||||
$('#pid-tuning .dtermSetpoint').show();
|
||||
}
|
||||
|
||||
$('#pid-tuning .delta').hide();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue