Skip to content

Commit

Permalink
mixer: FunctionMotors: compare against FLT_EPSILON instead of 0.f
Browse files Browse the repository at this point in the history
Signed-off-by: Silvan Fuhrer <[email protected]>
  • Loading branch information
sfuhrer authored and MaEtUgR committed Dec 13, 2024
1 parent d7904b5 commit 4db55cd
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/lib/mixer_module/functions/FunctionMotors.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class FunctionMotors : public FunctionProviderBase

static inline void updateValues(uint32_t reversible, float thrust_factor, float *values, int num_values)
{
if (thrust_factor > 0.f && thrust_factor <= 1.f) {
if (thrust_factor > FLT_EPSILON && thrust_factor <= 1.f) {
// thrust factor
// rel_thrust = factor * x^2 + (1-factor) * x,
const float a = thrust_factor;
Expand All @@ -88,17 +88,15 @@ class FunctionMotors : public FunctionProviderBase

for (int i = 0; i < num_values; ++i) {

float control = values[i];
const float control = values[i];

if (PX4_ISFINITE(control)) {
if (control > 0.f) {
if (control > FLT_EPSILON) {
values[i] = -tmp1 + sqrtf(tmp2 + (control / a));

} else if (control < -0.f) {
} else if (control < -FLT_EPSILON) {
values[i] = tmp1 - sqrtf(tmp2 - (control / a));

} else {
values[i] = 0.f;
}
}
}
Expand Down

0 comments on commit 4db55cd

Please sign in to comment.