Refactor rate limit
This commit is contained in:
parent
cb72f0a6d6
commit
81c06ace92
|
@ -245,8 +245,8 @@ static void resetPidProfile(pidProfile_t *pidProfile)
|
||||||
// Betaflight PID controller parameters
|
// Betaflight PID controller parameters
|
||||||
pidProfile->ptermSetpointWeight = 75;
|
pidProfile->ptermSetpointWeight = 75;
|
||||||
pidProfile->dtermSetpointWeight = 120;
|
pidProfile->dtermSetpointWeight = 120;
|
||||||
pidProfile->pidMaxVelocityYaw = 220;
|
pidProfile->yawRateAccelLimit = 220;
|
||||||
pidProfile->pidMaxVelocityRollPitch = 0;
|
pidProfile->rateAccelLimit = 0;
|
||||||
pidProfile->toleranceBand = 15;
|
pidProfile->toleranceBand = 15;
|
||||||
pidProfile->toleranceBandReduction = 40;
|
pidProfile->toleranceBandReduction = 40;
|
||||||
pidProfile->zeroCrossAllowanceCount = 2;
|
pidProfile->zeroCrossAllowanceCount = 2;
|
||||||
|
|
|
@ -187,8 +187,8 @@ static void pidBetaflight(const pidProfile_t *pidProfile, uint16_t max_angle_inc
|
||||||
Kd[axis] = DTERM_SCALE * pidProfile->D8[axis];
|
Kd[axis] = DTERM_SCALE * pidProfile->D8[axis];
|
||||||
b[axis] = pidProfile->ptermSetpointWeight / 100.0f;
|
b[axis] = pidProfile->ptermSetpointWeight / 100.0f;
|
||||||
c[axis] = pidProfile->dtermSetpointWeight / 100.0f;
|
c[axis] = pidProfile->dtermSetpointWeight / 100.0f;
|
||||||
yawMaxVelocity = pidProfile->pidMaxVelocityYaw * 1000 * getdT();
|
yawMaxVelocity = pidProfile->yawRateAccelLimit * 1000 * getdT();
|
||||||
rollPitchMaxVelocity = pidProfile->pidMaxVelocityRollPitch * 1000 * getdT();
|
rollPitchMaxVelocity = pidProfile->rateAccelLimit * 1000 * getdT();
|
||||||
|
|
||||||
configP[axis] = pidProfile->P8[axis];
|
configP[axis] = pidProfile->P8[axis];
|
||||||
configI[axis] = pidProfile->I8[axis];
|
configI[axis] = pidProfile->I8[axis];
|
||||||
|
|
|
@ -100,8 +100,8 @@ typedef struct pidProfile_s {
|
||||||
uint8_t itermThrottleGain; // Throttle coupling to iterm. Quick throttle changes will bump iterm
|
uint8_t itermThrottleGain; // Throttle coupling to iterm. Quick throttle changes will bump iterm
|
||||||
uint8_t ptermSetpointWeight; // Setpoint weight for Pterm (lower means more PV tracking)
|
uint8_t ptermSetpointWeight; // Setpoint weight for Pterm (lower means more PV tracking)
|
||||||
uint8_t dtermSetpointWeight; // Setpoint weight for Dterm (0= measurement, 1= full error, 1 > agressive derivative)
|
uint8_t dtermSetpointWeight; // Setpoint weight for Dterm (0= measurement, 1= full error, 1 > agressive derivative)
|
||||||
uint16_t pidMaxVelocityYaw; // velocity yaw limiter for pid controller deg/sec/ms
|
uint16_t yawRateAccelLimit; // yaw accel limiter for deg/sec/ms
|
||||||
uint16_t pidMaxVelocityRollPitch; // velocity roll/pitch limiter for pid controller deg/sec/ms
|
uint16_t rateAccelLimit; // accel limiter roll/pitch deg/sec/ms
|
||||||
|
|
||||||
#ifdef GTUNE
|
#ifdef GTUNE
|
||||||
uint8_t gtune_lolimP[3]; // [0..200] Lower limit of P during G tune
|
uint8_t gtune_lolimP[3]; // [0..200] Lower limit of P during G tune
|
||||||
|
|
|
@ -832,8 +832,8 @@ const clivalue_t valueTable[] = {
|
||||||
{ "iterm_throttle_gain", VAR_UINT8 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.itermThrottleGain, .config.minmax = {0, 200 } },
|
{ "iterm_throttle_gain", VAR_UINT8 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.itermThrottleGain, .config.minmax = {0, 200 } },
|
||||||
{ "pterm_setpoint_weight", VAR_UINT8 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.ptermSetpointWeight, .config.minmax = {30, 100 } },
|
{ "pterm_setpoint_weight", VAR_UINT8 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.ptermSetpointWeight, .config.minmax = {30, 100 } },
|
||||||
{ "dterm_setpoint_weight", VAR_UINT8 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.dtermSetpointWeight, .config.minmax = {0, 200 } },
|
{ "dterm_setpoint_weight", VAR_UINT8 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.dtermSetpointWeight, .config.minmax = {0, 200 } },
|
||||||
{ "max_yaw_acceleration", VAR_UINT16 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.pidMaxVelocityYaw, .config.minmax = {0, 1000 } },
|
{ "yaw_rate_acceleration_limit",VAR_UINT16 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.yawRateAccelLimit, .config.minmax = {0, 1000 } },
|
||||||
{ "max_acceleration", VAR_UINT16 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.pidMaxVelocityRollPitch, .config.minmax = {0, 1000 } },
|
{ "rate_acceleration_limit", VAR_UINT16 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.rateAccelLimit, .config.minmax = {0, 1000 } },
|
||||||
|
|
||||||
{ "iterm_ignore_threshold", VAR_UINT16 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.rollPitchItermIgnoreRate, .config.minmax = {15, 1000 } },
|
{ "iterm_ignore_threshold", VAR_UINT16 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.rollPitchItermIgnoreRate, .config.minmax = {15, 1000 } },
|
||||||
{ "yaw_iterm_ignore_threshold", VAR_UINT16 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.yawItermIgnoreRate, .config.minmax = {15, 1000 } },
|
{ "yaw_iterm_ignore_threshold", VAR_UINT16 | PROFILE_VALUE, &masterConfig.profile[0].pidProfile.yawItermIgnoreRate, .config.minmax = {15, 1000 } },
|
||||||
|
|
|
@ -1268,8 +1268,8 @@ static bool processOutCommand(uint8_t cmdMSP)
|
||||||
serialize8(currentProfile->pidProfile.toleranceBand);
|
serialize8(currentProfile->pidProfile.toleranceBand);
|
||||||
serialize8(currentProfile->pidProfile.toleranceBandReduction);
|
serialize8(currentProfile->pidProfile.toleranceBandReduction);
|
||||||
serialize8(currentProfile->pidProfile.itermThrottleGain);
|
serialize8(currentProfile->pidProfile.itermThrottleGain);
|
||||||
serialize16(currentProfile->pidProfile.pidMaxVelocityRollPitch);
|
serialize16(currentProfile->pidProfile.rateAccelLimit);
|
||||||
serialize16(currentProfile->pidProfile.pidMaxVelocityYaw);
|
serialize16(currentProfile->pidProfile.yawRateAccelLimit);
|
||||||
break;
|
break;
|
||||||
case MSP_SENSOR_CONFIG:
|
case MSP_SENSOR_CONFIG:
|
||||||
headSerialReply(3);
|
headSerialReply(3);
|
||||||
|
@ -1858,8 +1858,8 @@ static bool processInCommand(void)
|
||||||
currentProfile->pidProfile.toleranceBand = read8();
|
currentProfile->pidProfile.toleranceBand = read8();
|
||||||
currentProfile->pidProfile.toleranceBandReduction = read8();
|
currentProfile->pidProfile.toleranceBandReduction = read8();
|
||||||
currentProfile->pidProfile.itermThrottleGain = read8();
|
currentProfile->pidProfile.itermThrottleGain = read8();
|
||||||
currentProfile->pidProfile.pidMaxVelocityRollPitch = read16();
|
currentProfile->pidProfile.rateAccelLimit = read16();
|
||||||
currentProfile->pidProfile.pidMaxVelocityYaw = read16();
|
currentProfile->pidProfile.yawRateAccelLimit = read16();
|
||||||
break;
|
break;
|
||||||
case MSP_SET_SENSOR_CONFIG:
|
case MSP_SET_SENSOR_CONFIG:
|
||||||
masterConfig.acc_hardware = read8();
|
masterConfig.acc_hardware = read8();
|
||||||
|
|
Loading…
Reference in New Issue