mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 04:43:34 +08:00
mathlib: get rid of now duplicate sign() function
Instead use the one that was copied to the matrix library in https://github.com/PX4/Matrix/pull/116/
This commit is contained in:
@@ -41,16 +41,11 @@
|
||||
|
||||
#include "Limits.hpp"
|
||||
|
||||
#include <matrix/matrix/math.hpp>
|
||||
|
||||
namespace math
|
||||
{
|
||||
|
||||
// Type-safe signum function
|
||||
template<typename T>
|
||||
int sign(T val)
|
||||
{
|
||||
return (T(FLT_EPSILON) < val) - (val < T(FLT_EPSILON));
|
||||
}
|
||||
|
||||
// Type-safe signum function with zero treated as positive
|
||||
template<typename T>
|
||||
int signNoZero(T val)
|
||||
@@ -114,7 +109,7 @@ const T deadzone(const T &value, const T &dz)
|
||||
T x = constrain(value, (T) - 1, (T) 1);
|
||||
T dzc = constrain(dz, (T) 0, (T) 0.99);
|
||||
// Rescale the input such that we get a piecewise linear function that will be continuous with applied deadzone
|
||||
T out = (x - sign(x) * dzc) / (1 - dzc);
|
||||
T out = (x - matrix::sign(x) * dzc) / (1 - dzc);
|
||||
// apply the deadzone (values zero around the middle)
|
||||
return out * (fabsf(x) > dzc);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user