11#ifndef STATEOBSERVATIONTOOLSMISCELANEOUSALGORITHMS
12#define STATEOBSERVATIONTOOLSMISCELANEOUSALGORITHMS
13#include <boost/utility.hpp>
16#include <state-observation/api.h>
33inline T
derivate(
const T & o1,
const T & o2,
double dt)
43 return (T(0) < x) - (x < T(0));
47inline std::string toString(T val)
49 std::stringstream ss(
"");
79 outputSquaredNorm = v.squaredNorm();
98inline T
clampScalar(
const T & x,
const T & max,
const T & min)
142 return v /
sqrt(squaredNorm);
149inline double STATE_OBSERVATION_DLLAPI
finiteTimeAccControl(
double x,
double xd,
double kp = -1,
double kv = -1)
151 double sax =
sqrt(fabs(x));
152 double xdr = kp *
signum(x) * sax;
155 return ydr - kp * xd / (2 * sax);
165 for(Index i = 1; i < x.size(); ++i)
174double constexpr sqrtNewtonRaphson(
double x,
double curr,
double prev)
176 return curr == prev ? curr : sqrtNewtonRaphson(x, 0.5 * (curr + x / curr), curr);
188 return x >= 0 && x < std::numeric_limits<double>::infinity() ? Detail::sqrtNewtonRaphson(x, x, 0)
189 : std::numeric_limits<double>::quiet_NaN();
Definitions of types and some structures.
constexpr double epsilon1
number considered zero when compared to 1
double constexpr sqrt(double x)
Constexpr version of the square root.
T clampScalar(const T &x, const T &max, const T &min)
returns the value clamped between min and max
T derivate(const T &o1, const T &o2, double dt)
derivates any type with finite differences
Vector3 normalizedLazy(const Vector3 &v)
normalize the vector only if it is not normalized already. Useful if the vector is likely to be norma...
int signum(T x)
gives the sign of a variable (1, 0 or -1)
double STATE_OBSERVATION_DLLAPI finiteTimeAccControl(double x, double xd, double kp=-1, double kv=-1)
bool checkIfNormalized(const Vector3 &v)
checks if the vector is already normalized or not
T square(const T &x)
computes the square of a value of any type
Filtering of divergent component of motion (DCM) and estimation of a bias betweeen the DCM and the co...
Eigen::Vector3d Vector3
3D vector
Eigen::VectorXd Vector
Dynamic sized scalar vector.