Skip to content

Commit

Permalink
Remove the Remote Tiltback Smoothing Factor
Browse files Browse the repository at this point in the history
Feature: The Remote Tiltback Smoothing Factor configuration option has been removed.
 >
 Its default value of 1 is now used for smoothing.
  • Loading branch information
lukash committed Oct 20, 2024
1 parent 577d78f commit a55925f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 67 deletions.
1 change: 0 additions & 1 deletion src/conf/datatypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ typedef struct {
FLOAT_INPUTTILT_REMOTE_TYPE inputtilt_remote_type;
float inputtilt_speed;
float inputtilt_angle_limit;
uint16_t inputtilt_smoothing_factor;
bool inputtilt_invert_throttle;
float inputtilt_deadband;
float remote_throttle_current_max;
Expand Down
27 changes: 0 additions & 27 deletions src/conf/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -948,31 +948,6 @@ p, li { white-space: pre-wrap; }
<suffix> °/s</suffix>
<vTx>7</vTx>
</inputtilt_speed>
<inputtilt_smoothing_factor>
<longName>Tiltback Smoothing Factor</longName>
<type>2</type>
<transmittable>1</transmittable>
<description>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0//EN&quot; &quot;http://www.w3.org/TR/REC-html40/strict.dtd&quot;&gt;
&lt;html&gt;&lt;head&gt;&lt;meta name=&quot;qrichtext&quot; content=&quot;1&quot; /&gt;&lt;style type=&quot;text/css&quot;&gt;
p, li { white-space: pre-wrap; }
&lt;/style&gt;&lt;/head&gt;&lt;body style=&quot; font-family:'Roboto'; ; font-weight:400; font-style:normal;&quot;&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;Determines how much smoothing is added to Remote Tilt, such as when you start tilting and as you approach the target angle.&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;0 = No Smoothing&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;3 = Maximum Smoothing&lt;/p&gt;
&lt;p style=&quot;-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;br /&gt;&lt;/p&gt;
&lt;p style=&quot; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;&quot;&gt;&lt;span style=&quot; font-style:italic;&quot;&gt;Recommended Values: 1-2&lt;/span&gt;&lt;/p&gt;&lt;/body&gt;&lt;/html&gt;</description>
<cDefine>CFG_DFLT_INPUTTILT_SMOOTHING_FACTOR</cDefine>
<editorScale>1</editorScale>
<editAsPercentage>0</editAsPercentage>
<maxInt>3</maxInt>
<minInt>0</minInt>
<showDisplay>1</showDisplay>
<stepInt>1</stepInt>
<valInt>1</valInt>
<suffix></suffix>
<vTx>1</vTx>
</inputtilt_smoothing_factor>
<inputtilt_invert_throttle>
<longName>Invert Throttle</longName>
<type>5</type>
Expand Down Expand Up @@ -3343,7 +3318,6 @@ p, li { white-space: pre-wrap; }
<ser>inputtilt_remote_type</ser>
<ser>inputtilt_angle_limit</ser>
<ser>inputtilt_speed</ser>
<ser>inputtilt_smoothing_factor</ser>
<ser>inputtilt_invert_throttle</ser>
<ser>inputtilt_deadband</ser>
<ser>remote_throttle_current_max</ser>
Expand Down Expand Up @@ -3581,7 +3555,6 @@ p, li { white-space: pre-wrap; }
<param>inputtilt_remote_type</param>
<param>inputtilt_angle_limit</param>
<param>inputtilt_speed</param>
<param>inputtilt_smoothing_factor</param>
<param>inputtilt_invert_throttle</param>
<param>inputtilt_deadband</param>
<param>::sep::Remote Throttle</param>
Expand Down
63 changes: 24 additions & 39 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -870,48 +870,33 @@ static void apply_inputtilt(data *d) {
float input_tiltback_target_diff = input_tiltback_target - d->inputtilt_interpolated;

// Smoothen changes in tilt angle by ramping the step size
if (d->float_conf.inputtilt_smoothing_factor > 0) {
float smoothing_factor = 0.02;
for (int i = 1; i < d->float_conf.inputtilt_smoothing_factor; i++) {
smoothing_factor /= 2;
}

// Sets the angle away from Target that step size begins ramping down
float smooth_center_window = 1.5 + (0.5 * d->float_conf.inputtilt_smoothing_factor);

// Within X degrees of Target Angle, start ramping down step size
if (fabsf(input_tiltback_target_diff) < smooth_center_window) {
// Target step size is reduced the closer to center you are (needed for smoothly
// transitioning away from center)
d->inputtilt_ramped_step_size =
(smoothing_factor * d->inputtilt_step_size * (input_tiltback_target_diff / 2)) +
((1 - smoothing_factor) * d->inputtilt_ramped_step_size);
// Linearly ramped down step size is provided as minimum to prevent overshoot
float centering_step_size =
fminf(
fabsf(d->inputtilt_ramped_step_size),
fabsf(input_tiltback_target_diff / 2) * d->inputtilt_step_size
) *
sign(input_tiltback_target_diff);
if (fabsf(input_tiltback_target_diff) < fabsf(centering_step_size)) {
d->inputtilt_interpolated = input_tiltback_target;
} else {
d->inputtilt_interpolated += centering_step_size;
}
} else {
// Ramp up step size until the configured tilt speed is reached
d->inputtilt_ramped_step_size =
(smoothing_factor * d->inputtilt_step_size * sign(input_tiltback_target_diff)) +
((1 - smoothing_factor) * d->inputtilt_ramped_step_size);
d->inputtilt_interpolated += d->inputtilt_ramped_step_size;
}
} else {
// Constant step size; no smoothing
if (fabsf(input_tiltback_target_diff) < d->inputtilt_step_size) {
const float smoothing_factor = 0.02;

// Within X degrees of Target Angle, start ramping down step size
if (fabsf(input_tiltback_target_diff) < 2.0f) {
// Target step size is reduced the closer to center you are (needed for smoothly
// transitioning away from center)
d->inputtilt_ramped_step_size =
(smoothing_factor * d->inputtilt_step_size * (input_tiltback_target_diff / 2)) +
((1 - smoothing_factor) * d->inputtilt_ramped_step_size);
// Linearly ramped down step size is provided as minimum to prevent overshoot
float centering_step_size =
fminf(
fabsf(d->inputtilt_ramped_step_size),
fabsf(input_tiltback_target_diff / 2) * d->inputtilt_step_size
) *
sign(input_tiltback_target_diff);
if (fabsf(input_tiltback_target_diff) < fabsf(centering_step_size)) {
d->inputtilt_interpolated = input_tiltback_target;
} else {
d->inputtilt_interpolated += d->inputtilt_step_size * sign(input_tiltback_target_diff);
d->inputtilt_interpolated += centering_step_size;
}
} else {
// Ramp up step size until the configured tilt speed is reached
d->inputtilt_ramped_step_size =
(smoothing_factor * d->inputtilt_step_size * sign(input_tiltback_target_diff)) +
((1 - smoothing_factor) * d->inputtilt_ramped_step_size);
d->inputtilt_interpolated += d->inputtilt_ramped_step_size;
}

d->setpoint += d->inputtilt_interpolated;
Expand Down

0 comments on commit a55925f

Please sign in to comment.