mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 04:45:24 +03:00
Allow inflight adjustment of pitch/roll (linked) and yaw PID settings.
This commit is contained in:
parent
7548154d25
commit
2df976409d
3 changed files with 66 additions and 5 deletions
|
@ -70,7 +70,7 @@ void setPIDController(int type); // FIXME PID code needs to be in flight_pid.c/h
|
||||||
void mixerUseConfigs(servoParam_t *servoConfToUse, flight3DConfig_t *flight3DConfigToUse,
|
void mixerUseConfigs(servoParam_t *servoConfToUse, flight3DConfig_t *flight3DConfigToUse,
|
||||||
escAndServoConfig_t *escAndServoConfigToUse, mixerConfig_t *mixerConfigToUse,
|
escAndServoConfig_t *escAndServoConfigToUse, mixerConfig_t *mixerConfigToUse,
|
||||||
airplaneConfig_t *airplaneConfigToUse, rxConfig_t *rxConfig, gimbalConfig_t *gimbalConfigToUse);
|
airplaneConfig_t *airplaneConfigToUse, rxConfig_t *rxConfig, gimbalConfig_t *gimbalConfigToUse);
|
||||||
void useRcControlsConfig(modeActivationCondition_t *modeActivationConditions, escAndServoConfig_t *escAndServoConfigToUse);
|
void useRcControlsConfig(modeActivationCondition_t *modeActivationConditions, escAndServoConfig_t *escAndServoConfigToUse, pidProfile_t *pidProfileToUse);
|
||||||
|
|
||||||
#define FLASH_TO_RESERVE_FOR_CONFIG 0x800
|
#define FLASH_TO_RESERVE_FOR_CONFIG 0x800
|
||||||
|
|
||||||
|
@ -433,7 +433,7 @@ void activateConfig(void)
|
||||||
|
|
||||||
generatePitchRollCurve(¤tProfile->controlRateConfig);
|
generatePitchRollCurve(¤tProfile->controlRateConfig);
|
||||||
generateThrottleCurve(¤tProfile->controlRateConfig, &masterConfig.escAndServoConfig);
|
generateThrottleCurve(¤tProfile->controlRateConfig, &masterConfig.escAndServoConfig);
|
||||||
useRcControlsConfig(currentProfile->modeActivationConditions, &masterConfig.escAndServoConfig);
|
useRcControlsConfig(currentProfile->modeActivationConditions, &masterConfig.escAndServoConfig, ¤tProfile->pidProfile);
|
||||||
|
|
||||||
useGyroConfig(&masterConfig.gyroConfig);
|
useGyroConfig(&masterConfig.gyroConfig);
|
||||||
#ifdef TELEMETRY
|
#ifdef TELEMETRY
|
||||||
|
|
|
@ -47,6 +47,7 @@
|
||||||
#include "io/rc_curves.h"
|
#include "io/rc_curves.h"
|
||||||
|
|
||||||
static escAndServoConfig_t *escAndServoConfig;
|
static escAndServoConfig_t *escAndServoConfig;
|
||||||
|
static pidProfile_t *pidProfile;
|
||||||
|
|
||||||
static bool isUsingSticksToArm = true;
|
static bool isUsingSticksToArm = true;
|
||||||
|
|
||||||
|
@ -289,8 +290,31 @@ static const adjustmentConfig_t defaultAdjustmentConfigs[ADJUSTMENT_FUNCTION_COU
|
||||||
{
|
{
|
||||||
.adjustmentFunction = ADJUSTMENT_YAW_RATE,
|
.adjustmentFunction = ADJUSTMENT_YAW_RATE,
|
||||||
.step = 1
|
.step = 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.adjustmentFunction = ADJUSTMENT_PITCH_ROLL_P,
|
||||||
|
.step = 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.adjustmentFunction = ADJUSTMENT_PITCH_ROLL_I,
|
||||||
|
.step = 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.adjustmentFunction = ADJUSTMENT_PITCH_ROLL_D,
|
||||||
|
.step = 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.adjustmentFunction = ADJUSTMENT_YAW_P,
|
||||||
|
.step = 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.adjustmentFunction = ADJUSTMENT_YAW_I,
|
||||||
|
.step = 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.adjustmentFunction = ADJUSTMENT_YAW_D,
|
||||||
|
.step = 1
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define ADJUSTMENT_FUNCTION_CONFIG_INDEX_OFFSET 1
|
#define ADJUSTMENT_FUNCTION_CONFIG_INDEX_OFFSET 1
|
||||||
|
@ -352,6 +376,36 @@ void applyAdjustment(controlRateConfig_t *controlRateConfig, uint8_t adjustmentF
|
||||||
newValue = (int)controlRateConfig->yawRate + delta;
|
newValue = (int)controlRateConfig->yawRate + delta;
|
||||||
controlRateConfig->yawRate = constrain(newValue, 0, 100); // FIXME magic numbers repeated in serial_cli.c
|
controlRateConfig->yawRate = constrain(newValue, 0, 100); // FIXME magic numbers repeated in serial_cli.c
|
||||||
break;
|
break;
|
||||||
|
case ADJUSTMENT_PITCH_ROLL_P:
|
||||||
|
newValue = (int)pidProfile->P8[PIDPITCH] + delta;
|
||||||
|
pidProfile->P8[PIDPITCH] = constrain(newValue, 0, 200); // FIXME magic numbers repeated in serial_cli.c
|
||||||
|
newValue = (int)pidProfile->P8[PIDROLL] + delta;
|
||||||
|
pidProfile->P8[PIDROLL] = constrain(newValue, 0, 200); // FIXME magic numbers repeated in serial_cli.c
|
||||||
|
break;
|
||||||
|
case ADJUSTMENT_PITCH_ROLL_I:
|
||||||
|
newValue = (int)pidProfile->I8[PIDPITCH] + delta;
|
||||||
|
pidProfile->I8[PIDPITCH] = constrain(newValue, 0, 200); // FIXME magic numbers repeated in serial_cli.c
|
||||||
|
newValue = (int)pidProfile->I8[PIDROLL] + delta;
|
||||||
|
pidProfile->I8[PIDROLL] = constrain(newValue, 0, 200); // FIXME magic numbers repeated in serial_cli.c
|
||||||
|
break;
|
||||||
|
case ADJUSTMENT_PITCH_ROLL_D:
|
||||||
|
newValue = (int)pidProfile->D8[PIDPITCH] + delta;
|
||||||
|
pidProfile->D8[PIDPITCH] = constrain(newValue, 0, 200); // FIXME magic numbers repeated in serial_cli.c
|
||||||
|
newValue = (int)pidProfile->D8[PIDROLL] + delta;
|
||||||
|
pidProfile->D8[PIDROLL] = constrain(newValue, 0, 200); // FIXME magic numbers repeated in serial_cli.c
|
||||||
|
break;
|
||||||
|
case ADJUSTMENT_YAW_P:
|
||||||
|
newValue = (int)pidProfile->P8[PIDYAW] + delta;
|
||||||
|
pidProfile->P8[PIDYAW] = constrain(newValue, 0, 200); // FIXME magic numbers repeated in serial_cli.c
|
||||||
|
break;
|
||||||
|
case ADJUSTMENT_YAW_I:
|
||||||
|
newValue = (int)pidProfile->I8[PIDYAW] + delta;
|
||||||
|
pidProfile->I8[PIDYAW] = constrain(newValue, 0, 200); // FIXME magic numbers repeated in serial_cli.c
|
||||||
|
break;
|
||||||
|
case ADJUSTMENT_YAW_D:
|
||||||
|
newValue = (int)pidProfile->D8[PIDYAW] + delta;
|
||||||
|
pidProfile->D8[PIDYAW] = constrain(newValue, 0, 200); // FIXME magic numbers repeated in serial_cli.c
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
};
|
};
|
||||||
|
@ -420,11 +474,12 @@ void updateAdjustmentStates(adjustmentRange_t *adjustmentRanges)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void useRcControlsConfig(modeActivationCondition_t *modeActivationConditions, escAndServoConfig_t *escAndServoConfigToUse)
|
void useRcControlsConfig(modeActivationCondition_t *modeActivationConditions, escAndServoConfig_t *escAndServoConfigToUse, pidProfile_t *pidProfileToUse)
|
||||||
{
|
{
|
||||||
uint8_t index;
|
uint8_t index;
|
||||||
|
|
||||||
escAndServoConfig = escAndServoConfigToUse;
|
escAndServoConfig = escAndServoConfigToUse;
|
||||||
|
pidProfile = pidProfileToUse;
|
||||||
|
|
||||||
for (index = 0; index < MAX_MODE_ACTIVATION_CONDITION_COUNT; index++) {
|
for (index = 0; index < MAX_MODE_ACTIVATION_CONDITION_COUNT; index++) {
|
||||||
modeActivationCondition_t *modeActivationCondition = &modeActivationConditions[index];
|
modeActivationCondition_t *modeActivationCondition = &modeActivationConditions[index];
|
||||||
|
|
|
@ -140,9 +140,15 @@ typedef enum {
|
||||||
ADJUSTMENT_THROTTLE_EXPO,
|
ADJUSTMENT_THROTTLE_EXPO,
|
||||||
ADJUSTMENT_PITCH_ROLL_RATE,
|
ADJUSTMENT_PITCH_ROLL_RATE,
|
||||||
ADJUSTMENT_YAW_RATE,
|
ADJUSTMENT_YAW_RATE,
|
||||||
|
ADJUSTMENT_PITCH_ROLL_P,
|
||||||
|
ADJUSTMENT_PITCH_ROLL_I,
|
||||||
|
ADJUSTMENT_PITCH_ROLL_D,
|
||||||
|
ADJUSTMENT_YAW_P,
|
||||||
|
ADJUSTMENT_YAW_I,
|
||||||
|
ADJUSTMENT_YAW_D,
|
||||||
} adjustmentFunction_e;
|
} adjustmentFunction_e;
|
||||||
|
|
||||||
#define ADJUSTMENT_FUNCTION_COUNT 6
|
#define ADJUSTMENT_FUNCTION_COUNT 12
|
||||||
|
|
||||||
typedef struct adjustmentConfig_s {
|
typedef struct adjustmentConfig_s {
|
||||||
uint8_t adjustmentFunction;
|
uint8_t adjustmentFunction;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue