Skip to content

Commit

Permalink
Negative Variable Tiltback configured by negative rate
Browse files Browse the repository at this point in the history
Fix: Configure negative Variable Tiltback via negative rate, not maximum
 >
 This will cause negative Variable Tiltback configured through the
 maximum to disappear. In such case users need to configure it again.
  • Loading branch information
lukash committed Dec 25, 2024
1 parent 4021580 commit 9dbee3e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 20 deletions.
4 changes: 2 additions & 2 deletions src/conf/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -809,7 +809,7 @@ p, li { white-space: pre-wrap; }
<editorScale>1</editorScale>
<editAsPercentage>0</editAsPercentage>
<maxDouble>5</maxDouble>
<minDouble>0</minDouble>
<minDouble>-5</minDouble>
<showDisplay>0</showDisplay>
<stepDouble>0.05</stepDouble>
<valDouble>0.1</valDouble>
Expand All @@ -831,7 +831,7 @@ p, li { white-space: pre-wrap; }
<editorScale>1</editorScale>
<editAsPercentage>0</editAsPercentage>
<maxDouble>20</maxDouble>
<minDouble>-20</minDouble>
<minDouble>0</minDouble>
<showDisplay>0</showDisplay>
<stepDouble>0.5</stepDouble>
<valDouble>0</valDouble>
Expand Down
25 changes: 7 additions & 18 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -265,14 +265,9 @@ static void reconfigure(data *d) {
d->startup_step_size = d->float_conf.startup_speed / d->float_conf.hertz;
d->noseangling_step_size = d->float_conf.noseangling_speed / d->float_conf.hertz;
d->startup_pitch_trickmargin = d->float_conf.startup_dirtylandings_enabled ? 10 : 0;

d->tiltback_variable = d->float_conf.tiltback_variable / 1000;
if (d->tiltback_variable > 0) {
d->tiltback_variable_max_erpm =
fabsf(d->float_conf.tiltback_variable_max / d->tiltback_variable);
} else {
d->tiltback_variable_max_erpm = 100000;
}
d->tiltback_variable_max_erpm =
fabsf(d->float_conf.tiltback_variable_max / d->tiltback_variable);

motor_data_configure(&d->motor, d->float_conf.atr_filter / d->float_conf.hertz);
balance_filter_configure(&d->balance_filter, &d->float_conf);
Expand Down Expand Up @@ -853,17 +848,11 @@ static void calculate_setpoint_target(data *d) {
}

static void apply_noseangling(data *d) {
// Nose angle adjustment, add variable then constant tiltback
float noseangling_target = 0;

// Variable Tiltback looks at ERPM from the reference point of the set minimum ERPM
float variable_erpm = fmaxf(0, d->motor.abs_erpm - d->float_conf.tiltback_variable_erpm);
if (variable_erpm > d->tiltback_variable_max_erpm) {
noseangling_target = d->float_conf.tiltback_variable_max * d->motor.erpm_sign;
} else {
noseangling_target = d->tiltback_variable * variable_erpm * d->motor.erpm_sign *
sign(d->float_conf.tiltback_variable_max);
}
// Variable Tiltback: looks at ERPM from the reference point of the set minimum ERPM
float variable_erpm = clampf(
d->motor.abs_erpm - d->float_conf.tiltback_variable_erpm, 0, d->tiltback_variable_max_erpm
);
float noseangling_target = d->tiltback_variable * variable_erpm * d->motor.erpm_sign;

if (d->motor.abs_erpm > d->float_conf.tiltback_constant_erpm) {
noseangling_target += d->float_conf.tiltback_constant * d->motor.erpm_sign;
Expand Down

0 comments on commit 9dbee3e

Please sign in to comment.