34 #include "rosflight.h" 186 const float scaleDt = (dt > 0) ? (extAttDt / dt) : 0.0f;
206 bias_ -= ki * w_err * dt;
257 const float lowerbound = (1.0f - margin) * (1.0
f - margin) * 9.80665f * 9.80665f;
258 const float upperbound = (1.0f + margin) * (1.0
f + margin) * 9.80665f * 9.80665f;
262 return (lowerbound < a_sqrd_norm && a_sqrd_norm < upperbound);
286 w_acc.
x = -2.0f * q_tilde.
w * q_tilde.
x;
287 w_acc.
y = -2.0f * q_tilde.
w * q_tilde.
y;
337 const float dt)
const 341 const float sqrd_norm_w = omega.
sqrd_norm();
342 if (sqrd_norm_w == 0.0
f)
346 const float &p = omega.
x, &q = omega.
y, &r = omega.
z;
354 float norm_w = sqrtf(sqrd_norm_w);
355 float t1 = cosf((norm_w * dt) / 2.0
f);
356 float t2 = 1.0f / norm_w * sinf((norm_w * dt) / 2.0
f);
357 quat.
w = t1 * quat.
w + t2 * (-p * quat.
x - q * quat.
y - r * quat.
z);
358 quat.
x = t1 * quat.
x + t2 * (p * quat.
w + r * quat.
y - q * quat.
z);
359 quat.
y = t1 * quat.
y + t2 * (q * quat.
w - r * quat.
x + p * quat.
z);
360 quat.
z = t1 * quat.
z + t2 * (r * quat.
w + q * quat.
x - p * quat.
y);
368 0.5
f * (-p * quat.
x - q * quat.
y - r * quat.
z), 0.5f * (p * quat.
w + r * quat.
y - q * quat.
z),
369 0.5f * (q * quat.
w - r * quat.
x + p * quat.
z), 0.5f * (r * quat.
w + q * quat.
x - p * quat.
y));
370 quat.
w += qdot.
w * dt;
371 quat.
x += qdot.
x * dt;
372 quat.
y += qdot.
y * dt;
373 quat.
z += qdot.
z * dt;
387 const float &w = q.
w, &x = q.
x, &y = q.
y, &z = q.
z;
388 X.
x = 1.0f - 2.0f * (y * y + z * z);
389 X.
y = 2.0f * (x * y - z * w);
390 X.
z = 2.0f * (x * z + y * w);
391 Y.
x = 2.0f * (x * y + z * w);
392 Y.
y = 1.0f - 2.0f * (x * x + z * z);
393 Y.
z = 2.0f * (y * z - x * w);
394 Z.
x = 2.0f * (x * z - y * w);
395 Z.
y = 2.0f * (y * z + x * w);
396 Z.
z = 1.0f - 2.0f * (x * x + y * y);
Estimator(ROSflight &_rf)
void quaternion_to_dcm(const turbomath::Quaternion &q, turbomath::Vector &X, turbomath::Vector &Y, turbomath::Vector &Z) const
void integrate_angular_rate(turbomath::Quaternion &quat, const turbomath::Vector &omega, const float dt) const
Vector cross(const Vector &v) const
turbomath::Vector gyro_LPF_
turbomath::Vector accel_LPF_
turbomath::Vector smoothed_gyro_measurement()
void reset_adaptive_bias()
void param_change_callback(uint16_t param_id) override
turbomath::Vector accel_correction() const
turbomath::Vector extatt_correction() const
bool extatt_update_next_run_
uint64_t last_acc_update_us_
void get_RPY(float *roll, float *pitch, float *yaw) const
float get_param_float(uint16_t id) const
Get the value of a floating point parameter by id.
Vector normalized() const
void set_external_attitude_update(const turbomath::Quaternion &q)
bool can_use_extatt() const
virtual uint64_t clock_micros()=0
turbomath::Quaternion q_extatt_
bool can_use_accel() const
void set_error(uint16_t error)
void clear_error(uint16_t error)
turbomath::Quaternion attitude
turbomath::Vector angular_velocity
int get_param_int(uint16_t id) const
Get the value of an integer parameter by id.
StateManager state_manager_
const Data & data() const
uint64_t last_extatt_update_us_
const turbomath::Vector g_