Add in-flight adjustments support for feedforward terms

Renamed/repurposed the "D Setpoint" adjustment to be "Pitch & Roll F Adjustment" and have it simultaneously adjust pitch and roll.

Renamed the "D Setpoint Transition" adjustment to be "Feedforward Transition" - no functionality changes.

Added adjustments for the individual Pitch, Roll and Yaw axes.
This commit is contained in:
Bruce Luckcuck 2018-07-14 20:22:35 -04:00
parent 17e76e48f6
commit a1d3a0dba8
2 changed files with 67 additions and 17 deletions

View File

@ -203,11 +203,11 @@ static const adjustmentConfig_t defaultAdjustmentConfigs[ADJUSTMENT_FUNCTION_COU
.mode = ADJUSTMENT_MODE_STEP, .mode = ADJUSTMENT_MODE_STEP,
.data = { .step = 1 } .data = { .step = 1 }
}, { }, {
.adjustmentFunction = ADJUSTMENT_D_SETPOINT, .adjustmentFunction = ADJUSTMENT_PITCH_ROLL_F,
.mode = ADJUSTMENT_MODE_STEP, .mode = ADJUSTMENT_MODE_STEP,
.data = { .step = 1 } .data = { .step = 1 }
}, { }, {
.adjustmentFunction = ADJUSTMENT_D_SETPOINT_TRANSITION, .adjustmentFunction = ADJUSTMENT_FEEDFORWARD_TRANSITION,
.mode = ADJUSTMENT_MODE_STEP, .mode = ADJUSTMENT_MODE_STEP,
.data = { .step = 1 } .data = { .step = 1 }
}, { }, {
@ -218,6 +218,18 @@ static const adjustmentConfig_t defaultAdjustmentConfigs[ADJUSTMENT_FUNCTION_COU
.adjustmentFunction = ADJUSTMENT_PID_AUDIO, .adjustmentFunction = ADJUSTMENT_PID_AUDIO,
.mode = ADJUSTMENT_MODE_SELECT, .mode = ADJUSTMENT_MODE_SELECT,
.data = { .switchPositions = ARRAYLEN(pidAudioPositionToModeMap) } .data = { .switchPositions = ARRAYLEN(pidAudioPositionToModeMap) }
}, {
.adjustmentFunction = ADJUSTMENT_PITCH_F,
.mode = ADJUSTMENT_MODE_STEP,
.data = { .step = 1 }
}, {
.adjustmentFunction = ADJUSTMENT_ROLL_F,
.mode = ADJUSTMENT_MODE_STEP,
.data = { .step = 1 }
}, {
.adjustmentFunction = ADJUSTMENT_YAW_F,
.mode = ADJUSTMENT_MODE_STEP,
.data = { .step = 1 }
} }
}; };
@ -244,14 +256,17 @@ static const char * const adjustmentLabels[] = {
"ROLL I", "ROLL I",
"ROLL D", "ROLL D",
"RC RATE YAW", "RC RATE YAW",
"D SETPOINT", "PITCH/ROLL F",
"D SETPOINT TRANSITION", "FF TRANSITION",
"HORIZON STRENGTH", "HORIZON STRENGTH",
"ROLL RC RATE", "ROLL RC RATE",
"PITCH RC RATE", "PITCH RC RATE",
"ROLL RC EXPO", "ROLL RC EXPO",
"PITCH RC EXPO", "PITCH RC EXPO",
"PID AUDIO", "PID AUDIO",
"PITCH F",
"ROLL F",
"YAW F"
}; };
static int adjustmentRangeNameIndex = 0; static int adjustmentRangeNameIndex = 0;
@ -405,15 +420,31 @@ static int applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t a
controlRateConfig->rcRates[FD_YAW] = newValue; controlRateConfig->rcRates[FD_YAW] = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_RC_RATE_YAW, newValue); blackboxLogInflightAdjustmentEvent(ADJUSTMENT_RC_RATE_YAW, newValue);
break; break;
case ADJUSTMENT_D_SETPOINT: case ADJUSTMENT_PITCH_ROLL_F:
newValue = constrain((int)pidProfile->pid[PID_ROLL].F + delta, 0, 2000); // FIXME magic numbers repeated in cli.c case ADJUSTMENT_PITCH_F:
newValue = constrain(pidProfile->pid[PID_PITCH].F + delta, 0, 2000);
pidProfile->pid[PID_PITCH].F = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_PITCH_F, newValue);
if (adjustmentFunction == ADJUSTMENT_PITCH_F) {
break;
}
// fall through for combined ADJUSTMENT_PITCH_ROLL_F
FALLTHROUGH;
case ADJUSTMENT_ROLL_F:
newValue = constrain(pidProfile->pid[PID_ROLL].F + delta, 0, 2000);
pidProfile->pid[PID_ROLL].F = newValue; pidProfile->pid[PID_ROLL].F = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_D_SETPOINT, newValue); blackboxLogInflightAdjustmentEvent(ADJUSTMENT_ROLL_F, newValue);
break; break;
case ADJUSTMENT_D_SETPOINT_TRANSITION: case ADJUSTMENT_YAW_F:
newValue = constrain((int)pidProfile->feedForwardTransition + delta, 1, 100); // FIXME magic numbers repeated in cli.c newValue = constrain(pidProfile->pid[PID_YAW].F + delta, 0, 2000);
pidProfile->pid[PID_YAW].F = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_YAW_F, newValue);
break;
case ADJUSTMENT_FEEDFORWARD_TRANSITION:
newValue = constrain(pidProfile->feedForwardTransition + delta, 1, 100); // FIXME magic numbers repeated in cli.c
pidProfile->feedForwardTransition = newValue; pidProfile->feedForwardTransition = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_D_SETPOINT_TRANSITION, newValue); blackboxLogInflightAdjustmentEvent(ADJUSTMENT_FEEDFORWARD_TRANSITION, newValue);
break; break;
default: default:
newValue = -1; newValue = -1;
@ -554,15 +585,31 @@ static int applyAbsoluteAdjustment(controlRateConfig_t *controlRateConfig, adjus
controlRateConfig->rcRates[FD_YAW] = newValue; controlRateConfig->rcRates[FD_YAW] = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_RC_RATE_YAW, newValue); blackboxLogInflightAdjustmentEvent(ADJUSTMENT_RC_RATE_YAW, newValue);
break; break;
case ADJUSTMENT_D_SETPOINT: case ADJUSTMENT_PITCH_ROLL_F:
newValue = constrain(value, 0, 2000); // FIXME magic numbers repeated in cli.c case ADJUSTMENT_PITCH_F:
newValue = constrain(value, 0, 2000);
pidProfile->pid[PID_PITCH].F = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_PITCH_F, newValue);
if (adjustmentFunction == ADJUSTMENT_PITCH_F) {
break;
}
// fall through for combined ADJUSTMENT_PITCH_ROLL_F
FALLTHROUGH;
case ADJUSTMENT_ROLL_F:
newValue = constrain(value, 0, 2000);
pidProfile->pid[PID_ROLL].F = newValue; pidProfile->pid[PID_ROLL].F = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_D_SETPOINT, newValue); blackboxLogInflightAdjustmentEvent(ADJUSTMENT_ROLL_F, newValue);
break; break;
case ADJUSTMENT_D_SETPOINT_TRANSITION: case ADJUSTMENT_YAW_F:
newValue = constrain(value, 0, 2000);
pidProfile->pid[PID_YAW].F = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_YAW_F, newValue);
break;
case ADJUSTMENT_FEEDFORWARD_TRANSITION:
newValue = constrain(value, 1, 100); // FIXME magic numbers repeated in cli.c newValue = constrain(value, 1, 100); // FIXME magic numbers repeated in cli.c
pidProfile->feedForwardTransition = newValue; pidProfile->feedForwardTransition = newValue;
blackboxLogInflightAdjustmentEvent(ADJUSTMENT_D_SETPOINT_TRANSITION, newValue); blackboxLogInflightAdjustmentEvent(ADJUSTMENT_FEEDFORWARD_TRANSITION, newValue);
break; break;
default: default:
newValue = -1; newValue = -1;

