Apply the same maximum control rates (1.0) in CLI and MSP
Previously it was possible to set roll/pitch rate > 1.0 using MSP, but not using the CLI. Roll/pitch rate > 1.0 is meaningless. TPA is also limited to 1.0.
This commit is contained in:
parent
bcadd0803a
commit
828ec550cd
|
@ -407,18 +407,18 @@ void applyStepAdjustment(controlRateConfig_t *controlRateConfig, uint8_t adjustm
|
||||||
case ADJUSTMENT_PITCH_ROLL_RATE:
|
case ADJUSTMENT_PITCH_ROLL_RATE:
|
||||||
case ADJUSTMENT_PITCH_RATE:
|
case ADJUSTMENT_PITCH_RATE:
|
||||||
newValue = (int)controlRateConfig->rates[FD_PITCH] + delta;
|
newValue = (int)controlRateConfig->rates[FD_PITCH] + delta;
|
||||||
controlRateConfig->rates[FD_PITCH] = constrain(newValue, 0, 100); // FIXME magic numbers repeated in serial_cli.c
|
controlRateConfig->rates[FD_PITCH] = constrain(newValue, 0, CONTROL_RATE_CONFIG_ROLL_PITCH_RATE_MAX);
|
||||||
if (adjustmentFunction == ADJUSTMENT_PITCH_RATE) {
|
if (adjustmentFunction == ADJUSTMENT_PITCH_RATE) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// follow though for combined ADJUSTMENT_PITCH_ROLL_RATE
|
// follow though for combined ADJUSTMENT_PITCH_ROLL_RATE
|
||||||
case ADJUSTMENT_ROLL_RATE:
|
case ADJUSTMENT_ROLL_RATE:
|
||||||
newValue = (int)controlRateConfig->rates[FD_ROLL] + delta;
|
newValue = (int)controlRateConfig->rates[FD_ROLL] + delta;
|
||||||
controlRateConfig->rates[FD_ROLL] = constrain(newValue, 0, 100); // FIXME magic numbers repeated in serial_cli.c
|
controlRateConfig->rates[FD_ROLL] = constrain(newValue, 0, CONTROL_RATE_CONFIG_ROLL_PITCH_RATE_MAX);
|
||||||
break;
|
break;
|
||||||
case ADJUSTMENT_YAW_RATE:
|
case ADJUSTMENT_YAW_RATE:
|
||||||
newValue = (int)controlRateConfig->rates[FD_YAW] + delta;
|
newValue = (int)controlRateConfig->rates[FD_YAW] + delta;
|
||||||
controlRateConfig->rates[FD_YAW] = constrain(newValue, 0, 100); // FIXME magic numbers repeated in serial_cli.c
|
controlRateConfig->rates[FD_YAW] = constrain(newValue, 0, CONTROL_RATE_CONFIG_YAW_RATE_MAX);
|
||||||
break;
|
break;
|
||||||
case ADJUSTMENT_PITCH_ROLL_P:
|
case ADJUSTMENT_PITCH_ROLL_P:
|
||||||
if (IS_PID_CONTROLLER_FP_BASED(pidProfile->pidController)) {
|
if (IS_PID_CONTROLLER_FP_BASED(pidProfile->pidController)) {
|
||||||
|
|
|
@ -100,6 +100,16 @@ typedef enum {
|
||||||
#define MIN_MODE_RANGE_STEP 0
|
#define MIN_MODE_RANGE_STEP 0
|
||||||
#define MAX_MODE_RANGE_STEP ((CHANNEL_RANGE_MAX - CHANNEL_RANGE_MIN) / 25)
|
#define MAX_MODE_RANGE_STEP ((CHANNEL_RANGE_MAX - CHANNEL_RANGE_MIN) / 25)
|
||||||
|
|
||||||
|
// Roll/pitch rates are a proportion used for mixing, so it tops out at 1.0:
|
||||||
|
#define CONTROL_RATE_CONFIG_ROLL_PITCH_RATE_MAX 100
|
||||||
|
|
||||||
|
/* Meaningful yaw rates are effectively unbounded because they are treated as a rotation rate multiplier,
|
||||||
|
* but we'll limit it to 1.0:
|
||||||
|
*/
|
||||||
|
#define CONTROL_RATE_CONFIG_YAW_RATE_MAX 100
|
||||||
|
|
||||||
|
#define CONTROL_RATE_CONFIG_TPA_MAX 100
|
||||||
|
|
||||||
// steps are 25 apart
|
// steps are 25 apart
|
||||||
// a value of 0 corresponds to a channel value of 900 or less
|
// a value of 0 corresponds to a channel value of 900 or less
|
||||||
// a value of 48 corresponds to a channel value of 2100 or more
|
// a value of 48 corresponds to a channel value of 2100 or more
|
||||||
|
|
|
@ -397,10 +397,10 @@ const clivalue_t valueTable[] = {
|
||||||
{ "rc_expo", VAR_UINT8 | CONTROL_RATE_VALUE, &masterConfig.controlRateProfiles[0].rcExpo8, 0, 100 },
|
{ "rc_expo", VAR_UINT8 | CONTROL_RATE_VALUE, &masterConfig.controlRateProfiles[0].rcExpo8, 0, 100 },
|
||||||
{ "thr_mid", VAR_UINT8 | CONTROL_RATE_VALUE, &masterConfig.controlRateProfiles[0].thrMid8, 0, 100 },
|
{ "thr_mid", VAR_UINT8 | CONTROL_RATE_VALUE, &masterConfig.controlRateProfiles[0].thrMid8, 0, 100 },
|
||||||
{ "thr_expo", VAR_UINT8 | CONTROL_RATE_VALUE, &masterConfig.controlRateProfiles[0].thrExpo8, 0, 100 },
|
{ "thr_expo", VAR_UINT8 | CONTROL_RATE_VALUE, &masterConfig.controlRateProfiles[0].thrExpo8, 0, 100 },
|
||||||
{ "roll_rate", VAR_UINT8 | CONTROL_RATE_VALUE, &masterConfig.controlRateProfiles[0].rates[FD_ROLL], 0, 100 },
|
{ "roll_rate", VAR_UINT8 | CONTROL_RATE_VALUE, &masterConfig.controlRateProfiles[0].rates[FD_ROLL], 0, CONTROL_RATE_CONFIG_ROLL_PITCH_RATE_MAX },
|
||||||
{ "pitch_rate", VAR_UINT8 | CONTROL_RATE_VALUE, &masterConfig.controlRateProfiles[0].rates[FD_PITCH], 0, 100 },
|
{ "pitch_rate", VAR_UINT8 | CONTROL_RATE_VALUE, &masterConfig.controlRateProfiles[0].rates[FD_PITCH], 0, CONTROL_RATE_CONFIG_ROLL_PITCH_RATE_MAX },
|
||||||
{ "yaw_rate", VAR_UINT8 | CONTROL_RATE_VALUE, &masterConfig.controlRateProfiles[0].rates[FD_YAW], 0, 100 },
|
{ "yaw_rate", VAR_UINT8 | CONTROL_RATE_VALUE, &masterConfig.controlRateProfiles[0].rates[FD_YAW], 0, CONTROL_RATE_CONFIG_YAW_RATE_MAX },
|
||||||
{ "tpa_rate", VAR_UINT8 | CONTROL_RATE_VALUE, &masterConfig.controlRateProfiles[0].dynThrPID, 0, 100},
|
{ "tpa_rate", VAR_UINT8 | CONTROL_RATE_VALUE, &masterConfig.controlRateProfiles[0].dynThrPID, 0, CONTROL_RATE_CONFIG_TPA_MAX},
|
||||||
{ "tpa_breakpoint", VAR_UINT16 | CONTROL_RATE_VALUE, &masterConfig.controlRateProfiles[0].tpa_breakpoint, PWM_RANGE_MIN, PWM_RANGE_MAX},
|
{ "tpa_breakpoint", VAR_UINT16 | CONTROL_RATE_VALUE, &masterConfig.controlRateProfiles[0].tpa_breakpoint, PWM_RANGE_MIN, PWM_RANGE_MAX},
|
||||||
|
|
||||||
{ "failsafe_delay", VAR_UINT8 | PROFILE_VALUE, &masterConfig.profile[0].failsafeConfig.failsafe_delay, 0, 200 },
|
{ "failsafe_delay", VAR_UINT8 | PROFILE_VALUE, &masterConfig.profile[0].failsafeConfig.failsafe_delay, 0, 200 },
|
||||||
|
|
|
@ -1331,9 +1331,9 @@ static bool processInCommand(void)
|
||||||
currentControlRateProfile->rcRate8 = read8();
|
currentControlRateProfile->rcRate8 = read8();
|
||||||
currentControlRateProfile->rcExpo8 = read8();
|
currentControlRateProfile->rcExpo8 = read8();
|
||||||
for (i = 0; i < 3; i++) {
|
for (i = 0; i < 3; i++) {
|
||||||
currentControlRateProfile->rates[i] = read8();
|
currentControlRateProfile->rates[i] = MIN(read8(), i == FD_YAW ? CONTROL_RATE_CONFIG_YAW_RATE_MAX : CONTROL_RATE_CONFIG_ROLL_PITCH_RATE_MAX);
|
||||||
}
|
}
|
||||||
currentControlRateProfile->dynThrPID = read8();
|
currentControlRateProfile->dynThrPID = MIN(read8(), CONTROL_RATE_CONFIG_TPA_MAX);
|
||||||
currentControlRateProfile->thrMid8 = read8();
|
currentControlRateProfile->thrMid8 = read8();
|
||||||
currentControlRateProfile->thrExpo8 = read8();
|
currentControlRateProfile->thrExpo8 = read8();
|
||||||
currentControlRateProfile->tpa_breakpoint = read16();
|
currentControlRateProfile->tpa_breakpoint = read16();
|
||||||
|
|
Loading…
Reference in New Issue