mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
mixer: FunctionMotors: compare against FLT_EPSILON instead of 0.f
Signed-off-by: Silvan Fuhrer <silvan@auterion.com>
This commit is contained in:
parent
d7904b5f2c
commit
4db55cd25f
@ -76,7 +76,7 @@ public:
|
||||
|
||||
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;
|
||||
@ -88,17 +88,15 @@ public:
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user