1
0
Fork 0
mirror of https://github.com/iNavFlight/inav.git synced 2025-07-26 01:35:35 +03:00

Merge branch 'releases/release_3.0.0' into avs-ahi-uptilt-compensation-setting

# Conflicts:
#	docs/Settings.md
#	src/main/io/osd.c
This commit is contained in:
Alexander van Saase 2021-05-26 22:40:41 +02:00
commit 72de1e4ed4
6 changed files with 5676 additions and 613 deletions

File diff suppressed because it is too large Load diff

View file

@ -616,21 +616,6 @@ static void pidLevel(pidState_t *pidState, flight_dynamics_index_t axis, float h
DEBUG_SET(DEBUG_AUTOLEVEL, 1, fixedWingLevelTrim * 10);
DEBUG_SET(DEBUG_AUTOLEVEL, 2, getEstimatedActualVelocity(Z));
/*
* fixedWingLevelTrim has opposite sign to rcCommand.
* Positive rcCommand means nose should point downwards
* Negative rcCommand mean nose should point upwards
* This is counter intuitive and a natural way suggests that + should mean UP
* This is why fixedWingLevelTrim has opposite sign to rcCommand
* Positive fixedWingLevelTrim means nose should point upwards
* Negative fixedWingLevelTrim means nose should point downwards
*/
angleTarget -= fixedWingLevelTrim;
DEBUG_SET(DEBUG_AUTOLEVEL, 3, angleTarget * 10);
}
//PITCH trim applied by a AutoLevel flight mode and manual pitch trimming
if (axis == FD_PITCH && STATE(AIRPLANE)) {
/*
* fixedWingLevelTrim has opposite sign to rcCommand.
* Positive rcCommand means nose should point downwards
@ -641,6 +626,7 @@ static void pidLevel(pidState_t *pidState, flight_dynamics_index_t axis, float h
* Negative fixedWingLevelTrim means nose should point downwards
*/
angleTarget -= DEGREES_TO_DECIDEGREES(fixedWingLevelTrim);
DEBUG_SET(DEBUG_AUTOLEVEL, 3, angleTarget * 10);
}
#ifdef USE_SECONDARY_IMU
@ -795,7 +781,7 @@ static void NOINLINE pidApplyFixedWingRateController(pidState_t *pidState, fligh
pidState->errorGyroIf = constrainf(pidState->errorGyroIf, -pidProfile()->fixedWingItermThrowLimit, pidProfile()->fixedWingItermThrowLimit);
}
axisPID[axis] = constrainf(newPTerm + newFFTerm + pidState->errorGyroIf, -pidState->pidSumLimit, +pidState->pidSumLimit);
axisPID[axis] = constrainf(newPTerm + newFFTerm + pidState->errorGyroIf + newDTerm, -pidState->pidSumLimit, +pidState->pidSumLimit);
#ifdef USE_AUTOTUNE_FIXED_WING
if (FLIGHT_MODE(AUTO_TUNE) && !FLIGHT_MODE(MANUAL_MODE)) {
@ -1327,11 +1313,16 @@ void updateFixedWingLevelTrim(timeUs_t currentTimeUs)
*/
pidControllerFlags_e flags = PID_LIMIT_INTEGRATOR;
//Iterm should freeze when pitch stick is deflected
//Iterm should freeze when sticks are deflected
bool areSticksDeflected = false;
for (int stick = ROLL; stick <= YAW; stick++) {
areSticksDeflected = areSticksDeflected ||
rxGetChannelValue(stick) > (PWM_RANGE_MIDDLE + pidProfile()->fixedWingLevelTrimDeadband) ||
rxGetChannelValue(stick) < (PWM_RANGE_MIDDLE - pidProfile()->fixedWingLevelTrimDeadband);
}
if (
!IS_RC_MODE_ACTIVE(BOXAUTOLEVEL) ||
rxGetChannelValue(PITCH) > (PWM_RANGE_MIDDLE + pidProfile()->fixedWingLevelTrimDeadband) ||
rxGetChannelValue(PITCH) < (PWM_RANGE_MIDDLE - pidProfile()->fixedWingLevelTrimDeadband) ||
areSticksDeflected ||
(!FLIGHT_MODE(ANGLE_MODE) && !FLIGHT_MODE(HORIZON_MODE)) ||
navigationIsControllingAltitude()
) {
@ -1355,3 +1346,8 @@ void updateFixedWingLevelTrim(timeUs_t currentTimeUs)
previousArmingState = !!ARMING_FLAG(ARMED);
}
float getFixedWingLevelTrim(void)
{
return STATE(AIRPLANE) ? fixedWingLevelTrim : 0;
}

View file

@ -233,3 +233,4 @@ void autotuneFixedWingUpdate(const flight_dynamics_index_t axis, float desiredRa
pidType_e pidIndexGetType(pidIndex_e pidIndex);
void updateFixedWingLevelTrim(timeUs_t currentTimeUs);
float getFixedWingLevelTrim(void);

View file

@ -2031,6 +2031,7 @@ static bool osdDrawSingleElement(uint8_t item)
pitchAngle = DECIDEGREES_TO_RADIANS(attitude.values.pitch);
#endif
pitchAngle -= osdConfig()->ahi_camera_uptilt_comp ? DEGREES_TO_RADIANS(osdConfig()->camera_uptilt) : 0;
pitchAngle += DEGREES_TO_RADIANS(getFixedWingLevelTrim());
if (osdConfig()->ahi_reverse_roll) {
rollAngle = -rollAngle;
}
@ -2985,17 +2986,17 @@ void pgResetFn_osdLayoutsConfig(osdLayoutsConfig_t *osdLayoutsConfig)
// OSD_VARIO_NUM at the right of OSD_VARIO
osdLayoutsConfig->item_pos[0][OSD_VARIO_NUM] = OSD_POS(24, 7);
osdLayoutsConfig->item_pos[0][OSD_HOME_DIR] = OSD_POS(14, 11);
osdLayoutsConfig->item_pos[0][OSD_ARTIFICIAL_HORIZON] = OSD_POS(8, 6) | OSD_VISIBLE_FLAG;
osdLayoutsConfig->item_pos[0][OSD_HORIZON_SIDEBARS] = OSD_POS(8, 6) | OSD_VISIBLE_FLAG;
osdLayoutsConfig->item_pos[0][OSD_ARTIFICIAL_HORIZON] = OSD_POS(8, 6);
osdLayoutsConfig->item_pos[0][OSD_HORIZON_SIDEBARS] = OSD_POS(8, 6);
osdLayoutsConfig->item_pos[0][OSD_CRAFT_NAME] = OSD_POS(20, 2);
osdLayoutsConfig->item_pos[0][OSD_VTX_CHANNEL] = OSD_POS(8, 6);
#ifdef USE_SERIALRX_CRSF
osdLayoutsConfig->item_pos[0][OSD_CRSF_RSSI_DBM] = OSD_POS(24, 12);
osdLayoutsConfig->item_pos[0][OSD_CRSF_LQ] = OSD_POS(24, 11);
osdLayoutsConfig->item_pos[0][OSD_CRSF_SNR_DB] = OSD_POS(25, 9);
osdLayoutsConfig->item_pos[0][OSD_CRSF_TX_POWER] = OSD_POS(25, 10);
osdLayoutsConfig->item_pos[0][OSD_CRSF_RSSI_DBM] = OSD_POS(23, 12);
osdLayoutsConfig->item_pos[0][OSD_CRSF_LQ] = OSD_POS(23, 11);
osdLayoutsConfig->item_pos[0][OSD_CRSF_SNR_DB] = OSD_POS(24, 9);
osdLayoutsConfig->item_pos[0][OSD_CRSF_TX_POWER] = OSD_POS(24, 10);
#endif
osdLayoutsConfig->item_pos[0][OSD_ONTIME] = OSD_POS(23, 8);

View file

@ -502,8 +502,9 @@ void mavlinkSendRCChannelsAndRSSI(void)
GET_CHANNEL_VALUE(6),
// chan8_raw RC channel 8 value, in microseconds
GET_CHANNEL_VALUE(7),
// rssi Receive signal strength indicator, 0: 0%, 255: 100%
scaleRange(getRSSI(), 0, 1023, 0, 255));
// rssi Receive signal strength indicator, 0: 0%, 254: 100%
//https://github.com/mavlink/mavlink/issues/1027
scaleRange(getRSSI(), 0, 1023, 0, 254));
#undef GET_CHANNEL_VALUE
mavlinkSendMessage();

