Skip to content

Commit

Permalink
Add gov_ff_exponent
Browse files Browse the repository at this point in the history
	100 = angle^1.0
	150 = angle^1.5
  • Loading branch information
pmattila committed Aug 13, 2024
1 parent 01a598b commit 5011519
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/main/cli/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,7 @@ const clivalue_t valueTable[] = {
{ "gov_yaw_ff_weight", VAR_UINT8 | PROFILE_VALUE, .config.minmaxUnsigned = { 0, 250 }, PG_PID_PROFILE, offsetof(pidProfile_t, governor.yaw_ff_weight) },
{ "gov_cyclic_ff_weight", VAR_UINT8 | PROFILE_VALUE, .config.minmaxUnsigned = { 0, 250 }, PG_PID_PROFILE, offsetof(pidProfile_t, governor.cyclic_ff_weight) },
{ "gov_collective_ff_weight", VAR_UINT8 | PROFILE_VALUE, .config.minmaxUnsigned = { 0, 250 }, PG_PID_PROFILE, offsetof(pidProfile_t, governor.collective_ff_weight) },
{ "gov_ff_exponent", VAR_UINT8 | PROFILE_VALUE, .config.minmaxUnsigned = { 0, 250 }, PG_PID_PROFILE, offsetof(pidProfile_t, governor.ff_exponent) },
{ "gov_max_throttle", VAR_UINT8 | PROFILE_VALUE, .config.minmaxUnsigned = { 0, 100 }, PG_PID_PROFILE, offsetof(pidProfile_t, governor.max_throttle) },
{ "gov_min_pid_throttle", VAR_UINT8 | PROFILE_VALUE, .config.minmaxUnsigned = { 0, 100 }, PG_PID_PROFILE, offsetof(pidProfile_t, governor.min_pid_throttle) },

Expand Down
5 changes: 4 additions & 1 deletion src/main/flight/governor.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ typedef struct {
float yawWeight;
float cyclicWeight;
float collectiveWeight;
float FFExponent;
filter_t FFFilter;

// Tail Torque Assist
Expand Down Expand Up @@ -341,7 +342,7 @@ static inline float idleMap(float throttle)

static inline float angleDrag(float angle)
{
return angle * sqrtf(angle); // angle ^ 1.5
return pow_approx(angle, gov.FFExponent);
}

static inline void govChangeState(govState_e futureState)
Expand Down Expand Up @@ -1010,6 +1011,8 @@ void governorInitProfile(const pidProfile_t *pidProfile)
gov.cyclicWeight = pidProfile->governor.cyclic_ff_weight / 100.0f;
gov.collectiveWeight = pidProfile->governor.collective_ff_weight / 100.0f;

gov.FFExponent = pidProfile->governor.ff_exponent / 100.0f;

gov.maxThrottle = pidProfile->governor.max_throttle / 100.0f;
gov.minPIDThrottle = pidProfile->governor.min_pid_throttle / 100.0f;

Expand Down
1 change: 1 addition & 0 deletions src/main/pg/pid.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ void resetPidProfile(pidProfile_t *pidProfile)
.governor.tta_limit = 20,
.governor.cyclic_ff_weight = 40,
.governor.collective_ff_weight = 100,
.governor.ff_exponent = 100,
.governor.max_throttle = 100,
.governor.min_pid_throttle = 30,
);
Expand Down
1 change: 1 addition & 0 deletions src/main/pg/pid.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ typedef struct {
uint8_t yaw_ff_weight;
uint8_t cyclic_ff_weight;
uint8_t collective_ff_weight;
uint8_t ff_exponent;
uint8_t max_throttle;
uint8_t min_pid_throttle;
} governorProfile_t;
Expand Down

0 comments on commit 5011519

Please sign in to comment.