Go to the documentation of this file.
49 gain_acc_(
Parameters::defaultImuFilterComplementaryGainAcc()),
50 bias_alpha_(
Parameters::defaultImuFilterComplementaryBiasAlpha()),
51 do_bias_estimation_(
Parameters::defaultImuFilterComplementaryDoBiasEstimation()),
52 do_adaptive_gain_(
Parameters::defaultImuFilterComplementaryDoAdpativeGain()),
55 q0_(1), q1_(0), q2_(0), q3_(0),
56 wx_prev_(0), wy_prev_(0), wz_prev_(0),
57 wx_bias_(0), wy_bias_(0), wz_bias_(0)
92 if (gain >= 0 && gain <= 1.0)
113 if (bias_alpha >= 0 && bias_alpha <= 1.0)
128 double qx,
double qy,
double qz,
double qw)
160 double gx,
double gy,
double gz,
161 double ax,
double ay,
double az,
175 UWARN(
"dt=%f <=0.0, orientation will not be updated!",
dt);
184 double q0_pred, q1_pred, q2_pred, q3_pred;
186 q0_pred, q1_pred, q2_pred, q3_pred);
191 double dq0_acc, dq1_acc, dq2_acc, dq3_acc;
193 q0_pred, q1_pred, q2_pred, q3_pred,
194 dq0_acc, dq1_acc, dq2_acc, dq3_acc);
211 dq0_acc, dq1_acc, dq2_acc, dq3_acc,
218 double wx,
double wy,
double wz)
const
220 double acc_magnitude =
sqrt(ax*ax + ay*ay + az*az);
238 double wx,
double wy,
double wz)
255 double wx,
double wy,
double wz,
double dt,
256 double& q0_pred,
double& q1_pred,
double& q2_pred,
double& q3_pred)
const
271 double ax,
double ay,
double az,
272 double mx,
double my,
double mz,
273 double& q0_meas,
double& q1_meas,
double& q2_meas,
double& q3_meas)
278 double q0_acc, q1_acc, q2_acc, q3_acc;
284 q0_acc =
sqrt((az + 1) * 0.5);
285 q1_acc = -ay/(2.0 * q0_acc);
286 q2_acc = ax/(2.0 * q0_acc);
291 double X =
sqrt((1 - az) * 0.5);
292 q0_acc = -ay/(2.0 *
X);
295 q3_acc = ax/(2.0 *
X);
301 double lx = (q0_acc*q0_acc + q1_acc*q1_acc - q2_acc*q2_acc)*mx +
302 2.0 * (q1_acc*q2_acc)*my - 2.0 * (q0_acc*q2_acc)*mz;
303 double ly = 2.0 * (q1_acc*q2_acc)*mx + (q0_acc*q0_acc - q1_acc*q1_acc +
304 q2_acc*q2_acc)*my + 2.0 * (q0_acc*q1_acc)*mz;
308 double gamma = lx*lx + ly*ly;
311 double q3_mag = ly / (
sqrt(2.0) *
beta);
317 q0_mag, 0, 0, q3_mag,
318 q0_meas, q1_meas, q2_meas, q3_meas );
327 double ax,
double ay,
double az,
328 double& q0_meas,
double& q1_meas,
double& q2_meas,
double& q3_meas)
339 q0_meas =
sqrt((az + 1) * 0.5);
340 q1_meas = -ay/(2.0 * q0_meas);
341 q2_meas = ax/(2.0 * q0_meas);
346 double X =
sqrt((1 - az) * 0.5);
347 q0_meas = -ay/(2.0 *
X);
350 q3_meas = ax/(2.0 *
X);
355 double ax,
double ay,
double az,
356 double p0,
double p1,
double p2,
double p3,
357 double& dq0,
double& dq1,
double& dq2,
double& dq3)
370 dq0 =
sqrt((gz + 1) * 0.5);
371 dq1 = -gy/(2.0 * dq0);
372 dq2 = gx/(2.0 * dq0);
377 double& qx,
double& qy,
double& qz,
double& qw)
const
385 double a_mag =
sqrt(ax*ax + ay*ay + az*az);
390 double m = 1.0/(error1 - error2);
391 double b = 1.0 -
m*error1;
394 else if (
error < error2)
413 double norm =
sqrt(q0*q0 + q1*q1 + q2*q2 + q3*q3);
421 double q0,
double q1,
double q2,
double q3,
422 double& q0_inv,
double& q1_inv,
double& q2_inv,
double& q3_inv)
433 double& dq0,
double& dq1,
double& dq2,
double& dq3)
449 dq0 = (1.0 - gain) + gain * dq0;
459 double p0,
double p1,
double p2,
double p3,
460 double q0,
double q1,
double q2,
double q3,
461 double& r0,
double& r1,
double& r2,
double& r3)
471 double x,
double y,
double z,
472 double q0,
double q1,
double q2,
double q3,
473 double& vx,
double& vy,
double& vz)
475 vx = (q0*q0 + q1*q1 - q2*q2 - q3*q3)*
x + 2*(q1*q2 - q0*q3)*
y + 2*(q1*q3 + q0*q2)*
z;
476 vy = 2*(q1*q2 + q0*q3)*
x + (q0*q0 - q1*q1 + q2*q2 - q3*q3)*
y + 2*(q2*q3 - q0*q1)*
z;
477 vz = 2*(q1*q3 - q0*q2)*
x + 2*(q2*q3 + q0*q1)*
y + (q0*q0 - q1*q1 - q2*q2 + q3*q3)*
z;
bool setBiasAlpha(double bias_alpha)
void getAccCorrection(double ax, double ay, double az, double p0, double p1, double p2, double p3, double &dq0, double &dq1, double &dq2, double &dq3)
void rotateVectorByQuaternion(double x, double y, double z, double q0, double q1, double q2, double q3, double &vx, double &vy, double &vz)
double getGainAcc() const
static const double kAccelerationThreshold
bool setGainAcc(double gain)
virtual void getOrientation(double &qx, double &qy, double &qz, double &qw) const
void setDoAdaptiveGain(bool do_adaptive_gain)
void invertQuaternion(double q0, double q1, double q2, double q3, double &q0_inv, double &q1_inv, double &q2_inv, double &q3_inv)
virtual void parseParameters(const ParametersMap ¶meters)
std::map< std::string, std::string > ParametersMap
double beta(double a, double b)
void updateBiases(double ax, double ay, double az, double wx, double wy, double wz)
GLM_FUNC_DECL genType acos(genType const &x)
static bool parse(const ParametersMap ¶meters, const std::string &key, bool &value)
void getPrediction(double wx, double wy, double wz, double dt, double &q0_pred, double &q1_pred, double &q2_pred, double &q3_pred) const
bool getSteadyState() const
double getAngularVelocityBiasY() const
StridedVectorType vy(make_vector(y, *n, std::abs(*incy)))
void normalizeQuaternion(double &q0, double &q1, double &q2, double &q3)
GLM_FUNC_DECL vecType< T, P > sqrt(vecType< T, P > const &x)
double getAdaptiveGain(double alpha, double ax, double ay, double az)
static const double kAngularVelocityThreshold
void normalizeVector(double &x, double &y, double &z)
void error(const char *str)
GLM_FUNC_DECL T angle(detail::tquat< T, P > const &x)
bool getDoAdaptiveGain() const
virtual void updateImpl(double gx, double gy, double gz, double ax, double ay, double az, double dt)
static const double kGravity
void quaternionMultiplication(double p0, double p1, double p2, double p3, double q0, double q1, double q2, double q3, double &r0, double &r1, double &r2, double &r3)
ULogger class and convenient macros.
bool getDoBiasEstimation() const
void scaleQuaternion(double gain, double &dq0, double &dq1, double &dq2, double &dq3)
virtual void reset(double qx=0.0, double qy=0.0, double qz=0.0, double qw=1.0)
double getBiasAlpha() const
bool checkState(double ax, double ay, double az, double wx, double wy, double wz) const
void getMeasurement(double ax, double ay, double az, double &q0_meas, double &q1_meas, double &q2_meas, double &q3_meas)
ComplementaryFilter(const ParametersMap ¶meters=ParametersMap())
double getAngularVelocityBiasX() const
static const double kDeltaAngularVelocityThreshold
static const double gamma_
GLM_FUNC_DECL genType sin(genType const &angle)
StridedVectorType vx(make_vector(x, *n, std::abs(*incx)))
void setDoBiasEstimation(bool do_bias_estimation)
double getAngularVelocityBiasZ() const
rtabmap
Author(s): Mathieu Labbe
autogenerated on Thu Jul 25 2024 02:50:08