View file

@ -38,7 +38,7 @@ def parse_settings_yaml():
with open(SETTINGS_YAML_PATH, "r") as settings_yaml:
return yaml.load(settings_yaml, Loader=yaml.Loader)
def generate_md_table_from_yaml(settings_yaml):
def generate_md_from_yaml(settings_yaml):
"""Generate a sorted markdown table with description & default value for each setting"""
params = {}
@ -84,20 +84,19 @@ def generate_md_table_from_yaml(settings_yaml):
"max": member["max"] if "max" in member else ""
}
# MD table header
md_table_lines = [
"| Variable Name | Default Value | Min | Max | Description |\n",
"| ------------- | ------------- | --- | --- | ----------- |\n",
]
# Sort the settings by name and build the rows of the table
# Sort the settings by name and build the doc
output_lines = []
for param in sorted(params.items()):
md_table_lines.append("| {} | {} | {} | {} | {} |\n".format(
param[0], param[1]['default'], param[1]['min'], param[1]['max'], param[1]['description']
))
output_lines.extend([
f"### {param[0]}\n\n",
f"{param[1]['description'] if param[1]['description'] else '_// TODO_'}\n\n",
"| Default | Min | Max |\n| --- | --- | --- |\n",
f"| {param[1]['default']} | {param[1]['min']} | {param[1]['max']} |\n\n",
"---\n\n"
])
# Return the assembled table
return md_table_lines
# Return the assembled doc body
return output_lines
def write_settings_md(lines):
"""Write the contents of the CLI settings docs"""
@ -185,9 +184,9 @@ if __name__ == "__main__":
defaults_match = check_defaults(settings_yaml)
quit(0 if defaults_match else 1)
md_table_lines = generate_md_table_from_yaml(settings_yaml)
settings_md_lines = \
["# CLI Variable Reference\n", "\n" ] + \
md_table_lines + \
["\n", "> Note: this table is autogenerated. Do not edit it manually."]
write_settings_md(settings_md_lines)
output_lines = generate_md_from_yaml(settings_yaml)
output_lines = [
"# CLI Variable Reference\n\n",
"> Note: this document is autogenerated. Do not edit it manually.\n\n"
] + output_lines
write_settings_md(output_lines)