40 #include <mathlib/mathlib.h> 122 static constexpr
float mag_anomalies_max_hagl = 1.5f;
157 bool has_realigned_yaw =
false;
281 return (user_selected && heading_not_required_for_navigation)
304 constexpr
float wmm_gate_size = 0.2f;
310 constexpr
float average_earth_mag_field_strength = 0.45f;
311 constexpr
float average_earth_mag_gate_size = 0.40f;
313 average_earth_mag_field_strength,
314 average_earth_mag_gate_size);
319 return (measured >= expected - gate)
320 && (measured <= expected + gate);
bool canUse3DMagFusion() const
void fuseDeclination(float decl_sigma)
struct estimator::filter_control_status_u::@60 flags
uint32_t gps_yaw
22 - true when yaw (not ground course) data from a GPS receiver is being fused
stateSample _state
state struct of the ekf running at the delayed time horizon
uint64_t _time_last_mov_3d_mag_suitable
last system time that sufficient movement to use 3-axis magnetometer fusion was detected (uSec) ...
uint32_t yaw_align
1 - true if the filter yaw alignment is complete
float _yaw_rate_lpf_ef
Filtered angular rate about earth frame D axis (rad/sec)
bool resetMagHeading(const Vector3f &mag_init, bool increase_yaw_var=true, bool update_buffer=true)
void checkMagBiasObservability()
#define MAG_FUSE_TYPE_3D
Magnetometer 3-axis fusion will always be used. This is more accurate, but more affected by localised...
void runOnGroundYawReset()
bool shouldInhibitMag() const
bool _mag_yaw_reset_req
true when a reset of the yaw using the magnetometer data has been requested
float _yaw_delta_ef
Recent change in yaw angle measured about the earth frame D axis (rad)
uint32_t fixed_wing
17 - true when the vehicle is operating as a fixed wing vehicle
uint32_t mag_hdg
4 - true if a simple magnetic yaw heading is being fused
Vector2f _accel_lpf_NE
Low pass filtered horizontal earth frame acceleration (m/sec**2)
bool canRunMagFusion() const
uint32_t mag_fault
18 - true when the magnetometer has been declared faulty and is no longer being used ...
#define MAG_FUSE_TYPE_HEADING
Simple yaw angle fusion will always be used. This is less accurate, but less affected by earth field ...
uint32_t mag_field_disturbed
16 - true when the mag field does not match the expected strength
bool _mag_decl_cov_reset
true after the fuseDeclination() function has been used to modify the earth field covariances after a...
#define MAG_FUSE_TYPE_INDOOR
The same as option 0, but magnetometer or yaw fusion will not be used unless earth frame external aid...
static bool isMeasuredMatchingExpected(float measured, float expected, float gate)
bool _mag_inhibit_yaw_reset_req
true when magnetometer inhibit has been active for long enough to require a yaw reset when conditions...
const T & getState() const
void checkMagFieldStrength()
float _terrain_vpos
estimated vertical position of the terrain underneath the vehicle in local NED frame (m) ...
bool _NED_origin_initialised
AlphaFilterVector3f _mag_lpf
filtered magnetometer measurement (Gauss)
bool isStrongMagneticDisturbance() const
uint32_t ev_vel
24 - true when local earth frame velocity data from external vision measurements are being fused ...
void runMagAndMagDeclFusions()
int32_t mag_declination_source
bitmask used to control the handling of declination data
bool isYawResetAuthorized() const
bool isMeasuredMatchingGpsMagStrength() const
bool canResetMagHeading() const
float getTerrainVPos() const
uint64_t time_us
timestamp of the measurement (uSec)
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
void update(const T &input, float tau, float dt)
filter_control_status_u _control_status
float mag_acc_gate
when in auto select mode, heading fusion will be used when manoeuvre accel is lower than this (m/sec*...
void checkMagInhibition()
int32_t mag_fusion_type
integer used to specify the type of magnetometer fusion used
uint32_t ev_yaw
13 - true when yaw data from external vision measurements is being fused
bool _velpos_reset_request
true when a large yaw error has been fixed and a velocity and position state reset is required ...
bool canRealignYawUsingGps() const
uint32_t mag_aligned_in_flight
23 - true when the in-flight mag field alignment has been completed
imuSample _imu_sample_delayed
void checkMagDeclRequired()
Vector3f pos
NED position in earth frame in m.
int32_t check_mag_strength
bool _mag_use_inhibit
true when magnetometer use is being inhibited
uint32_t mag_dec
6 - true if synthetic magnetic declination measurements are being fused
#define MAG_FUSE_TYPE_NONE
Do not use magnetometer under any circumstance. Other sources of yaw may be used if selected via the ...
uint64_t _time_yaw_started
last system time in usec that a yaw rotation manoeuvre was detected
uint32_t mag_3D
5 - true if 3-axis magnetometer measurement are being fused
uint32_t in_air
7 - true when the vehicle is airborne
bool isYawAngleObservable() const
bool _yaw_angle_observable
true when there is enough horizontal acceleration to make yaw observable
void run3DMagAndDeclFusions()
float mag_yaw_rate_gate
yaw rate threshold used by mode select logic (rad/sec)
uint32_t ev_pos
12 - true when local position data from external vision is being fused
float _last_on_ground_posD
last vertical position when the in_air status was false (m)
void checkHaglYawResetReq()
uint8_t _num_bad_flight_yaw_events
number of times a bad heading has been detected in flight and required a yaw reset ...
uint32_t gps
2 - true if GPS measurements are being fused
void check3DMagFusionSuitability()
Vector3f mag
NED magnetometer body frame measurements (Gauss)
#define MAG_FUSE_TYPE_AUTO
The selection of either heading or 3D magnetometer fusion will be automatic.
bool isMagBiasObservable() const
Class for core functions for ekf attitude and position estimator.
bool isTerrainEstimateValid() const override
#define MASK_FUSE_DECL
set to true if the declination is always fused as an observation to constrain drift when 3-axis fusio...
uint64_t _mag_use_not_inhibit_us
last system time in usec before magnetometer use was inhibited
bool _mag_data_ready
true when new magnetometer data has fallen behind the fusion time horizon and is available to be fuse...
bool isMeasuredMatchingAverageMagStrength() const
bool _mag_bias_observable
true when there is enough rotation to make magnetometer bias errors observable
magSample _mag_sample_delayed
void checkYawAngleObservability()