Independent rates settings for roll and pitch

10.5.x-maintenance
Trond G. Ziarkowski 2018-09-09 11:46:56 +02:00
parent 3a94d0056f
commit 68adc30de8
5 changed files with 58 additions and 11 deletions

View File

@ -155,6 +155,8 @@ var FC = {
dynamic_THR_breakpoint: 0,
RC_YAW_EXPO: 0,
rcYawRate: 0,
rcPitchRate: 0,
RC_PITCH_EXPO: 0,
};
AUX_CONFIG = [];

View File

@ -313,6 +313,13 @@ MspHelper.prototype.process_data = function(dataHandler) {
} else {
RC_tuning.RC_YAW_EXPO = 0;
}
if (semver.gte(CONFIG.apiVersion, "1.37.0")) {
RC_tuning.rcPitchRate = parseFloat((data.readU8() / 100).toFixed(2));
RC_tuning.RC_PITCH_EXPO = parseFloat((data.readU8() / 100).toFixed(2));
} else {
RC_tuning.rcPitchRate = 0;
RC_tuning.RC_PITCH_EXPO = 0;
}
break;
case MSPCodes.MSP_PID:
// PID data arrived, we need to scale it and save to appropriate bank / array
@ -1325,6 +1332,10 @@ MspHelper.prototype.crunch = function(code) {
buffer.push8(Math.round(RC_tuning.rcYawRate * 100));
}
}
if (semver.gte(CONFIG.apiVersion, "1.37.0")) {
buffer.push8(Math.round(RC_tuning.rcPitchRate * 100));
buffer.push8(Math.round(RC_tuning.RC_PITCH_EXPO * 100));
}
break;
case MSPCodes.MSP_SET_RX_MAP:
for (var i = 0; i < RC_MAP.length; i++) {

View File

@ -163,6 +163,11 @@ TABS.pid_tuning.initialize = function (callback) {
$('.antigravity').hide();
}
if (semver.gte(CONFIG.apiVersion, "1.37.0")) {
$('.pid_tuning input[name="rc_rate_pitch"]').val(RC_tuning.rcPitchRate.toFixed(2));
$('.pid_tuning input[name="rc_pitch_expo"]').val(RC_tuning.RC_PITCH_EXPO.toFixed(2));
}
if (semver.gte(CONFIG.apiVersion, "1.39.0")) {
$('.pid_filter input[name="gyroLowpass2Frequency"]').val(FILTER_CONFIG.gyro_lowpass2_hz);
@ -437,6 +442,8 @@ TABS.pid_tuning.initialize = function (callback) {
RC_tuning.RC_EXPO = parseFloat($('.pid_tuning input[name="rc_expo"]').val());
RC_tuning.RC_YAW_EXPO = parseFloat($('.pid_tuning input[name="rc_yaw_expo"]').val());
RC_tuning.rcYawRate = parseFloat($('.pid_tuning input[name="rc_rate_yaw"]').val());
RC_tuning.rcPitchRate = parseFloat($('.pid_tuning input[name="rc_rate_pitch"]').val());
RC_tuning.RC_PITCH_EXPO = parseFloat($('.pid_tuning input[name="rc_pitch_expo"]').val());
RC_tuning.throttle_MID = parseFloat($('.throttle input[name="mid"]').val());
RC_tuning.throttle_EXPO = parseFloat($('.throttle input[name="expo"]').val());
@ -635,13 +642,15 @@ TABS.pid_tuning.initialize = function (callback) {
// Local cache of current rates
self.currentRates = {
roll_rate: RC_tuning.roll_rate,
pitch_rate: RC_tuning.pitch_rate,
yaw_rate: RC_tuning.yaw_rate,
rc_rate: RC_tuning.RC_RATE,
rc_rate_yaw: RC_tuning.rcYawRate,
rc_expo: RC_tuning.RC_EXPO,
rc_yaw_expo: RC_tuning.RC_YAW_EXPO,
roll_rate: RC_tuning.roll_rate,
pitch_rate: RC_tuning.pitch_rate,
yaw_rate: RC_tuning.yaw_rate,
rc_rate: RC_tuning.RC_RATE,
rc_rate_yaw: RC_tuning.rcYawRate,
rc_expo: RC_tuning.RC_EXPO,
rc_yaw_expo: RC_tuning.RC_YAW_EXPO,
rc_rate_pitch: RC_tuning.rcPitchRate,
rc_pitch_expo: RC_tuning.RC_PITCH_EXPO,
superexpo: FEATURE_CONFIG.features.isEnabled('SUPEREXPO_RATES'),
deadband: RC_DEADBAND_CONFIG.deadband,
yawDeadband: RC_DEADBAND_CONFIG.yaw_deadband
@ -665,6 +674,11 @@ TABS.pid_tuning.initialize = function (callback) {
$('.pid_tuning .levelSensitivityHeader').empty();
}
if (semver.lt(CONFIG.apiVersion, "1.37.0")) {
self.currentRates.rc_rate_pitch = self.currentRates.rc_rate;
self.currentRates.rc_expo_pitch = self.currentRates.rc_expo;
}
$('.tab-pid_tuning .tab_container .pid').on('click', function () {
$('.tab-pid_tuning .subtab-pid').show();
$('.tab-pid_tuning .subtab-filter').hide();
@ -950,6 +964,16 @@ TABS.pid_tuning.initialize = function (callback) {
$('.pid_tuning .roll_pitch_rate').hide();
}
if (semver.gte(CONFIG.apiVersion, "1.37.0")) {
$('.pid_tuning .bracket').hide();
$('.pid_tuning input[name=rc_rate]').parent().css('background-color', '')
$('.pid_tuning input[name=rc_rate]').parent().attr('rowspan', 1)
$('.pid_tuning input[name=rc_expo]').parent().attr('rowspan', 1)
} else {
$('.pid_tuning input[name=rc_rate_pitch]').parent().hide()
$('.pid_tuning input[name=rc_pitch_expo]').parent().hide()
}
if (useLegacyCurve) {
$('.new_rates').hide();
}
@ -996,6 +1020,14 @@ TABS.pid_tuning.initialize = function (callback) {
updateNeeded = true;
}
if (targetElement.attr('name') === 'rc_rate' && semver.lt(CONFIG.apiVersion, "1.37.0")) {
self.currentRates.rc_rate_pitch = targetValue;
}
if (targetElement.attr('name') === 'rc_expo' && semver.lt(CONFIG.apiVersion, "1.37.0")) {
self.currentRates.rc_pitch_expo = targetValue;
}
} else { // no event was passed, just force a graph update
updateNeeded = true;
}
@ -1009,7 +1041,7 @@ TABS.pid_tuning.initialize = function (callback) {
if (!useLegacyCurve) {
maxAngularVel = Math.max(
printMaxAngularVel(self.currentRates.roll_rate, self.currentRates.rc_rate, self.currentRates.rc_expo, self.currentRates.superexpo, self.currentRates.deadband, self.maxAngularVelRollElement),
printMaxAngularVel(self.currentRates.pitch_rate, self.currentRates.rc_rate, self.currentRates.rc_expo, self.currentRates.superexpo, self.currentRates.deadband, self.maxAngularVelPitchElement),
printMaxAngularVel(self.currentRates.pitch_rate, self.currentRates.rc_rate_pitch, self.currentRates.rc_pitch_expo, self.currentRates.superexpo, self.currentRates.deadband, self.maxAngularVelPitchElement),
printMaxAngularVel(self.currentRates.yaw_rate, self.currentRates.rc_rate_yaw, self.currentRates.rc_yaw_expo, self.currentRates.superexpo, self.currentRates.yawDeadband, self.maxAngularVelYawElement));
// make maxAngularVel multiple of 200deg/s so that the auto-scale doesn't keep changing for small changes of the maximum curve
@ -1023,7 +1055,7 @@ TABS.pid_tuning.initialize = function (callback) {
curveContext.lineWidth = 2 * lineScale;
drawCurve(self.currentRates.roll_rate, self.currentRates.rc_rate, self.currentRates.rc_expo, self.currentRates.superexpo, self.currentRates.deadband, maxAngularVel, '#ff0000', 0, curveContext);
drawCurve(self.currentRates.pitch_rate, self.currentRates.rc_rate, self.currentRates.rc_expo, self.currentRates.superexpo, self.currentRates.deadband, maxAngularVel, '#00ff00', -4, curveContext);
drawCurve(self.currentRates.pitch_rate, self.currentRates.rc_rate_pitch, self.currentRates.rc_pitch_expo, self.currentRates.superexpo, self.currentRates.deadband, maxAngularVel, '#00ff00', -4, curveContext);
drawCurve(self.currentRates.yaw_rate, self.currentRates.rc_rate_yaw, self.currentRates.rc_yaw_expo, self.currentRates.superexpo, self.currentRates.yawDeadband, maxAngularVel, '#0000ff', 4, curveContext);
self.updateRatesLabels();
@ -1532,7 +1564,7 @@ TABS.pid_tuning.updateRatesLabels = function() {
if(RC.channels[0] && RC.channels[1] && RC.channels[2]) {
currentValues.push(self.rateCurve.drawStickPosition(RC.channels[0], self.currentRates.roll_rate, self.currentRates.rc_rate, self.currentRates.rc_expo, self.currentRates.superexpo, self.currentRates.deadband, maxAngularVel, stickContext, '#FF8080') + ' deg/s');
currentValues.push(self.rateCurve.drawStickPosition(RC.channels[1], self.currentRates.pitch_rate, self.currentRates.rc_rate, self.currentRates.rc_expo, self.currentRates.superexpo, self.currentRates.deadband, maxAngularVel, stickContext, '#80FF80') + ' deg/s');
currentValues.push(self.rateCurve.drawStickPosition(RC.channels[1], self.currentRates.pitch_rate, self.currentRates.rc_rate_pitch, self.currentRates.rc_pitch_expo, self.currentRates.superexpo, self.currentRates.deadband, maxAngularVel, stickContext, '#80FF80') + ' deg/s');
currentValues.push(self.rateCurve.drawStickPosition(RC.channels[2], self.currentRates.yaw_rate, self.currentRates.rc_rate_yaw, self.currentRates.rc_yaw_expo, self.currentRates.superexpo, self.currentRates.yawDeadband, maxAngularVel, stickContext, '#8080FF') + ' deg/s');
} else {
currentValues = [];

View File

@ -575,7 +575,7 @@ TABS.receiver.renderModel = function () {
var delta = this.clock.getDelta();
var roll = delta * this.rateCurve.rcCommandRawToDegreesPerSecond(RC.channels[0], RC_tuning.roll_rate, RC_tuning.RC_RATE, RC_tuning.RC_EXPO, this.useSuperExpo, this.deadband),
pitch = delta * this.rateCurve.rcCommandRawToDegreesPerSecond(RC.channels[1], RC_tuning.pitch_rate, RC_tuning.RC_RATE, RC_tuning.RC_EXPO, this.useSuperExpo, this.deadband),
pitch = delta * this.rateCurve.rcCommandRawToDegreesPerSecond(RC.channels[1], RC_tuning.pitch_rate, RC_tuning.rcPitchRate, RC_tuning.RC_PITCH_EXPO, this.useSuperExpo, this.deadband),
yaw = delta * this.rateCurve.rcCommandRawToDegreesPerSecond(RC.channels[2], RC_tuning.yaw_rate, RC_tuning.rcYawRate, RC_tuning.RC_YAW_EXPO, this.useSuperExpo, this.yawDeadband);
this.model.rotateBy(-degToRad(pitch), -degToRad(yaw), -degToRad(roll));

View File

@ -113,8 +113,10 @@
<td class="pid_data"><input type="number" name="i" step="1" min="0" max="200" /></td>
<td class="pid_data"><input type="number" name="d" step="1" min="0" max="200" /></td>
<td class="pid_data"><input type="number" name="f" step="1" min="0" max="2000" /></td>
<td><input type="number" name="rc_rate_pitch" step="0.01" min="0" max="2.55" /></td>
<td class="pitch_rate"><input type="number" name="pitch_rate" step="0.01" min="0" max="1.00" /></td>
<td class="new_rates maxAngularVelPitch"></td>
<td><input type="number" name="rc_pitch_expo" step="0.01" min="0" max="1" /></td>
</tr>
<tr class="YAW">
<!-- 2 -->