From c7740575831082da5c34196669379518537d8944 Mon Sep 17 00:00:00 2001 From: bnsgeyer Date: Fri, 20 Dec 2024 15:17:34 -0500 Subject: [PATCH 01/15] AnalyticTune: add drb and att without ff --- AnalyticTune/AnalyticTune.js | 67 ++++++++++++++++++++++++++++++------ 1 file changed, 56 insertions(+), 11 deletions(-) diff --git a/AnalyticTune/AnalyticTune.js b/AnalyticTune/AnalyticTune.js index f4c14942..428073fc 100644 --- a/AnalyticTune/AnalyticTune.js +++ b/AnalyticTune/AnalyticTune.js @@ -789,6 +789,8 @@ function calculate_predicted_TF(H_acft, sample_rate, window_size) { var unwrap_phase = false var PID_rate = get_form("SCHED_LOOP_RATE") + + // Calculate transfer function for Rate PID var PID_filter = [] var axis_prefix = "ATC_RAT_" + get_axis_prefix(); PID_filter.push(new PID(PID_rate, @@ -800,6 +802,7 @@ function calculate_predicted_TF(H_acft, sample_rate, window_size) { const PID_H = evaluate_transfer_functions([PID_filter], freq_max, freq_step, use_dB, unwrap_phase) + // calculate transfer funciton for the PID Error Notch filter const nef_num = get_form(axis_prefix + "NEF") var nef_freq = 0.0 if (nef_num > 0) { nef_freq = get_form("FILT" + nef_num + "_NOTCH_FREQ") } @@ -812,6 +815,7 @@ function calculate_predicted_TF(H_acft, sample_rate, window_size) { PID_H_TOT = PID_H.H_total } + // calculate transfer function for FF and DFF var FF_filter = [] FF_filter.push(new feedforward(PID_rate, get_form(axis_prefix + "FF"),get_form(axis_prefix + "D_FF"))) const FF_H = evaluate_transfer_functions([FF_filter], freq_max, freq_step, use_dB, unwrap_phase) @@ -821,10 +825,13 @@ function calculate_predicted_TF(H_acft, sample_rate, window_size) { FFPID_H[1][k] = PID_H_TOT[1][k] + FF_H.H_total[1][k] } + // calculate transfer function for target LPF var T_filter = [] T_filter.push(new LPF_1P(PID_rate, get_form(axis_prefix + "FLTT"))) const FLTT_H = evaluate_transfer_functions([T_filter], freq_max, freq_step, use_dB, unwrap_phase) + // calculate transfer function for target PID notch and the target LPF combined, if the notch is defined. Otherwise just + // provide the target LPF as the combined transfer function. const ntf_num = get_form(axis_prefix + "NTF") var ntf_freq = 0.0 if (ntf_num > 0) { ntf_freq = get_form("FILT" + ntf_num + "_NOTCH_FREQ") } @@ -837,10 +844,12 @@ function calculate_predicted_TF(H_acft, sample_rate, window_size) { TGT_FILT_H = FLTT_H.H_total } + // calculate the transfer function of the INS filters which includes notches and LPF let fast_sample_rate = get_form("GyroSampleRate"); let gyro_filters = get_filters(fast_sample_rate) const INS_H = evaluate_transfer_functions([gyro_filters], freq_max, freq_step, use_dB, unwrap_phase) + // calculation of transfer function for the rate controller (includes serveral intermediate steps) var H_PID_Acft_plus_one = [new Array(PID_H_TOT[0].length).fill(0), new Array(PID_H_TOT[0].length).fill(0)] const PID_Acft = complex_mul(H_acft, PID_H_TOT) @@ -855,10 +864,12 @@ function calculate_predicted_TF(H_acft, sample_rate, window_size) { } const Ret_rate = complex_div(FLTT_FFPID_Acft, H_PID_Acft_plus_one) + // calculate transfer function for the angle P in prep for attitude controller calculation var Ang_P_filter = [] Ang_P_filter.push(new Ang_P(PID_rate, get_form("ATC_ANG_" + get_axis_prefix() + "P"))) const Ang_P_H = evaluate_transfer_functions([Ang_P_filter], freq_max, freq_step, use_dB, unwrap_phase) + // calculate transfer function for attitude controller with feedforward enabled (includes intermediate steps) const rate_INS_ANGP = complex_mul(Ret_rate, complex_mul(INS_H.H_total, Ang_P_H.H_total)) var rate_INS_ANGP_plus_one = [new Array(H_acft[0].length).fill(0), new Array(H_acft[0].length).fill(0)] var ANGP_plus_one = [new Array(H_acft[0].length).fill(0), new Array(H_acft[0].length).fill(0)] @@ -868,16 +879,24 @@ function calculate_predicted_TF(H_acft, sample_rate, window_size) { ANGP_plus_one[0][k] = Ang_P_H.H_total[0][k] + 1 ANGP_plus_one[1][k] = Ang_P_H.H_total[1][k] } - const Ret_att = complex_div(complex_mul(ANGP_plus_one, Ret_rate), rate_INS_ANGP_plus_one) + const Ret_att_ff = complex_div(complex_mul(ANGP_plus_one, Ret_rate), rate_INS_ANGP_plus_one) + + // transfer function of attitude controller without feedforward + const Ret_att_nff = complex_div(complex_mul(Ang_P_H.H_total, Ret_rate), rate_INS_ANGP_plus_one) + // calculate transfer function for pilot feel LPF var tc_filter = [] const tc_freq = 1 / (get_form("ATC_INPUT_TC") * 2 * Math.PI) tc_filter.push(new LPF_1P(PID_rate, tc_freq)) const tc_H = evaluate_transfer_functions([tc_filter], freq_max, freq_step, use_dB, unwrap_phase) + // calculate transfer function for pilot input to the aircraft response + const Ret_pilot = complex_mul(tc_H.H_total, Ret_att_ff) - const Ret_pilot = complex_mul(tc_H.H_total, Ret_att) - - return [Ret_rate, Ret_att, Ret_pilot] + // calculate transfer function for attitude Distrubance Rejection + var minus_one = [new Array(H_acft[0].length).fill(-1), new Array(H_acft[0].length).fill(0)] + const Ret_DRB = complex_div(minus_one, rate_INS_ANGP_plus_one) + + return [Ret_rate, Ret_att_ff, Ret_pilot, Ret_DRB, Ret_att_nff] } @@ -1300,6 +1319,11 @@ function calculate_freq_resp() { var coh_att [H_att, coh_att] = calculate_freq_resp_from_FFT(data_set.FFT.AttTgt, data_set.FFT.Att, start_index, end_index, mean_length, window_size, sample_rate) + var H_drb + var coh_drb + [H_drb, coh_drb] = calculate_freq_resp_from_FFT(data_set.FFT.DRBin, data_set.FFT.DRBresp, start_index, end_index, mean_length, window_size, sample_rate) + + // resample calculated responses to predicted response length const len = H_acft[0].length-1 var H_pilot_tf = [new Array(len).fill(0), new Array(len).fill(0)] @@ -1310,6 +1334,8 @@ function calculate_freq_resp() { var coh_rate_tf = [new Array(len).fill(0)] var H_att_tf = [new Array(len).fill(0), new Array(len).fill(0)] var coh_att_tf = [new Array(len).fill(0)] + var H_drb_tf = [new Array(len).fill(0), new Array(len).fill(0)] + var coh_drb_tf = [new Array(len).fill(0)] var freq_tf = [new Array(len).fill(0)] for (let k=1;k Date: Fri, 20 Dec 2024 17:14:14 -0500 Subject: [PATCH 02/15] AnalyticTune: add attitude stability broken loop --- AnalyticTune/AnalyticTune.js | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/AnalyticTune/AnalyticTune.js b/AnalyticTune/AnalyticTune.js index 428073fc..057b0a03 100644 --- a/AnalyticTune/AnalyticTune.js +++ b/AnalyticTune/AnalyticTune.js @@ -896,7 +896,9 @@ function calculate_predicted_TF(H_acft, sample_rate, window_size) { var minus_one = [new Array(H_acft[0].length).fill(-1), new Array(H_acft[0].length).fill(0)] const Ret_DRB = complex_div(minus_one, rate_INS_ANGP_plus_one) - return [Ret_rate, Ret_att_ff, Ret_pilot, Ret_DRB, Ret_att_nff] + const Ret_att_bl = rate_INS_ANGP + + return [Ret_rate, Ret_att_ff, Ret_pilot, Ret_DRB, Ret_att_nff, Ret_att_bl] } @@ -1360,7 +1362,8 @@ function calculate_freq_resp() { var H_att_ff_pred var H_pilot_pred var H_DRB_pred - [H_rate_pred, H_att_ff_pred, H_pilot_pred, H_DRB_pred, H_att_nff_pred] = calculate_predicted_TF(H_acft_tf, sample_rate, window_size) + var H_att_bl + [H_rate_pred, H_att_ff_pred, H_pilot_pred, H_DRB_pred, H_att_nff_pred, H_att_bl] = calculate_predicted_TF(H_acft_tf, sample_rate, window_size) calc_freq_resp = { pilotctrl_H: H_pilot_tf, @@ -1380,7 +1383,8 @@ function calculate_freq_resp() { ratectrl_H: H_rate_pred, pilotctrl_H: H_pilot_pred, attctrl_nff_H: H_att_nff_pred, - DRB_H: H_DRB_pred + DRB_H: H_DRB_pred, + attbl_H: H_att_bl } redraw_freq_resp() @@ -1847,10 +1851,14 @@ function redraw_freq_resp() { } else if (document.getElementById("type_Att_Ctrlr").checked) { calc_data = calc_freq_resp.attctrl_H calc_data_coh = calc_freq_resp.attctrl_coh - pred_data = pred_freq_resp.attctrl_nff_H -// calc_data = calc_freq_resp.DRB_H -// calc_data_coh = calc_freq_resp.DRB_coh -// pred_data = pred_freq_resp.DRB_H + pred_data = pred_freq_resp.attctrl_ff_H // attitude controller with feedforward +// pred_data = pred_freq_resp.attctrl_nff_H // attitude controller without feedforward + +// calc_data = calc_freq_resp.DRB_H // calculated disturbance rejection +// calc_data_coh = calc_freq_resp.DRB_coh // calculated disturbance rejection coherence +// pred_data = pred_freq_resp.DRB_H // predicted disturbance rejection + +// pred_data = pred_freq_resp.attbl_H // attitude stability pred_data_coh = calc_freq_resp.bareAC_coh show_set = true } else if (document.getElementById("type_Rate_Ctrlr").checked) { From 2cedc44fdaaffea8e4fd8ef9d11f549812ab26a2 Mon Sep 17 00:00:00 2001 From: bnsgeyer Date: Sun, 22 Dec 2024 00:24:08 -0500 Subject: [PATCH 03/15] AnalyticTune: add selectable options for new freq resp --- AnalyticTune/AnalyticTune.js | 68 ++++++++++++++++++++++++++---------- AnalyticTune/index.html | 10 ++++-- 2 files changed, 58 insertions(+), 20 deletions(-) diff --git a/AnalyticTune/AnalyticTune.js b/AnalyticTune/AnalyticTune.js index 057b0a03..c49a2216 100644 --- a/AnalyticTune/AnalyticTune.js +++ b/AnalyticTune/AnalyticTune.js @@ -971,6 +971,7 @@ function TimeUS_to_seconds(TimeUS) { // Load a new log let log +var sid_axis function load_log(log_file) { log = new DataflashParser() @@ -1090,6 +1091,9 @@ function load_log(log_file) { parameter_set_value("GyroSampleRate", (1 << gyro_rate) * 1000) } + // set the sid_axis variable + sid_axis = get_param("SID_AXIS"); + // approximately calculate the rate loop rate const loop_rate = get_param("SCHED_LOOP_RATE"); const fstrate = get_param("FSTRATE_ENABLE"); @@ -1834,10 +1838,12 @@ function redraw_freq_resp() { var unwrap_ph = document.getElementById("PID_ScaleUnWrap").checked; + console.log(sid_axis) unwrap_ph = false // Set scaled x data const scaled_bins = frequency_scale.fun(calc_freq_resp.freq) - var show_set = true + var show_set_calc = true + var show_set_pred = true var calc_data var calc_data_coh var pred_data @@ -1845,33 +1851,59 @@ function redraw_freq_resp() { if (document.getElementById("type_Pilot_Ctrlr").checked) { calc_data = calc_freq_resp.pilotctrl_H calc_data_coh = calc_freq_resp.pilotctrl_coh + if (sid_axis > 2 && sid_axis < 7) { + show_set_calc = false + } pred_data = pred_freq_resp.pilotctrl_H pred_data_coh = calc_freq_resp.bareAC_coh - show_set = true + show_set_pred = true + } else if (document.getElementById("type_Att_Stab").checked) { + calc_data = calc_freq_resp.attctrl_H + calc_data_coh = calc_freq_resp.attctrl_coh + show_set_calc = false + pred_data = pred_freq_resp.attbl_H // attitude stability + pred_data_coh = calc_freq_resp.bareAC_coh + show_set_pred = true + } else if (document.getElementById("type_Att_DRB").checked) { + calc_data = calc_freq_resp.DRB_H // calculated disturbance rejection + calc_data_coh = calc_freq_resp.DRB_coh // calculated disturbance rejection coherence + if (sid_axis < 3 || sid_axis > 6) { + show_set_calc = false + } + pred_data = pred_freq_resp.DRB_H // predicted disturbance rejection + pred_data_coh = calc_freq_resp.bareAC_coh + show_set_pred = true + } else if (document.getElementById("type_Att_Ctrlr_nff").checked) { + calc_data = calc_freq_resp.attctrl_H + calc_data_coh = calc_freq_resp.attctrl_coh + if (sid_axis < 3 || sid_axis > 6) { + show_set_calc = false + } + pred_data = pred_freq_resp.attctrl_nff_H // attitude controller without feedforward + pred_data_coh = calc_freq_resp.bareAC_coh + show_set_pred = true } else if (document.getElementById("type_Att_Ctrlr").checked) { calc_data = calc_freq_resp.attctrl_H calc_data_coh = calc_freq_resp.attctrl_coh + if (sid_axis > 2 && sid_axis < 7) { + show_set_calc = false + } pred_data = pred_freq_resp.attctrl_ff_H // attitude controller with feedforward -// pred_data = pred_freq_resp.attctrl_nff_H // attitude controller without feedforward - -// calc_data = calc_freq_resp.DRB_H // calculated disturbance rejection -// calc_data_coh = calc_freq_resp.DRB_coh // calculated disturbance rejection coherence -// pred_data = pred_freq_resp.DRB_H // predicted disturbance rejection - -// pred_data = pred_freq_resp.attbl_H // attitude stability pred_data_coh = calc_freq_resp.bareAC_coh - show_set = true + show_set_pred = true } else if (document.getElementById("type_Rate_Ctrlr").checked) { calc_data = calc_freq_resp.ratectrl_H calc_data_coh = calc_freq_resp.ratectrl_coh + show_set_calc = true pred_data = pred_freq_resp.ratectrl_H pred_data_coh = calc_freq_resp.bareAC_coh - show_set = true + show_set_pred = true } else { calc_data = calc_freq_resp.bareAC_H calc_data_coh = calc_freq_resp.bareAC_coh + show_set_calc = true pred_data = pred_freq_resp.ratectrl_H - show_set = false + show_set_pred = false } // Apply selected scale, set to y axis @@ -1881,7 +1913,7 @@ function redraw_freq_resp() { fft_plot.data[0].x = scaled_bins // Work out if we should show this line - fft_plot.data[0].visible = true + fft_plot.data[0].visible = show_set_calc var calc_plotted_phase = [] if (unwrap_ph) { @@ -1896,7 +1928,7 @@ function redraw_freq_resp() { fft_plot_Phase.data[0].x = scaled_bins // Work out if we should show this line - fft_plot_Phase.data[0].visible = true + fft_plot_Phase.data[0].visible = show_set_calc // Apply selected scale, set to y axis fft_plot_Coh.data[0].y = calc_data_coh @@ -1905,7 +1937,7 @@ function redraw_freq_resp() { fft_plot_Coh.data[0].x = scaled_bins // Work out if we should show this line - fft_plot_Coh.data[0].visible = true + fft_plot_Coh.data[0].visible = show_set_calc // Apply selected scale, set to y axis fft_plot.data[1].y = amplitude_scale.scale(complex_abs(pred_data)) @@ -1914,7 +1946,7 @@ function redraw_freq_resp() { fft_plot.data[1].x = scaled_bins // Work out if we should show this line - fft_plot.data[1].visible = show_set + fft_plot.data[1].visible = show_set_pred var pred_plotted_phase = [] if (unwrap_ph) { @@ -1929,7 +1961,7 @@ function redraw_freq_resp() { fft_plot_Phase.data[1].x = scaled_bins // Work out if we should show this line - fft_plot_Phase.data[1].visible = show_set + fft_plot_Phase.data[1].visible = show_set_pred // Apply selected scale, set to y axis fft_plot_Coh.data[1].y = pred_data_coh @@ -1938,7 +1970,7 @@ function redraw_freq_resp() { fft_plot_Coh.data[1].x = scaled_bins // Work out if we should show this line - fft_plot_Coh.data[1].visible = show_set + fft_plot_Coh.data[1].visible = show_set_pred Plotly.redraw("FFTPlotMag") diff --git a/AnalyticTune/index.html b/AnalyticTune/index.html index 92da7180..948351c1 100644 --- a/AnalyticTune/index.html +++ b/AnalyticTune/index.html @@ -479,14 +479,20 @@

-
+
Control Loop

-
+
+ +
+ +
+ +

From 76e0038fdfe3adcd56896655ed1e9cf8db5f0333 Mon Sep 17 00:00:00 2001 From: bnsgeyer Date: Sun, 22 Dec 2024 22:56:41 -0500 Subject: [PATCH 04/15] AnalyticTune: add rate stability freq response --- AnalyticTune/AnalyticTune.js | 17 ++++++++++++++--- AnalyticTune/index.html | 4 +++- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/AnalyticTune/AnalyticTune.js b/AnalyticTune/AnalyticTune.js index c49a2216..f2ba16ea 100644 --- a/AnalyticTune/AnalyticTune.js +++ b/AnalyticTune/AnalyticTune.js @@ -898,7 +898,9 @@ function calculate_predicted_TF(H_acft, sample_rate, window_size) { const Ret_att_bl = rate_INS_ANGP - return [Ret_rate, Ret_att_ff, Ret_pilot, Ret_DRB, Ret_att_nff, Ret_att_bl] + const Ret_rate_bl = INS_PID_Acft + + return [Ret_rate, Ret_att_ff, Ret_pilot, Ret_DRB, Ret_att_nff, Ret_att_bl, Ret_rate_bl] } @@ -1367,7 +1369,8 @@ function calculate_freq_resp() { var H_pilot_pred var H_DRB_pred var H_att_bl - [H_rate_pred, H_att_ff_pred, H_pilot_pred, H_DRB_pred, H_att_nff_pred, H_att_bl] = calculate_predicted_TF(H_acft_tf, sample_rate, window_size) + var H_rate_bl + [H_rate_pred, H_att_ff_pred, H_pilot_pred, H_DRB_pred, H_att_nff_pred, H_att_bl, H_rate_bl] = calculate_predicted_TF(H_acft_tf, sample_rate, window_size) calc_freq_resp = { pilotctrl_H: H_pilot_tf, @@ -1388,7 +1391,8 @@ function calculate_freq_resp() { pilotctrl_H: H_pilot_pred, attctrl_nff_H: H_att_nff_pred, DRB_H: H_DRB_pred, - attbl_H: H_att_bl + attbl_H: H_att_bl, + ratebl_H: H_rate_bl } redraw_freq_resp() @@ -1864,6 +1868,13 @@ function redraw_freq_resp() { pred_data = pred_freq_resp.attbl_H // attitude stability pred_data_coh = calc_freq_resp.bareAC_coh show_set_pred = true + } else if (document.getElementById("type_Rate_Stab").checked) { + calc_data = calc_freq_resp.attctrl_H + calc_data_coh = calc_freq_resp.attctrl_coh + show_set_calc = false + pred_data = pred_freq_resp.ratebl_H // attitude stability + pred_data_coh = calc_freq_resp.bareAC_coh + show_set_pred = true } else if (document.getElementById("type_Att_DRB").checked) { calc_data = calc_freq_resp.DRB_H // calculated disturbance rejection calc_data_coh = calc_freq_resp.DRB_coh // calculated disturbance rejection coherence diff --git a/AnalyticTune/index.html b/AnalyticTune/index.html index 948351c1..53ab3d4a 100644 --- a/AnalyticTune/index.html +++ b/AnalyticTune/index.html @@ -479,7 +479,7 @@

-
+
Control Loop
@@ -491,6 +491,8 @@



+ +

From 27dc79c1108fcb9d78480e5779d8c36ca7d01a46 Mon Sep 17 00:00:00 2001 From: bnsgeyer Date: Tue, 24 Dec 2024 00:18:30 -0500 Subject: [PATCH 05/15] AnalyticTune: add entire control system broken loop freq resp --- AnalyticTune/AnalyticTune.js | 56 +++++++++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 14 deletions(-) diff --git a/AnalyticTune/AnalyticTune.js b/AnalyticTune/AnalyticTune.js index f2ba16ea..27cf2eb6 100644 --- a/AnalyticTune/AnalyticTune.js +++ b/AnalyticTune/AnalyticTune.js @@ -900,7 +900,16 @@ function calculate_predicted_TF(H_acft, sample_rate, window_size) { const Ret_rate_bl = INS_PID_Acft - return [Ret_rate, Ret_att_ff, Ret_pilot, Ret_DRB, Ret_att_nff, Ret_att_bl, Ret_rate_bl] + // calculate broken loop stability for entire control system + var bl_temp = complex_mul(Ang_P_H.H_total, FLTT_FFPID_Acft) + var bl_temp2 = bl_temp + for (let k=0;k 6) { +// show_set_calc = false +// } pred_data = pred_freq_resp.attbl_H // attitude stability pred_data_coh = calc_freq_resp.bareAC_coh show_set_pred = true } else if (document.getElementById("type_Rate_Stab").checked) { - calc_data = calc_freq_resp.attctrl_H - calc_data_coh = calc_freq_resp.attctrl_coh - show_set_calc = false + calc_data = pred_freq_resp.allbl_H // entire control system stability + calc_data_coh = calc_freq_resp.bareAC_coh + show_set_calc = true pred_data = pred_freq_resp.ratebl_H // attitude stability pred_data_coh = calc_freq_resp.bareAC_coh show_set_pred = true From 35bc9cdc09e8b67d22e042b35cd52ab1b9db1177 Mon Sep 17 00:00:00 2001 From: bnsgeyer Date: Wed, 25 Dec 2024 23:55:01 -0500 Subject: [PATCH 06/15] AnalyticTune: make SID runs selectable --- AnalyticTune/AnalyticTune.js | 155 ++++++++++++++++++++++++++++++++++- AnalyticTune/index.html | 12 +++ 2 files changed, 163 insertions(+), 4 deletions(-) diff --git a/AnalyticTune/AnalyticTune.js b/AnalyticTune/AnalyticTune.js index 27cf2eb6..327e3384 100644 --- a/AnalyticTune/AnalyticTune.js +++ b/AnalyticTune/AnalyticTune.js @@ -983,6 +983,7 @@ function TimeUS_to_seconds(TimeUS) { // Load a new log let log var sid_axis +var sid_sets = {} function load_log(log_file) { log = new DataflashParser() @@ -1015,6 +1016,14 @@ function load_log(log_file) { return get_param_value(PARM, name, allow_change) } + if ("SIDS" in log.messageTypes) { + sid_sets.axis = [] + sid_sets.tlen = [] + const SIDS_time = TimeUS_to_seconds(log.get("SIDS", "TimeUS")) + sid_sets.axis = log.get("SIDS", "Ax") + sid_sets.tlen = log.get("SIDS", "TR") + } + // Find SIDD data range if ("SIDD" in log.messageTypes) { const SIDD_time = TimeUS_to_seconds(log.get("SIDD", "TimeUS")) @@ -1022,7 +1031,28 @@ function load_log(log_file) { flight_data.data[0].x = SIDD_time flight_data.data[0].y = log.get("SIDD", "Targ") - update_time(SIDD_time) + sid_sets.tstart = [] + sid_sets.tend = [] + j = 0 + sid_sets.tstart[j] = SIDD_time[0] + for (let k=1;k 0.5) { + sid_sets.tend[j] = SIDD_time[k-1] + if (sid_sets.tend[j]-sid_sets.tstart[j] > sid_sets.tlen[j]) { + sid_sets.tend[j]=sid_sets.tstart[j]+sid_sets.tlen[j] + } + j++ + sid_sets.tstart[j] = SIDD_time[k] + } + } + sid_sets.tend[j] = SIDD_time[SIDD_time.length-1] + if (sid_sets.tend[j]-sid_sets.tstart[j] > sid_sets.tlen[j]) { + sid_sets.tend[j]=sid_sets.tstart[j]+sid_sets.tlen[j] + } + start_time = sid_sets.tstart[0] + end_time = sid_sets.tend[0] + set_sid_axis(sid_sets.axis[0]) + add_sid_sets() } if ("RATE" in log.messageTypes) { @@ -1102,9 +1132,6 @@ function load_log(log_file) { parameter_set_value("GyroSampleRate", (1 << gyro_rate) * 1000) } - // set the sid_axis variable - sid_axis = get_param("SID_AXIS"); - // approximately calculate the rate loop rate const loop_rate = get_param("SCHED_LOOP_RATE"); const fstrate = get_param("FSTRATE_ENABLE"); @@ -2020,3 +2047,123 @@ function redraw_freq_resp() { const end = performance.now(); console.log(`freq response redraw took: ${end - start} ms`); } + +function add_sid_sets() { + let fieldset = document.getElementById("sid_sets") + + // Remove all children + fieldset.replaceChildren(fieldset.children[0]) + + // Add table + let table = document.createElement("table") + table.style.borderCollapse = "collapse" + + fieldset.appendChild(table) + + // Add headers + let header = document.createElement("tr") + table.appendChild(header) + + function set_cell_style(cell, color) { + cell.style.border = "1px solid #000" + cell.style.padding = "8px" + if (color != null) { + // add alpha, 40% + cell.style.backgroundColor = color + '66' + } + } + + let index = document.createElement("th") + header.appendChild(index) + index.appendChild(document.createTextNode("Num")) + set_cell_style(index) + + let item = document.createElement("th") + header.appendChild(item) + item.appendChild(document.createTextNode("Use")) + set_cell_style(item) + + item = document.createElement("th") + header.appendChild(item) + item.appendChild(document.createTextNode("SID Axis")) + set_cell_style(item) + + item = document.createElement("th") + header.appendChild(item) + item.appendChild(document.createTextNode("Start Time")) + set_cell_style(item) + + item = document.createElement("th") + header.appendChild(item) + item.appendChild(document.createTextNode("End Time")) + set_cell_style(item) + + var num_sets = sid_sets.axis.length + // Add line + let radio = document.createElement("input") + for (let i = 0; i < num_sets; i++) { + const color = num_sets > 1 ? plot_default_color(i) : null + + let row = document.createElement("tr") + table.appendChild(row) + + let index = document.createElement("td") + row.appendChild(index) + set_cell_style(index, color) + index.appendChild(document.createTextNode(i + 1)) + + let item = document.createElement("td") + row.appendChild(item) + set_cell_style(item, color) + + radio = document.createElement("input") + radio.setAttribute('type', "radio") + radio.setAttribute('id', "set_selection_" + i) + radio.setAttribute('name', "sid_sets") + radio.setAttribute('value', "set_set_" + i) + radio.setAttribute('onchange', "update_time_range(this); time_range_changed(this)") + if (i == 0) {radio.checked = true} + item.appendChild(radio) + + item = document.createElement("td") + row.appendChild(item) + set_cell_style(item, color) + item.appendChild(document.createTextNode(sid_sets.axis[i])) + + item = document.createElement("td") + row.appendChild(item) + set_cell_style(item, color) + item.appendChild(document.createTextNode(sid_sets.tstart[i])) + + item = document.createElement("td") + row.appendChild(item) + set_cell_style(item, color) + item.appendChild(document.createTextNode(sid_sets.tend[i])) + + } +} + +function update_time_range() { + + for (j=0; jArduCopter Analytic
+ + + + + + +
+
+ System ID Runs +
+
+

Flight Data

From dbb4a34a43e583a12dfe603427a565be587118b0 Mon Sep 17 00:00:00 2001 From: bnsgeyer Date: Thu, 26 Dec 2024 00:16:42 -0500 Subject: [PATCH 07/15] AnalyticTune: fix axis params for selectable sid_set --- AnalyticTune/AnalyticTune.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AnalyticTune/AnalyticTune.js b/AnalyticTune/AnalyticTune.js index 327e3384..12fcacd1 100644 --- a/AnalyticTune/AnalyticTune.js +++ b/AnalyticTune/AnalyticTune.js @@ -2163,7 +2163,8 @@ function set_sid_axis(axis) { } else if (axis == 2 || axis == 5 || axis == 8 || axis == 11) { document.getElementById("type_Pitch").checked = true } else if (axis == 3 || axis == 6 || axis == 9 || axis == 12) { - document.getElementById("type_Pitch").checked = true + document.getElementById("type_Yaw").checked = true } sid_axis = axis + axis_changed() } From fab50eb2cb5a4e8f4876e7d10a047afcedc80695 Mon Sep 17 00:00:00 2001 From: bnsgeyer Date: Sun, 29 Dec 2024 23:41:11 -0500 Subject: [PATCH 08/15] AnalyticTune: correct broken loop calc --- AnalyticTune/AnalyticTune.js | 57 ++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/AnalyticTune/AnalyticTune.js b/AnalyticTune/AnalyticTune.js index 12fcacd1..7c739431 100644 --- a/AnalyticTune/AnalyticTune.js +++ b/AnalyticTune/AnalyticTune.js @@ -907,9 +907,9 @@ function calculate_predicted_TF(H_acft, sample_rate, window_size) { bl_temp[0][k] = PID_Acft[0][k] + bl_temp2[0][k] bl_temp[1][k] = PID_Acft[1][k] + bl_temp2[1][k] } - const Ret_entire_bl = complex_mul(bl_temp,INS_H.H_total) + const Ret_sys_bl = complex_mul(bl_temp,INS_H.H_total) - return [Ret_rate, Ret_att_ff, Ret_pilot, Ret_DRB, Ret_att_nff, Ret_att_bl, Ret_rate_bl, Ret_entire_bl] + return [Ret_rate, Ret_att_ff, Ret_pilot, Ret_DRB, Ret_att_nff, Ret_att_bl, Ret_rate_bl, Ret_sys_bl] } @@ -1367,9 +1367,9 @@ function calculate_freq_resp() { var coh_drb [H_drb, coh_drb] = calculate_freq_resp_from_FFT(data_set.FFT.DRBin, data_set.FFT.DRBresp, start_index, end_index, mean_length, window_size, sample_rate) - var H_att_bl - var coh_att_bl - [H_att_bl, coh_att_bl] = calculate_freq_resp_from_FFT(data_set.FFT.AttBLInput, data_set.FFT.AttBLOutput, start_index, end_index, mean_length, window_size, sample_rate) + var H_sys_bl + var coh_sys_bl + [H_sys_bl, coh_sys_bl] = calculate_freq_resp_from_FFT(data_set.FFT.SysBLInput, data_set.FFT.SysBLOutput, start_index, end_index, mean_length, window_size, sample_rate) // resample calculated responses to predicted response length const len = H_acft[0].length-1 @@ -1383,8 +1383,8 @@ function calculate_freq_resp() { var coh_att_tf = [new Array(len).fill(0)] var H_drb_tf = [new Array(len).fill(0), new Array(len).fill(0)] var coh_drb_tf = [new Array(len).fill(0)] - var H_att_bl_tf = [new Array(len).fill(0), new Array(len).fill(0)] - var coh_att_bl_tf = [new Array(len).fill(0)] + var H_sys_bl_tf = [new Array(len).fill(0), new Array(len).fill(0)] + var coh_sys_bl_tf = [new Array(len).fill(0)] var freq_tf = [new Array(len).fill(0)] for (let k=1;k 6) { -// show_set_calc = false -// } + calc_data = calc_freq_resp.sysbl_H // entire control system stability + calc_data_coh = calc_freq_resp.sysbl_coh + if (sid_axis < 10 || sid_axis > 12) { + show_set_calc = false + } pred_data = pred_freq_resp.attbl_H // attitude stability pred_data_coh = calc_freq_resp.bareAC_coh show_set_pred = true } else if (document.getElementById("type_Rate_Stab").checked) { - calc_data = pred_freq_resp.allbl_H // entire control system stability - calc_data_coh = calc_freq_resp.bareAC_coh - show_set_calc = true + calc_data = calc_freq_resp.sysbl_H // entire control system stability + calc_data_coh = calc_freq_resp.sysbl_coh + if (sid_axis < 10 || sid_axis > 12) { + show_set_calc = false + } pred_data = pred_freq_resp.ratebl_H // attitude stability pred_data_coh = calc_freq_resp.bareAC_coh show_set_pred = true From e615a3a09ccd7b97353c05e764b3d3ec42d99b22 Mon Sep 17 00:00:00 2001 From: bnsgeyer Date: Tue, 31 Dec 2024 00:01:01 -0500 Subject: [PATCH 09/15] AnalyticTune: remove INS filter from attitude feedback --- AnalyticTune/AnalyticTune.js | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/AnalyticTune/AnalyticTune.js b/AnalyticTune/AnalyticTune.js index 7c739431..3cd3b712 100644 --- a/AnalyticTune/AnalyticTune.js +++ b/AnalyticTune/AnalyticTune.js @@ -870,19 +870,19 @@ function calculate_predicted_TF(H_acft, sample_rate, window_size) { const Ang_P_H = evaluate_transfer_functions([Ang_P_filter], freq_max, freq_step, use_dB, unwrap_phase) // calculate transfer function for attitude controller with feedforward enabled (includes intermediate steps) - const rate_INS_ANGP = complex_mul(Ret_rate, complex_mul(INS_H.H_total, Ang_P_H.H_total)) - var rate_INS_ANGP_plus_one = [new Array(H_acft[0].length).fill(0), new Array(H_acft[0].length).fill(0)] + const rate_ANGP = complex_mul(Ret_rate, Ang_P_H.H_total) + var rate_ANGP_plus_one = [new Array(H_acft[0].length).fill(0), new Array(H_acft[0].length).fill(0)] var ANGP_plus_one = [new Array(H_acft[0].length).fill(0), new Array(H_acft[0].length).fill(0)] for (let k=0;k 12) { show_set_calc = false } - pred_data = pred_freq_resp.ratebl_H // attitude stability + pred_data = pred_freq_resp.sysbl_H // attitude stability pred_data_coh = calc_freq_resp.bareAC_coh show_set_pred = true } else if (document.getElementById("type_Att_DRB").checked) { From 241eeea75613e1e6517fa21fd16243a8d11d87ca Mon Sep 17 00:00:00 2001 From: bnsgeyer Date: Wed, 1 Jan 2025 11:45:23 -0500 Subject: [PATCH 10/15] AnalyticTune: add Entire system stability plot; clean up logic on visible plots --- AnalyticTune/AnalyticTune.js | 27 +++++++++++++++++---------- AnalyticTune/index.html | 8 +++++--- 2 files changed, 22 insertions(+), 13 deletions(-) diff --git a/AnalyticTune/AnalyticTune.js b/AnalyticTune/AnalyticTune.js index 3cd3b712..19465f72 100644 --- a/AnalyticTune/AnalyticTune.js +++ b/AnalyticTune/AnalyticTune.js @@ -1908,34 +1908,39 @@ function redraw_freq_resp() { if (document.getElementById("type_Pilot_Ctrlr").checked) { calc_data = calc_freq_resp.pilotctrl_H calc_data_coh = calc_freq_resp.pilotctrl_coh - if (sid_axis > 2 && sid_axis < 7) { + if (sid_axis > 3) { show_set_calc = false } pred_data = pred_freq_resp.pilotctrl_H pred_data_coh = calc_freq_resp.bareAC_coh show_set_pred = true - } else if (document.getElementById("type_Att_Stab").checked) { + } else if (document.getElementById("type_Sys_Stab").checked) { calc_data = calc_freq_resp.sysbl_H // entire control system stability calc_data_coh = calc_freq_resp.sysbl_coh if (sid_axis < 10 || sid_axis > 12) { show_set_calc = false } + pred_data = pred_freq_resp.sysbl_H // attitude stability + pred_data_coh = calc_freq_resp.bareAC_coh + show_set_pred = true + } else if (document.getElementById("type_Att_Stab").checked) { + calc_data = calc_freq_resp.sysbl_H // entire control system stability + calc_data_coh = calc_freq_resp.sysbl_coh + show_set_calc = false pred_data = pred_freq_resp.attbl_H // attitude stability pred_data_coh = calc_freq_resp.bareAC_coh show_set_pred = true } else if (document.getElementById("type_Rate_Stab").checked) { calc_data = calc_freq_resp.sysbl_H // entire control system stability calc_data_coh = calc_freq_resp.sysbl_coh - if (sid_axis < 10 || sid_axis > 12) { - show_set_calc = false - } - pred_data = pred_freq_resp.sysbl_H // attitude stability + show_set_calc = false + pred_data = pred_freq_resp.ratebl_H // attitude stability pred_data_coh = calc_freq_resp.bareAC_coh show_set_pred = true } else if (document.getElementById("type_Att_DRB").checked) { calc_data = calc_freq_resp.DRB_H // calculated disturbance rejection calc_data_coh = calc_freq_resp.DRB_coh // calculated disturbance rejection coherence - if (sid_axis < 3 || sid_axis > 6) { + if (sid_axis < 4 || sid_axis > 6) { show_set_calc = false } pred_data = pred_freq_resp.DRB_H // predicted disturbance rejection @@ -1944,7 +1949,7 @@ function redraw_freq_resp() { } else if (document.getElementById("type_Att_Ctrlr_nff").checked) { calc_data = calc_freq_resp.attctrl_H calc_data_coh = calc_freq_resp.attctrl_coh - if (sid_axis < 3 || sid_axis > 6) { + if (sid_axis < 4 || sid_axis > 6) { show_set_calc = false } pred_data = pred_freq_resp.attctrl_nff_H // attitude controller without feedforward @@ -1953,7 +1958,7 @@ function redraw_freq_resp() { } else if (document.getElementById("type_Att_Ctrlr").checked) { calc_data = calc_freq_resp.attctrl_H calc_data_coh = calc_freq_resp.attctrl_coh - if (sid_axis > 2 && sid_axis < 7) { + if (sid_axis > 3 && sid_axis < 7 || sid_axis > 9) { show_set_calc = false } pred_data = pred_freq_resp.attctrl_ff_H // attitude controller with feedforward @@ -1962,7 +1967,9 @@ function redraw_freq_resp() { } else if (document.getElementById("type_Rate_Ctrlr").checked) { calc_data = calc_freq_resp.ratectrl_H calc_data_coh = calc_freq_resp.ratectrl_coh - show_set_calc = true + if (sid_axis > 9) { + show_set_calc = false + } pred_data = pred_freq_resp.ratectrl_H pred_data_coh = calc_freq_resp.bareAC_coh show_set_pred = true diff --git a/AnalyticTune/index.html b/AnalyticTune/index.html index 1b3da143..519cd83c 100644 --- a/AnalyticTune/index.html +++ b/AnalyticTune/index.html @@ -491,7 +491,7 @@

-
+
Control Loop
@@ -501,14 +501,16 @@



+ +



- -
+ +
From 1b8318ecf1b64364e22362377eab03fe337113de Mon Sep 17 00:00:00 2001 From: bnsgeyer Date: Wed, 1 Jan 2025 18:43:06 -0500 Subject: [PATCH 11/15] AnalyticTune: Add PILOT_Y_RATE_TC for yaw axis input shaping prediction --- AnalyticTune/AnalyticTune.js | 22 +++++++++++++++++++++- AnalyticTune/index.html | 15 +++++++++++---- AnalyticTune/params.json | 13 +++++++++++++ 3 files changed, 45 insertions(+), 5 deletions(-) diff --git a/AnalyticTune/AnalyticTune.js b/AnalyticTune/AnalyticTune.js index 19465f72..1b6b8aad 100644 --- a/AnalyticTune/AnalyticTune.js +++ b/AnalyticTune/AnalyticTune.js @@ -886,7 +886,12 @@ function calculate_predicted_TF(H_acft, sample_rate, window_size) { // calculate transfer function for pilot feel LPF var tc_filter = [] - const tc_freq = 1 / (get_form("ATC_INPUT_TC") * 2 * Math.PI) + var tc_freq + if (get_axis_prefix() == "YAW_") { + tc_freq = 1 / (get_form("PILOT_Y_RATE_TC") * 2 * Math.PI) + } else { + tc_freq = 1 / (get_form("ATC_INPUT_TC") * 2 * Math.PI) + } tc_filter.push(new LPF_1P(PID_rate, tc_freq)) const tc_H = evaluate_transfer_functions([tc_filter], freq_max, freq_step, use_dB, unwrap_phase) // calculate transfer function for pilot input to the aircraft response @@ -1115,6 +1120,7 @@ function load_log(log_file) { const other_params = [ "INS_GYRO_FILTER", "ATC_INPUT_TC", + "PILOT_Y_RATE_TC", "ATC_ANG_RLL_P", "ATC_ANG_PIT_P", "ATC_ANG_YAW_P" @@ -1153,6 +1159,7 @@ function load_log(log_file) { document.getElementById("endtime").value = end_time } + console.log(param) setup_FFT_data() } @@ -1237,6 +1244,8 @@ function axis_changed() { } function update_PID_filters() { + document.getElementById('RollPitchTC').style.display = 'none'; + document.getElementById('YawTC').style.display = 'none'; document.getElementById('RollPIDS').style.display = 'none'; document.getElementById('PitchPIDS').style.display = 'none'; document.getElementById('YawPIDS').style.display = 'none'; @@ -1247,6 +1256,7 @@ function update_PID_filters() { document.getElementById('FILT' + i).style.display = 'none'; } if (document.getElementById('type_Roll').checked) { + document.getElementById('RollPitchTC').style.display = 'block'; document.getElementById('RollPIDS').style.display = 'block';; document.getElementById('RollNOTCH').style.display = 'block'; const NTF_num = document.getElementById('ATC_RAT_RLL_NTF').value; @@ -1258,6 +1268,7 @@ function update_PID_filters() { document.getElementById('FILT' + NEF_num).style.display = 'block'; } } else if (document.getElementById('type_Pitch').checked) { + document.getElementById('RollPitchTC').style.display = 'block'; document.getElementById('PitchPIDS').style.display = 'block'; document.getElementById('PitchNOTCH').style.display = 'block'; const NTF_num = document.getElementById('ATC_RAT_PIT_NTF').value; @@ -1269,6 +1280,7 @@ function update_PID_filters() { document.getElementById('FILT' + NEF_num).style.display = 'block'; } } else if (document.getElementById('type_Yaw').checked) { + document.getElementById('YawTC').style.display = 'block'; document.getElementById('YawPIDS').style.display = 'block'; document.getElementById('YawNOTCH').style.display = 'block'; const NTF_num = document.getElementById('ATC_RAT_YAW_NTF').value; @@ -1749,6 +1761,14 @@ function save_parameters() { NEF_num = document.getElementById('ATC_RAT_YAW_NEF').value NTF_num = document.getElementById('ATC_RAT_YAW_NTF').value } + if (name.startsWith("ATC_INPUT_")) { + var value = inputs[v].value; + params += name + "," + param_to_string(value) + "\n"; + } + if (name.startsWith("PILOT_")) { + var value = inputs[v].value; + params += name + "," + param_to_string(value) + "\n"; + } if (NEF_num > 0) { if (name.startsWith("FILT" + NEF_num + "_")) { var value = inputs[v].value; diff --git a/AnalyticTune/index.html b/AnalyticTune/index.html index 519cd83c..8df1d60a 100644 --- a/AnalyticTune/index.html +++ b/AnalyticTune/index.html @@ -208,10 +208,17 @@

Flight Data

- Attitude Controller Parameters -

- -

+ Attitude Controller Parameters **WARNING - Parameter values are not updated if they changed during the log** +
+

+ +

+
+

diff --git a/AnalyticTune/params.json b/AnalyticTune/params.json index d10aeb4c..5e2a0ff0 100644 --- a/AnalyticTune/params.json +++ b/AnalyticTune/params.json @@ -729,6 +729,19 @@ "__field_text": "\n // @DisplayName: Throttle Mix Minimum\n // @Description: Throttle vs attitude control prioritisation used when landing (higher values mean we prioritise attitude control over throttle)\n // @Range: 0.1 0.25\n // @User: Advanced" } }, + "PILOT": { + "PILOT_Y_RATE_TC": { + "Description": "Pilot yaw rate control input time constant", + "DisplayName": "Pilot yaw rate control input time constant", + "Range": { + "high": "0.5", + "low": "0.01" + }, + "Units": "s", + "User": "Advanced", + "__field_text": "\n // @DisplayName: Pilot yaw rate control input time constant\n // @Description: Pilot yaw rate control input time constant\n // @Range: 0.01 0.5\n // @User: Advanced" + } + }, "INS": { "INS_ACC1_CALTEMP": { "Calibration": "1", From 4a946e1375b59445345c9a5b97daa70c2e955e8d Mon Sep 17 00:00:00 2001 From: bnsgeyer Date: Wed, 1 Jan 2025 22:22:38 -0500 Subject: [PATCH 12/15] AnalyticTune: removed get link feature; moved warning and used larger font --- AnalyticTune/AnalyticTune.js | 74 ++++++++++-------------------------- AnalyticTune/index.html | 7 ++-- 2 files changed, 24 insertions(+), 57 deletions(-) diff --git a/AnalyticTune/AnalyticTune.js b/AnalyticTune/AnalyticTune.js index 1b6b8aad..7003e568 100644 --- a/AnalyticTune/AnalyticTune.js +++ b/AnalyticTune/AnalyticTune.js @@ -1159,7 +1159,6 @@ function load_log(log_file) { document.getElementById("endtime").value = end_time } - console.log(param) setup_FFT_data() } @@ -1343,7 +1342,7 @@ function calculate_freq_resp() { window_size: window_size, correction: win_correction }) - console.log(data_set) +// console.log(data_set) // Windowing amplitude correction depends on spectrum of interest and resolution const FFT_resolution = data_set.FFT.average_sample_rate/data_set.FFT.window_size @@ -1355,7 +1354,7 @@ function calculate_freq_resp() { // Number of windows averaged const mean_length = end_index - start_index - console.log(mean_length) +// console.log(mean_length) var H_pilot var coh_pilot @@ -1470,18 +1469,18 @@ function load_time_history_data(t_start, t_end, axis) { let timeRATE_arr = log.get("RATE", "TimeUS") const ind1_i = nearestIndex(timeRATE_arr, t_start*1000000) const ind2_i = nearestIndex(timeRATE_arr, t_end*1000000) - console.log("ind1: ",ind1_i," ind2: ",ind2_i) +// console.log("ind1: ",ind1_i," ind2: ",ind2_i) let timeRATE = Array.from(timeRATE_arr) - console.log("time field pre slicing size: ", timeRATE.length) +// console.log("time field pre slicing size: ", timeRATE.length) timeRATE = timeRATE.slice(ind1_i, ind2_i) - console.log("time field post slicing size: ", timeRATE.length) +// console.log("time field post slicing size: ", timeRATE.length) // Determine average sample rate const trecord = (timeRATE[timeRATE.length - 1] - timeRATE[0]) / 1000000 const samplerate = (timeRATE.length)/ trecord - console.log("sample rate: ", samplerate) +// console.log("sample rate: ", samplerate) const timeATT = log.get("ATT", "TimeUS") const ind1_a = nearestIndex(timeATT, t_start*1000000) @@ -1682,43 +1681,6 @@ function window_size_inc(event) { last_window_size = event.target.value } -// build url and query string for current view and copy to clipboard -function get_link() { - - if (!(navigator && navigator.clipboard && navigator.clipboard.writeText)) { - // copy not available - return - } - - // get base url - var url = new URL((window.location.href).split('?')[0]); - - // Add all query strings - var sections = ["params", "PID_params"]; - for (var j = 0; j 0) { if (name.startsWith("FILT" + NEF_num + "_")) { var value = inputs[v].value; @@ -1915,7 +1881,7 @@ function redraw_freq_resp() { var unwrap_ph = document.getElementById("PID_ScaleUnWrap").checked; - console.log(sid_axis) +// console.log(sid_axis) unwrap_ph = false // Set scaled x data const scaled_bins = frequency_scale.fun(calc_freq_resp.freq) diff --git a/AnalyticTune/index.html b/AnalyticTune/index.html index 8df1d60a..92706c72 100644 --- a/AnalyticTune/index.html +++ b/AnalyticTune/index.html @@ -114,10 +114,11 @@

Flight Data

-

-
+

+ +
INS Settings @@ -208,7 +209,7 @@

Flight Data

- Attitude Controller Parameters **WARNING - Parameter values are not updated if they changed during the log** + Attitude Controller Parameters

From 58998f5fc8e58069453c4df0df0e8987b5849f82 Mon Sep 17 00:00:00 2001 From: bnsgeyer Date: Wed, 1 Jan 2025 23:01:00 -0500 Subject: [PATCH 13/15] AnalyticTune: add support for ANG message in 4.6 --- AnalyticTune/AnalyticTune.js | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/AnalyticTune/AnalyticTune.js b/AnalyticTune/AnalyticTune.js index 7003e568..ede31a37 100644 --- a/AnalyticTune/AnalyticTune.js +++ b/AnalyticTune/AnalyticTune.js @@ -990,6 +990,7 @@ function TimeUS_to_seconds(TimeUS) { let log var sid_axis var sid_sets = {} +var use_ANG_message function load_log(log_file) { log = new DataflashParser() @@ -1072,6 +1073,14 @@ function load_log(log_file) { update_time(RATE_time) } + // Determine if ANG message is used instead of ATT message + if ("ANG" in log.messageTypes) { + use_ANG_message = true + } else { + use_ANG_message = false + } + + // If found use zoom to non-zero SIDD if ((start_time != null) && (end_time != null)) { flight_data.layout.xaxis.range = [start_time, end_time] @@ -1482,9 +1491,18 @@ function load_time_history_data(t_start, t_end, axis) { const samplerate = (timeRATE.length)/ trecord // console.log("sample rate: ", samplerate) - const timeATT = log.get("ATT", "TimeUS") - const ind1_a = nearestIndex(timeATT, t_start*1000000) - const ind2_a = nearestIndex(timeATT, t_end*1000000) + var timeATT + var ind1_a + var ind2_a + if (use_ANG_message) { + timeATT = log.get("ANG", "TimeUS") + ind1_a = nearestIndex(timeATT, t_start*1000000) + ind2_a = nearestIndex(timeATT, t_end*1000000) + } else { + timeATT = log.get("ATT", "TimeUS") + ind1_a = nearestIndex(timeATT, t_start*1000000) + ind2_a = nearestIndex(timeATT, t_end*1000000) + } const timeSIDD = log.get("SIDD", "TimeUS") const ind1_s = nearestIndex(timeSIDD, t_start*1000000) @@ -1521,8 +1539,15 @@ function load_time_history_data(t_start, t_end, axis) { let ActInputData = Array.from(log.get("RATE", ActInputParam)) let RateTgtData = Array.from(log.get("RATE", RateTgtParam)) let RateData = Array.from(log.get("RATE", RateParam)) - let AttTgtData = Array.from(log.get("ATT", AttTgtParam)) - let AttData = Array.from(log.get("ATT", AttParam)) + var AttTgtData + var AttData + if (use_ANG_message) { + AttTgtData = Array.from(log.get("ANG", AttTgtParam)) + AttData = Array.from(log.get("ANG", AttParam)) + } else { + AttTgtData = Array.from(log.get("ATT", AttTgtParam)) + AttData = Array.from(log.get("ATT", AttParam)) + } let GyroRawData = Array.from(log.get("SIDD", GyroRawParam)) // Slice ActInputData From ff4f881210d45426d676454e25a332ce1e1d2b4e Mon Sep 17 00:00:00 2001 From: bnsgeyer Date: Thu, 2 Jan 2025 00:20:51 -0500 Subject: [PATCH 14/15] AnalyticTune: fix SID trecord length error --- AnalyticTune/AnalyticTune.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/AnalyticTune/AnalyticTune.js b/AnalyticTune/AnalyticTune.js index ede31a37..c407dc5d 100644 --- a/AnalyticTune/AnalyticTune.js +++ b/AnalyticTune/AnalyticTune.js @@ -1045,16 +1045,16 @@ function load_log(log_file) { for (let k=1;k 0.5) { sid_sets.tend[j] = SIDD_time[k-1] - if (sid_sets.tend[j]-sid_sets.tstart[j] > sid_sets.tlen[j]) { - sid_sets.tend[j]=sid_sets.tstart[j]+sid_sets.tlen[j] + if (sid_sets.tend[j]-sid_sets.tstart[j] > sid_sets.tlen[j] + 1.0) { + sid_sets.tend[j]=sid_sets.tstart[j]+sid_sets.tlen[j] + 1.0 } j++ sid_sets.tstart[j] = SIDD_time[k] } } sid_sets.tend[j] = SIDD_time[SIDD_time.length-1] - if (sid_sets.tend[j]-sid_sets.tstart[j] > sid_sets.tlen[j]) { - sid_sets.tend[j]=sid_sets.tstart[j]+sid_sets.tlen[j] + if (sid_sets.tend[j]-sid_sets.tstart[j] > sid_sets.tlen[j] + 1.0) { + sid_sets.tend[j]=sid_sets.tstart[j]+sid_sets.tlen[j] + 1.0 } start_time = sid_sets.tstart[0] end_time = sid_sets.tend[0] From da0470932a2acd0e6a36717d575cd0393370e40a Mon Sep 17 00:00:00 2001 From: Peter Hall <33176108+IamPete1@users.noreply.github.com> Date: Thu, 2 Jan 2025 16:53:23 +0000 Subject: [PATCH 15/15] AnalyticTune: add `PILOT_Y_RATE_TC` to param to be loaded from json --- AnalyticTune/index.html | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/AnalyticTune/index.html b/AnalyticTune/index.html index 92706c72..9282b3e7 100644 --- a/AnalyticTune/index.html +++ b/AnalyticTune/index.html @@ -586,12 +586,8 @@

calc_btn.onclick = function() { calculate_freq_resp(); } - //var clear_btn = document.getElementById('clear_cookies'); - //clear_btn.onclick = function() { - // clear_cookies(); - //} - let params = ["SCHED_LOOP_RATE"] + let params = ["SCHED_LOOP_RATE", "PILOT_Y_RATE_TC"] var inputs = document.getElementsByTagName("input"); for (param of inputs) { if (param.id.startsWith("INS_") || param.id.startsWith("ATC_") || param.id.startsWith("FILT")) {