From 72fc7b6f91b0219ded66e6ffae4c9889a652f1ce Mon Sep 17 00:00:00 2001 From: mikeller Date: Wed, 17 Aug 2016 00:25:09 +1200 Subject: [PATCH] Created subtab for PID filters. Added filter setting to PID tuning tab. --- _locales/en/messages.json | 67 ++- tabs/pid_tuning.css | 34 +- tabs/pid_tuning.html | 882 +++++++++++++++++++++----------------- tabs/pid_tuning.js | 61 ++- 4 files changed, 621 insertions(+), 423 deletions(-) diff --git a/_locales/en/messages.json b/_locales/en/messages.json index 33de7e27..21f1bea2 100755 --- a/_locales/en/messages.json +++ b/_locales/en/messages.json @@ -776,8 +776,11 @@ "pidTuningUpgradeFirmwareToChangePidController": { "message": "Changing PID controller disabled - you can change it via the CLI. You have firmware with API version $1, but this functionality requires requires $2." }, - "pidTuningName": { - "message": "Name" + "pidTuningSubTabPid": { + "message": "PID Settings" + }, + "pidTuningSubTabFilter": { + "message": "Filter Settings" }, "pidTuningShowAllPids": { "message": "Show all PIDs" @@ -1623,18 +1626,54 @@ "pidTuningLevelHelp": { "message": "The values below change the behaviour of the ANGLE and HORIZON flight modes. Different PID controllers handle the values differently. Please check the documentation." }, - "pidTuningLfpFilters": { - "message": "LFP Filters" - }, - "pidTuningGyro": { - "message": "Gyro Soft (Hz)" - }, - "pidTuningDTerm": { - "message": "D Term (Hz)" - }, - "pidTuningYaw": { - "message": "Yaw (Hz)" - }, + "pidTuningNonProfileFilterSettings": { + "message": "Profile independent Filter Settings" + }, + "pidTuningGyroLowpassFrequency": { + "message": "Gyro Soft Lowpass Frequency (Hz)" + }, + "pidTuningGyroLowpassFrequencyHelp": { + "message": "Gyro Soft Lowpass Frequency (Hz)" + }, + "pidTuningGyroNotchFrequency": { + "message": "Gyro Notch Filter Frequency (Hz)" + }, + "pidTuningGyroNotchFrequencyHelp": { + "message": "Gyro Notch Filter Frequency (Hz)" + }, + "pidTuningGyroNotchCutoff": { + "message": "Gyro Notch Filter Cutoff Frequency (Hz)" + }, + "pidTuningGyroNotchCutoffHelp": { + "message": "Gyro Notch Filter Cutoff Frequency (Hz)" + }, + "pidTuningFilterSettings": { + "message": "Filter Settings" + }, + "pidTuningDTermLowpassFrequency": { + "message": "D Term Lowpass Frequency (Hz)" + }, + "pidTuningDTermLowpassFrequencyHelp": { + "message": "D Term Lowpass Frequency (Hz)" + }, + "pidTuningDTermNotchFrequency": { + "message": "D Term Notch Filter Frequency (Hz)" + }, + "pidTuningDTermNotchFrequencyHelp": { + "message": "D Term Notch Filter Frequency (Hz)" + }, + "pidTuningDTermNotchCutoff": { + "message": "D Term Notch Filter Cutoff (Hz)" + }, + "pidTuningDTermNotchCutoffHelp": { + "message": "D Term Notch Filter Cutoff (Hz)" + }, + "pidTuningYawLowpassFrequency": { + "message": "Yaw Lowpass Frequency (Hz)" + }, + "pidTuningYawLowpassFrequencyHelp": { + "message": "Yaw Lowpass Frequency (Hz)" + }, "pidTuningVbatPidCompensation": { "message": "Vbat PID Compensation" }, diff --git a/tabs/pid_tuning.css b/tabs/pid_tuning.css index c756aa13..6ef7ef87 100644 --- a/tabs/pid_tuning.css +++ b/tabs/pid_tuning.css @@ -242,7 +242,7 @@ padding: 5px; text-align: left; border-right: 1px solid #ccc; - width: calc(100% -1px); + width: calc(100% - 1px); } .tab-pid_tuning .pid_titlebar th:first-child { @@ -305,6 +305,33 @@ border-radius: 0px; } +.tab-pid_tuning .tab_container { + float: top; + width: 300px; + height: 20px; + border-right-width: 0px; +} + +.tab-pid_tuning .tab_container td { + background-color: #2e2e2e; +} + +.tab-pid_tuning .tab_container td a { + color: #999999; +} + +.tab-pid_tuning .tab_container td.active { + background-color: #ffbb00; + color: #000; + transition: none; +} + +.tab-pid_tuning .tab_container td.active a { + background-color: #ffbb00; + color: #000; + text-shadow: 0px 1px rgba(255, 255, 255, 0.45); +} + .tab-pid_tuning .single-field { display: inline-block; margin-bottom: 10px; @@ -374,7 +401,7 @@ border-bottom: 1px solid #ccc; color: #828282; /* font-family: 'open_sans', Arial; */ - background-image: linear-gradient(-45deg, rgba(255, 255, 255, .2) 10%, transparent 10%, transparent 20%, rgba(255, 255, 255, .2) 20%, rgba(255, 255, 255, .2) 30%, transparent 30%, transparent 40%, rgba(255, 255, 255, .2) 40%, rgba(255, 255, 255, .2) 50%, transparent 50%, transparent 60%, rgba(255, 255, 255, .2) 60%, rgba(255, 255, 255, .2) 70%, transparent 70%, transparent 80%, rgba(255, 255, 255, .2) 80%, rgba(255, 255, 255, .2) 90%, transparent 90%, transparent 100%, rgba(255, 255, 255, .2) 100%, transparent); + background-image: linear-gradient(315deg, rgba(255, 255, 255, .2) 10%, transparent 10%, transparent 20%, rgba(255, 255, 255, .2) 20%, rgba(255, 255, 255, .2) 30%, transparent 30%, transparent 40%, rgba(255, 255, 255, .2) 40%, rgba(255, 255, 255, .2) 50%, transparent 50%, transparent 60%, rgba(255, 255, 255, .2) 60%, rgba(255, 255, 255, .2) 70%, transparent 70%, transparent 80%, rgba(255, 255, 255, .2) 80%, rgba(255, 255, 255, .2) 90%, transparent 90%, transparent 100%, rgba(255, 255, 255, .2) 100%, transparent); } .fancy.header th { @@ -383,7 +410,6 @@ padding-left: 5px; } - .pid_mode { width: calc(100% - 5px); height: 20px; @@ -399,7 +425,7 @@ border-bottom: 1px solid #ccc; color: #828282; font-family: 'open_sans', Arial; - background-image: linear-gradient(-45deg, rgba(255, 255, 255, .2) 10%, transparent 10%, transparent 20%, + background-image: linear-gradient(315deg, rgba(255, 255, 255, .2) 10%, transparent 10%, transparent 20%, rgba(255, 255, 255, .2) 20%, rgba(255, 255, 255, .2) 30%, transparent 30%, transparent 40%, rgba(255, 255, 255, .2) 40%, rgba(255, 255, 255, .2) 50%, transparent 50%, transparent 60%, rgba(255, 255, 255, .2) 60%, rgba(255, 255, 255, .2) 70%, transparent 70%, transparent 80%, diff --git a/tabs/pid_tuning.html b/tabs/pid_tuning.html index 31d2bc8b..cb047a15 100755 --- a/tabs/pid_tuning.html +++ b/tabs/pid_tuning.html @@ -4,11 +4,6 @@
-
-
-

-
-
@@ -50,417 +45,526 @@
+
+ + + + + +
+ + + +
+
-
-
-
- - - - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
-
-
- -
-
- -
-
-
-
-
-
-
-
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - -
-
-
VEL
- - - - - - - - - - - -
-
-
- - - - - - - - - - - - - - - - - - - - - - - - - - -
-
-
-
-
- - - - - - -
- - - - - - - - - - - - - - - - -
-
-
-
-
-
-
-
- - - - - - -
- - - - - - - - - -
-
-
-
-
-
-
-
- - - - -
- - - - - - - - - - - - -
- - -
- -
-
-
-
- -
-
-
-
-
- - - - -
- - - - - - - - - - - - - - - - - - -
- - -
- -
-
-
-
- -
-
-
-
- -
-
-
-
- -
-
-
-
-
- - +
+
+
+
+
- + + + + + + + - - +
+ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
-
- +
+
+
+
+
+
+ +
+
+ +
+
+
+
+
+
+
+
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + +
+
+
VEL
+ + + + + + + + + + + +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+ + + + + + +
+ + + + + + + + + + + + + + + + +
+
+
+
+
+
+
+
+ + + + +
+ + + + + + + - -
+ + +
+ +
-
-
-
-
-
- + + + + +
+
+ +
+
+
+
+
+ + + + +
+ + + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+ +
+
+
+
+
+ - + - - - - - - - - - - - - -
-
-
-
-
-
-
-
- -
+
+
+
-
- - +
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+
+
+ +
+
+
+
+
+
+ + + + + + + + + + + + + +
+
+
+ + + + + + + - - - - - - - - - - -
-
-
- - - - - - - - - - - -
-
-
- +
+
+
+ +
- -
+ + + + +
+
+ + + + + + + + + + + + + +
+
-
- - + +
- - + - - +
+ - - + + - -
+ + +
+ +
+
+
+ + + + + +
+ +
+
+ + + + + + + +
+ +
+
+ + + +
+
+ + + + +
+ + + + + + + + + + + + + + + + + +
+ + +
+ +
+
+
+ + +
+ +
+
+
+ + +
+ +
+
+
+ + +
+ +
+
+
+
diff --git a/tabs/pid_tuning.js b/tabs/pid_tuning.js index 2ddab8c8..cfbfdf5c 100755 --- a/tabs/pid_tuning.js +++ b/tabs/pid_tuning.js @@ -59,7 +59,7 @@ TABS.pid_tuning.initialize = function (callback) { } if (semver.gte(CONFIG.flightControllerVersion, "2.8.1")) { - $('input[name="vbatpidcompensation"]').prop('checked', ADVANCED_TUNING.vbatPidCompensation !== 0); + $('input[name="#vbatpidcompensation"]').prop('checked', ADVANCED_TUNING.vbatPidCompensation !== 0); } if (semver.gte(CONFIG.flightControllerVersion, "2.8.2")) { @@ -227,7 +227,6 @@ TABS.pid_tuning.initialize = function (callback) { $('.pid_tuning input[name="yaw_rate"]').val(RC_tuning.yaw_rate.toFixed(2)); $('.pid_tuning input[name="rc_expo"]').val(RC_tuning.RC_EXPO.toFixed(2)); $('.pid_tuning input[name="rc_yaw_expo"]').val(RC_tuning.RC_YAW_EXPO.toFixed(2)); - $('.pid_tuning input[name="rc_rate_yaw"]').val(RC_tuning.rcYawRate.toFixed(2)); $('.throttle input[name="mid"]').val(RC_tuning.throttle_MID.toFixed(2)); $('.throttle input[name="expo"]').val(RC_tuning.throttle_EXPO.toFixed(2)); @@ -240,14 +239,25 @@ TABS.pid_tuning.initialize = function (callback) { $('.pid_tuning input[name="rc_expo"]').attr("rowspan", "3"); } - $('.pid_tuning input[name="gyro"]').val(FILTER_CONFIG.gyro_soft_lpf_hz); - $('.pid_tuning input[name="dterm"]').val(FILTER_CONFIG.dterm_lpf_hz); - $('.pid_tuning input[name="yaw"]').val(FILTER_CONFIG.yaw_lpf_hz); - - if (semver.lt(CONFIG.flightControllerVersion, "2.9.0")) { - $('.pid_filter').hide(); + if (semver.gte(CONFIG.flightControllerVersion, '2.9.0')) { + $('.pid_tuning input[name="rc_rate_yaw"]').val(RC_tuning.rcYawRate.toFixed(2)); + $('.pid_filter input[name="gyroLowpassFrequency"]').val(FILTER_CONFIG.gyro_soft_lpf_hz); + $('.pid_filter input[name="dtermLowpassFrequency"]').val(FILTER_CONFIG.dterm_lpf_hz); + $('.pid_filter input[name="yawLowpassFrequency"]').val(FILTER_CONFIG.yaw_lpf_hz); + } else { + $('.tab-pid_tuning .subtab-filter').hide(); + $('.tab-pid_tuning .tab_container').hide(); $('.pid_tuning input[name="rc_rate_yaw"]').hide(); } + + if (semver.gte(CONFIG.flightControllerVersion, '3.0.0')) { + $('.pid_filter input[name="gyroNotchFrequency"]').val(FILTER_CONFIG.gyro_soft_notch_hz); + $('.pid_filter input[name="gyroNotchCutoff"]').val(FILTER_CONFIG.gyro_soft_notch_cutoff); + $('.pid_filter input[name="dTermNotchFrequency"]').val(FILTER_CONFIG.dterm_notch_hz); + $('.pid_filter input[name="dTermNotchCutoff"]').val(FILTER_CONFIG.dterm_notch_cutoff); + } else { + $('.pid_filter .newFilter').hide(); + } } function form_to_pid_and_rc() { @@ -256,7 +266,7 @@ TABS.pid_tuning.initialize = function (callback) { } if (semver.gte(CONFIG.flightControllerVersion, "2.8.1")) { - ADVANCED_TUNING.vbatPidCompensation = $('input[name="vbatpidcompensation"]').is(':checked') ? 1 : 0; + ADVANCED_TUNING.vbatPidCompensation = $('input[name="#vbatpidcompensation"]').is(':checked') ? 1 : 0; } if (semver.gte(CONFIG.flightControllerVersion, "2.8.2")) { @@ -346,9 +356,16 @@ TABS.pid_tuning.initialize = function (callback) { RC_tuning.dynamic_THR_PID = parseFloat($('.tpa input[name="tpa"]').val()); RC_tuning.dynamic_THR_breakpoint = parseInt($('.tpa input[name="tpa-breakpoint"]').val()); - FILTER_CONFIG.gyro_soft_lpf_hz = parseInt($('.pid_tuning input[name="gyro"]').val()); - FILTER_CONFIG.dterm_lpf_hz = parseInt($('.pid_tuning input[name="dterm"]').val()); - FILTER_CONFIG.yaw_lpf_hz = parseInt($('.pid_tuning input[name="yaw"]').val()); + FILTER_CONFIG.gyro_soft_lpf_hz = parseInt($('.pid_filter input[name="gyroLowpassFrequency"]').val()); + FILTER_CONFIG.dterm_lpf_hz = parseInt($('.pid_filter input[name="dtermLowpassFrequency"]').val()); + FILTER_CONFIG.yaw_lpf_hz = parseInt($('.pid_filter input[name="yawLowpassFrequency"]').val()); + + if (semver.gte(CONFIG.flightControllerVersion, '3.0.0')) { + FILTER_CONFIG.gyro_soft_notch_hz = parseInt($('.pid_filter input[name="gyroNotchFrequency"]').val()); + FILTER_CONFIG.gyro_soft_notch_cutoff = parseInt($('.pid_filter input[name="gyroNotchCutoff"]').val()); + FILTER_CONFIG.dterm_notch_hz = parseInt($('.pid_filter input[name="dTermNotchFrequency"]').val()); + FILTER_CONFIG.dterm_notch_cutoff = parseInt($('.pid_filter input[name="dTermNotchCutoff"]').val()); + } } function showAllPids() { @@ -360,10 +377,6 @@ TABS.pid_tuning.initialize = function (callback) { $('#pid_main').show(); - if (semver.gte(CONFIG.flightControllerVersion, "2.9.0")) { - $('#pid_filter').show(); - } - if (have_sensor(CONFIG.activeSensors, 'acc')) { $('#pid_accel').show(); $('#pid_level').show(); @@ -482,6 +495,22 @@ TABS.pid_tuning.initialize = function (callback) { self.currentRates.pitch_rate = RC_tuning.roll_pitch_rate; } + $('.tab-pid_tuning .tab_container .pid').on('click', function () { + $('.tab-pid_tuning .subtab-pid').show(); + $('.tab-pid_tuning .subtab-filter').hide(); + + $('.tab-pid_tuning .tab_container td').removeClass('active'); + $(this).addClass('active'); + }); + + $('.tab-pid_tuning .tab_container .filter').on('click', function () { + $('.tab-pid_tuning .subtab-filter').show(); + $('.tab-pid_tuning .subtab-pid').hide(); + + $('.tab-pid_tuning .tab_container td').removeClass('active'); + $(this).addClass('active'); + }); + var showAllButton = $('#showAllPids'); function updatePidDisplay() {