Skip to content

Commit

Permalink
rename d_min related values (betaflight#775)
Browse files Browse the repository at this point in the history
* rename d_min related values

* add semver checks
  • Loading branch information
mituritsyn authored Oct 13, 2024
1 parent 97236d1 commit 380601b
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 102 deletions.
96 changes: 28 additions & 68 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ <h5 class="modal-title-revision"></h5>
</table>

<table id="pid_main" class="pid_tuning">
<tr class = "pid_labels">
<tr class = "pid_labels">
<th name="Blank">
<label>&nbsp;</label>
</th>
Expand All @@ -724,74 +724,34 @@ <h5 class="modal-title-revision"></h5>
<th name="Integral">
<label>I</label>
</th>
<th name="D_Max">
<label>D_Max</label>
</th>
<th name="Derivative">
<th id="derivativeColumn" name="Derivative">
<label>D</label>
</th>
<th id="dMaxColumn" name="D_Max">
<label>D Max</label>
</th>
<th name="Feedforward">
<label>FF</label>
</th>
</tr>
<tr class="rollPID">
<!-- 0 -->
<td>Roll</td>
<td>
<input type="text" name="p" step="1" min="0" max="255" />
</td>
<td>
<input type="text" name="i" step="1" min="0" max="255" />
</td>
<td>
<input type="text" name="d" step="1" min="0" max="255" />
</td>
<td>
<input type="text" name="d_min_roll" step="1" min="0" max="255" />
</td>
<td>
<input type="text" name="f" step="1" min="0" max="255" />
</td>
</tr>
<tr class="pitchPID">
<!-- 1 -->
<td>Pitch</td>
<td>
<input type="text" name="p" step="1" min="0" max="255" />
</td>
<td>
<input type="text" name="i" step="1" min="0" max="255" />
</td>
<td>
<input type="text" name="d" step="1" min="0" max="255" />
</td>
<td>
<input type="text" name="d_min_pitch" step="1" min="0" max="255" />
</td>
<td>
<input type="text" name="f" step="1" min="0" max="255" />
</td>
</tr>
<tr class="yawPID">
<!-- 2 -->
<td>Yaw</td>
<td>
<input type="text" name="p" step="1" min="0" max="255" />
</td>
<td>
<input type="text" name="i" step="1" min="0" max="255" />
</td>
<td>
<input type="text" name="d" step="1" min="0" max="255" />
</td>
<td>
<input type="text" name="d_min_yaw" step="1" min="0" max="255" />
</td>
<td>
<input type="text" name="f" step="1" min="0" max="255" />
</td>
</tr>
</table>
<tbody id="pid_tbody"></tbody>
</table>
<script>
const axes = ['Roll', 'Pitch', 'Yaw'];
const pidTbody = document.getElementById('pid_tbody');

axes.forEach(axis => {
const row = `<tr class="${axis.toLowerCase()}PID">
<td>${axis}</td>
<td><input type="text" name="p" step="1" min="0" max="255" /></td>
<td><input type="text" name="i" step="1" min="0" max="255" /></td>
<td><input type="text" name="d" step="1" min="0" max="255" /></td>
<td><input type="text" name="dMax" step="1" min="0" max="255" /></td>
<td><input type="text" name="f" step="1" min="0" max="255" /></td>
</tr>`;
pidTbody.innerHTML += row;
});
</script>

<table id="pid_baro_header" class="parameter cf">
<thead>
Expand Down Expand Up @@ -928,8 +888,8 @@ <h5 class="modal-title-revision"></h5>
<label>D gain</label>
<input type="text" step="1" min="0" max="200" />
</td>
<td name="simplified_dmax_gain" class="bf-only">
<label>Dmax</label>
<td name="simplified_d_max_gain" class="bf-only">
<label>D Max</label>
<input type="text" step="1" min="0" max="200" />
</td>
</tr>
Expand Down Expand Up @@ -995,19 +955,19 @@ <h5 class="modal-title-revision"></h5>
</tbody>
</table>

<table id="d_min" class="parameter cf">
<table id="d_max" class="parameter cf">
<thead>
<tr>
<th colspan="5">D Max</th>
</tr>
</thead>
<tbody>
<tr>
<td name="d_min_gain" class="bf-only">
<td name="d_max_gain" class="bf-only">
<label>Gain</label>
<input type="text" step="1" min="0" max="100" />
</td>
<td name="d_min_advance" class="bf-only">
<td name="d_max_advance" class="bf-only">
<label>Advance</label>
<input type="text" step="1" min="0" max="200" />
</td>
Expand Down
11 changes: 5 additions & 6 deletions src/flightlog_fielddefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ export const DEBUG_MODE_COMPLETE = makeReadOnly([
"RX_SPECTRUM_SPI",
"DSHOT_RPM_TELEMETRY",
"RPM_FILTER",
"D_MIN",
"D_MAX",
"AC_CORRECTION",
"AC_ERROR",
"DUAL_GYRO_SCALED",
Expand Down Expand Up @@ -520,13 +520,12 @@ export function adjustFieldDefsList(firmwareType, firmwareVersion) {
DEBUG_MODE.splice(DEBUG_MODE.indexOf("DUAL_GYRO_COMBINED"), 1);
}
if (semver.gte(firmwareVersion, "4.3.0")) {
DEBUG_MODE.splice(
DEBUG_MODE.indexOf("FF_INTERPOLATED"),
1,
"FEEDFORWARD"
);
DEBUG_MODE.splice(DEBUG_MODE.indexOf("FF_INTERPOLATED"), 1, "FEEDFORWARD");
DEBUG_MODE.splice(DEBUG_MODE.indexOf("FF_LIMIT"), 1, "FEEDFORWARD_LIMIT");
}
if (semver.lt(firmwareVersion, "4.6.0")) {
DEBUG_MODE.splice(DEBUG_MODE.indexOf("D_MAX"), 1, "D_MIN");
}

DEBUG_MODE = makeReadOnly(DEBUG_MODE);

Expand Down
8 changes: 4 additions & 4 deletions src/flightlog_fields_presenter.js
Original file line number Diff line number Diff line change
Expand Up @@ -695,8 +695,8 @@ const DEBUG_FRIENDLY_FIELD_NAMES_INITIAL = {
"debug[6]": "Not Used",
"debug[7]": "Not Used",
},
D_MIN: {
"debug[all]": "D_MIN",
D_MAX: {
"debug[all]": "D_MAX",
"debug[0]": "Gyro Factor [roll]",
"debug[1]": "Setpoint Factor [roll]",
"debug[2]": "Actual D [roll]",
Expand Down Expand Up @@ -1850,7 +1850,7 @@ FlightLogFieldPresenter.decodeDebugFieldToFriendly = function (
).toFixed(0)} hz`;
case "RPM_FILTER":
return `${(value * 60).toFixed(0)}rpm / ${value.toFixed(0)} Hz`;
case "D_MIN":
case "D_MAX":
switch (fieldName) {
case "debug[0]": // roll gyro factor
case "debug[1]": // roll setpoint Factor
Expand Down Expand Up @@ -2506,7 +2506,7 @@ FlightLogFieldPresenter.ConvertDebugFieldValue = function (
return toFriendly ? (value * 200) / pole : (value * pole) / 200;
case "RPM_FILTER":
return toFriendly ? value * 60 : value / 60;
case "D_MIN":
case "D_MAX":
switch (fieldName) {
case "debug[0]": // roll gyro factor
case "debug[1]": // roll setpoint Factor
Expand Down
28 changes: 15 additions & 13 deletions src/flightlog_parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,9 @@ export function FlightLogParser(logData) {
pidSumLimit: null, // PID sum limit
pidSumLimitYaw: null, // PID sum limit yaw
use_integrated_yaw: null, // Use integrated yaw
d_min: [null, null, null], // D_Min [P, I, D]
d_min_gain: null, // D_Min gain - D_Max in 4.3
d_min_advance: null, // D_Min advance - D_Max in 4.3
d_max: [null, null, null], // D_MAX [ROLL, PITCH, YAW]
d_max_gain: null, // D_MAX gain
d_max_advance: null, // D_MAX advance
iterm_relax: null, // ITerm Relax mode
iterm_relax_type: null, // ITerm Relax type
iterm_relax_cutoff: null, // ITerm Relax cutoff
Expand Down Expand Up @@ -326,7 +326,7 @@ export function FlightLogParser(logData) {
simplified_pi_gain: null,
simplified_i_gain: null,
simplified_d_gain: null,
simplified_dmax_gain: null,
simplified_d_max_gain: null,
simplified_feedforward_gain: null,
simplified_pitch_d_gain: null,
simplified_pitch_pi_gain: null,
Expand Down Expand Up @@ -370,8 +370,8 @@ export function FlightLogParser(logData) {
dterm_lpf2_static_hz: "dterm_lpf2_hz",
dterm_setpoint_weight: "dtermSetpointWeight",
digital_idle_value: "digitalIdleOffset",
d_max_gain: "d_min_gain",
d_max_advance: "d_min_advance",
simplified_dmax_gain: "simplified_d_max_gain",
d_max: "d_min",
dshot_idle_value: "digitalIdleOffset",
dyn_idle_min_rpm: "dynamic_idle_min_rpm",
feedforward_transition: "ff_transition",
Expand Down Expand Up @@ -696,8 +696,8 @@ export function FlightLogParser(logData) {
case "anti_gravity_cutoff_hz":
case "abs_control_gain":
case "use_integrated_yaw":
case "d_min_gain":
case "d_min_advance":
case "d_max_gain":
case "d_max_advance":
case "dshot_bidir":
case "gyro_rpm_notch_harmonics":
case "gyro_rpm_notch_q":
Expand Down Expand Up @@ -732,6 +732,7 @@ export function FlightLogParser(logData) {
case "simplified_i_gain":
case "simplified_d_gain":
case "simplified_dmax_gain":
case "simplified_d_max_gain":
case "simplified_feedforward_gain":
case "simplified_pitch_d_gain":
case "simplified_pitch_pi_gain":
Expand Down Expand Up @@ -869,11 +870,12 @@ export function FlightLogParser(logData) {
that.sysConfig.magPID = parseCommaSeparatedString(fieldValue, 3); //[parseInt(fieldValue, 10), null, null];
break;
case "d_min":
// Add Dmin values as Derivative numbers to PID array
var dMinValues = parseCommaSeparatedString(fieldValue);
that.sysConfig["rollPID"].push(dMinValues[0]);
that.sysConfig["pitchPID"].push(dMinValues[1]);
that.sysConfig["yawPID"].push(dMinValues[2]);
case "d_max":
// Add D MAX values as Derivative numbers to PID array
var dMaxValues = parseCommaSeparatedString(fieldValue);
that.sysConfig["rollPID"].push(dMaxValues[0]);
that.sysConfig["pitchPID"].push(dMaxValues[1]);
that.sysConfig["yawPID"].push(dMaxValues[2]);
break;
case "ff_weight":
// Add feedforward values to the PID array
Expand Down
2 changes: 1 addition & 1 deletion src/graph_config.js
Original file line number Diff line number Diff line change
Expand Up @@ -707,7 +707,7 @@ GraphConfig.getDefaultCurveForField = function (flightLog, fieldName) {
"debug[2]",
"debug[3]"
);
case "D_MIN":
case "D_MAX":
switch (fieldName) {
case "debug[0]": // roll gyro factor
case "debug[1]": // roll setpoint Factor
Expand Down
27 changes: 17 additions & 10 deletions src/header_dialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -698,7 +698,7 @@ export function HeaderDialog(dialog, onSave) {
max: "999.9.9",
},
{
name: "simplified_dmax_gain",
name: "simplified_d_max_gain",
type: FIRMWARE_TYPE_BETAFLIGHT,
min: "4.3.0",
max: "999.9.9",
Expand Down Expand Up @@ -1692,24 +1692,31 @@ export function HeaderDialog(dialog, onSave) {
setParameter("rcSmoothingActiveCutoffsThr", "0", 0);
}

// D_MIN and rate_limits
// D_MAX and rate_limits
if (
activeSysConfig.firmwareType == FIRMWARE_TYPE_BETAFLIGHT &&
semver.gte(activeSysConfig.firmwareVersion, "4.0.0")
) {
setParameter("d_min_roll", sysConfig.d_min[0], 0);
setParameter("d_min_pitch", sysConfig.d_min[1], 0);
setParameter("d_min_yaw", sysConfig.d_min[2], 0);
setParameter("d_min_gain", sysConfig.d_min_gain, 0);
setParameter("d_min_advance", sysConfig.d_min_advance, 0);
$("#d_min").show();
setParameter("d_max_roll", sysConfig.d_max[0], 0);
setParameter("d_max_pitch", sysConfig.d_max[1], 0);
setParameter("d_max_yaw", sysConfig.d_max[2], 0);
setParameter("d_max_gain", sysConfig.d_max_gain, 0);
setParameter("d_max_advance", sysConfig.d_max_advance, 0);
$("#d_max").show();

setParameter("rate_limits_roll", sysConfig.rate_limits[0], 0);
setParameter("rate_limits_pitch", sysConfig.rate_limits[1], 0);
setParameter("rate_limits_yaw", sysConfig.rate_limits[2], 0);
$("#rate_limits").show();

if (semver.lt(activeSysConfig.firmwareVersion, "4.6.0")) {
const derivativeColumn = document.getElementById("derivativeColumn");
const dMaxColumn = document.getElementById("dMaxColumn");
const parent = derivativeColumn.parentNode;
parent.insertBefore(dMaxColumn, derivativeColumn); // Меняем местами
}
} else {
$("#d_min").hide();
$("#d_max").hide();
$("#rate_limits").hide();
}

Expand Down Expand Up @@ -1823,7 +1830,7 @@ export function HeaderDialog(dialog, onSave) {
setParameter("simplified_pi_gain", sysConfig.simplified_pi_gain, 0);
setParameter("simplified_i_gain", sysConfig.simplified_i_gain, 0);
setParameter("simplified_d_gain", sysConfig.simplified_d_gain, 0);
setParameter("simplified_dmax_gain", sysConfig.simplified_dmax_gain, 0);
setParameter("simplified_d_max_gain", sysConfig.simplified_d_max_gain, 0);
setParameter(
"simplified_feedforward_gain",
sysConfig.simplified_feedforward_gain,
Expand Down

0 comments on commit 380601b

Please sign in to comment.