View File

@ -47,14 +47,17 @@ typedef enum {
ADJUSTMENT_ROLL_I, ADJUSTMENT_ROLL_I,
ADJUSTMENT_ROLL_D, ADJUSTMENT_ROLL_D,
ADJUSTMENT_RC_RATE_YAW, ADJUSTMENT_RC_RATE_YAW,
ADJUSTMENT_D_SETPOINT, ADJUSTMENT_PITCH_ROLL_F,
ADJUSTMENT_D_SETPOINT_TRANSITION, ADJUSTMENT_FEEDFORWARD_TRANSITION,
ADJUSTMENT_HORIZON_STRENGTH, ADJUSTMENT_HORIZON_STRENGTH,
ADJUSTMENT_ROLL_RC_RATE, ADJUSTMENT_ROLL_RC_RATE,
ADJUSTMENT_PITCH_RC_RATE, ADJUSTMENT_PITCH_RC_RATE,
ADJUSTMENT_ROLL_RC_EXPO, ADJUSTMENT_ROLL_RC_EXPO,
ADJUSTMENT_PITCH_RC_EXPO, ADJUSTMENT_PITCH_RC_EXPO,
ADJUSTMENT_PID_AUDIO, ADJUSTMENT_PID_AUDIO,
ADJUSTMENT_PITCH_F,
ADJUSTMENT_ROLL_F,
ADJUSTMENT_YAW_F,
ADJUSTMENT_FUNCTION_COUNT ADJUSTMENT_FUNCTION_COUNT
} adjustmentFunction_e; } adjustmentFunction_e;