Vector3fvel;// NED velocity estimate in earth frame in m/s
Vector3fvel;// NED velocity estimate in earth frame in m/s
@ -107,43 +114,90 @@ struct airspeedSample {
};
};
structflowSample{
structflowSample{
Vector2fflowRadXY;
uint8_tquality;// quality indicator between 0 and 255
Vector2fflowRadXYcomp;
Vector2fflowRadXY;// measured delta angle of the image about the X and Y body axes (rad), RH rotaton is positive
uint64_ttime_us;
Vector2fflowRadXYcomp;// measured delta angle of the image about the X and Y body axes after removal of body rotation (rad), RH rotation is positive
Vector2fgyroXY;// measured delta angle of the inertial frame about the X and Y body axes obtained from rate gyro measurements (rad), RH rotation is positive
floatdt;// amount of integration time (sec)
uint64_ttime_us;// timestamp in microseconds of the integration period mid-point
};
};
enumvdist_sensor_type_t{
VDIST_SENSOR_RANGE,
VDIST_SENSOR_BARO,
VDIST_SENSOR_GPS,
VDIST_SENSOR_NONE
};
// Bit locations for mag_declination_source
#define MASK_USE_GEO_DECL (1<<0) // set to true to use the declination from the geo library when the GPS position becomes available, set to false to always use the EKF2_MAG_DECL value
#define MASK_SAVE_GEO_DECL (1<<1) // set to true to set the EKF2_MAG_DECL parameter to the value returned by the geo library
#define MASK_FUSE_DECL (1<<2) // set to true if the declination is always fused as an observation to constrain drift when 3-axis fusion is performed
// Bit locations for fusion_mode
#define MASK_USE_GPS (1<<0) // set to true to use GPS data
#define MASK_USE_OF (1<<1) // set to true to use optical flow data
// Integer definitions for mag_fusion_type
#define MAG_FUSE_TYPE_AUTO 0 // The selection of either heading or 3D magnetometer fusion will be automatic
#define MAG_FUSE_TYPE_HEADING 1 // Simple yaw angle fusion will always be used. This is less accurate, but less affected by earth field distortions. It should not be used for pitch angles outside the range from -60 to +60 deg
#define MAG_FUSE_TYPE_3D 2 // Magnetometer 3-axis fusion will always be used. This is more accurate, but more affected by localised earth field distortions
#define MAG_FUSE_TYPE_2D 3 // A 2D fusion that uses the horizontal projection of the magnetic fields measurement will alays be used. This is less accurate, but less affected by earth field distortions.
structparameters{
structparameters{
floatmag_delay_ms;// magnetometer measurement delay relative to the IMU
// measurement source control
floatbaro_delay_ms;// barometer height measurement delay relative to the IMU
intfusion_mode;
floatgps_delay_ms;// GPS measurement delay relative to the IMU
intvdist_sensor_type;
floatairspeed_delay_ms;// airspeed measurement delay relative to the IMU
// measurement time delays
floatmag_delay_ms;// magnetometer measurement delay relative to the IMU (msec)
floatbaro_delay_ms;// barometer height measurement delay relative to the IMU (msec)
floatgps_delay_ms;// GPS measurement delay relative to the IMU (msec)
floatairspeed_delay_ms;// airspeed measurement delay relative to the IMU (msec)
floatflow_delay_ms;// optical flow measurement delay relative to the IMU (msec) - this is to the middle of the optical flow integration interval
floatrange_delay_ms;// range finder measurement delay relative to the IMU (msec)
// input noise
// input noise
floatgyro_noise;// IMU angular rate noise used for covariance prediction
floatgyro_noise;// IMU angular rate noise used for covariance prediction (rad/sec)
floataccel_noise;// IMU acceleration noise use for covariance prediction
floataccel_noise;// IMU acceleration noise use for covariance prediction (m/sec/sec)
// process noise
// process noise
floatgyro_bias_p_noise;// process noise for IMU delta angle bias prediction
floatgyro_bias_p_noise;// process noise for IMU delta angle bias prediction (rad/sec)
floataccel_bias_p_noise;// process noise for IMU delta velocity bias prediction
floataccel_bias_p_noise;// process noise for IMU delta velocity bias prediction (m/sec/sec)
floatgyro_scale_p_noise;// process noise for gyro scale factor prediction
floatgyro_scale_p_noise;// process noise for gyro scale factor prediction (N/A)
floatmag_p_noise;// process noise for magnetic field prediction
floatmag_p_noise;// process noise for magnetic field prediction (Guass/sec)
floatwind_vel_p_noise;// process noise for wind velocity prediction
floatwind_vel_p_noise;// process noise for wind velocity prediction (m/sec/sec)
floatterrain_p_noise;// process noise for terrain offset (m/sec)
floatgps_vel_noise;// observation noise for gps velocity fusion
floatgps_pos_noise;// observation noise for gps position fusion
// position and velocity fusion
floatpos_noaid_noise;// observation noise for non-aiding position fusion
floatgps_vel_noise;// observation noise for gps velocity fusion (m/sec)
floatbaro_noise;// observation noise for barometric height fusion
floatgps_pos_noise;// observation noise for gps position fusion (m)
floatbaro_innov_gate;// barometric height innovation consistency gate size in standard deviations
floatpos_noaid_noise;// observation noise for non-aiding position fusion (m)
floatposNE_innov_gate;// GPS horizontal position innovation consistency gate size in standard deviations
floatbaro_noise;// observation noise for barometric height fusion (m)
floatvel_innov_gate;// GPS velocity innovation consistency gate size in standard deviations
floatflow_rate_max;// maximum valid optical flow rate (rad/sec)
// these parameters control the strictness of GPS quality checks used to determine uf the GPS is
// these parameters control the strictness of GPS quality checks used to determine uf the GPS is
// good enough to set a local origin and commence aiding
// good enough to set a local origin and commence aiding
@ -159,10 +213,17 @@ struct parameters {
// Initialize parameter values. Initialization must be accomplished in the constructor to allow C99 compiler compatibility.
// Initialize parameter values. Initialization must be accomplished in the constructor to allow C99 compiler compatibility.
parameters()
parameters()
{
{
// measurement source control
fusion_mode=MASK_USE_OF;
vdist_sensor_type=VDIST_SENSOR_BARO;
// measurement time delays
mag_delay_ms=0.0f;
mag_delay_ms=0.0f;
baro_delay_ms=0.0f;
baro_delay_ms=0.0f;
gps_delay_ms=200.0f;
gps_delay_ms=200.0f;
airspeed_delay_ms=200.0f;
airspeed_delay_ms=200.0f;
flow_delay_ms=60.0f;
range_delay_ms=200.0f;
// input noise
// input noise
gyro_noise=1.0e-3f;
gyro_noise=1.0e-3f;
@ -174,7 +235,9 @@ struct parameters {
gyro_scale_p_noise=3.0e-3f;
gyro_scale_p_noise=3.0e-3f;
mag_p_noise=2.5e-2f;
mag_p_noise=2.5e-2f;
wind_vel_p_noise=1.0e-1f;
wind_vel_p_noise=1.0e-1f;
terrain_p_noise=0.5f;
// position and velocity fusion
gps_vel_noise=5.0e-1f;
gps_vel_noise=5.0e-1f;
gps_pos_noise=1.0f;
gps_pos_noise=1.0f;
pos_noaid_noise=10.0f;
pos_noaid_noise=10.0f;
@ -183,15 +246,28 @@ struct parameters {
posNE_innov_gate=3.0f;
posNE_innov_gate=3.0f;
vel_innov_gate=3.0f;
vel_innov_gate=3.0f;
mag_heading_noise=5.0e-1f;
// magnetometer fusion
mag_heading_noise=1.7e-1f;
mag_noise=5.0e-2f;
mag_noise=5.0e-2f;
mag_declination_deg=0.0f;
mag_declination_deg=0.0f;
heading_innov_gate=3.0f;
heading_innov_gate=3.0f;
mag_innov_gate=3.0f;
mag_innov_gate=3.0f;
mag_declination_source=3;
mag_declination_source=7;
mag_fusion_type=0;
mag_fusion_type=0;
// range finder fusion
range_noise=0.1f;
range_innov_gate=5.0f;
rng_gnd_clearance=0.1f;
// optical flow fusion
flow_noise=0.15f;
flow_noise_qual_min=0.5f;
flow_qual_min=1;
flow_innov_gate=3.0f;
flow_rate_max=2.5f;
// GPS quality checks
gps_check_mask=21;
gps_check_mask=21;
req_hacc=5.0f;
req_hacc=5.0f;
req_vacc=8.0f;
req_vacc=8.0f;
@ -203,17 +279,6 @@ struct parameters {
}
}
};
};
// Bit locations for mag_declination_source
#define MASK_USE_GEO_DECL (1<<0) // set to true to use the declination from the geo library when the GPS position becomes available, set to false to always use the EKF2_MAG_DECL value
#define MASK_SAVE_GEO_DECL (1<<1) // set to true to set the EKF2_MAG_DECL parameter to the value returned by the geo library
#define MASK_FUSE_DECL (1<<2) // set to true if the declination is always fused as an observation to constrain drift when 3-axis fusion is performed
// Integer definitions for mag_fusion_type
#define MAG_FUSE_TYPE_AUTO 0 // The selection of either heading or 3D magnetometer fusion will be automatic
#define MAG_FUSE_TYPE_HEADING 1 // Simple yaw angle fusion will always be used. This is less accurate, but less affected by earth field distortions. It should not be used for pitch angles outside the range from -60 to +60 deg
#define MAG_FUSE_TYPE_3D 2 // Magnetometer 3-axis fusion will always be used. This is more accurate, but more affected by localised earth field distortions
#define MAG_FUSE_TYPE_2D 3 // A 2D fusion that uses the horizontal projection of the magnetic fields measurement will alays be used. This is less accurate, but less affected by earth field distortions.
structstateSample{
structstateSample{
Vector3fang_error;// attitude axis angle error (error state formulation)
Vector3fang_error;// attitude axis angle error (error state formulation)
Vector3fvel;// NED velocity in earth frame in m/s
Vector3fvel;// NED velocity in earth frame in m/s
@ -259,17 +324,20 @@ union gps_check_fail_status_u {
// bitmask containing filter control status
// bitmask containing filter control status
unionfilter_control_status_u{
unionfilter_control_status_u{
struct{
struct{
uint8_ttilt_align:1;// 0 - true if the filter tilt alignment is complete
uint16_ttilt_align:1;// 0 - true if the filter tilt alignment is complete
uint8_tyaw_align:1;// 1 - true if the filter yaw alignment is complete
uint16_tyaw_align:1;// 1 - true if the filter yaw alignment is complete
uint8_tgps:1;// 2 - true if GPS measurements are being fused
uint16_tgps:1;// 2 - true if GPS measurements are being fused
uint8_topt_flow:1;// 3 - true if optical flow measurements are being fused
uint16_topt_flow:1;// 3 - true if optical flow measurements are being fused
uint8_tmag_hdg:1;// 4 - true if a simple magnetic yaw heading is being fused
uint16_tmag_hdg:1;// 4 - true if a simple magnetic yaw heading is being fused
uint8_tmag_2D:1;// 5 - true if the horizontal projection of magnetometer data is being fused
uint16_tmag_2D:1;// 5 - true if the horizontal projection of magnetometer data is being fused
uint8_tmag_3D:1;// 6 - true if 3-axis magnetometer measurement are being fused
uint16_tmag_3D:1;// 6 - true if 3-axis magnetometer measurement are being fused
uint8_tmag_dec:1;// 7 - true if synthetic magnetic declination measurements are being fused
uint16_tmag_dec:1;// 7 - true if synthetic magnetic declination measurements are being fused
uint8_tin_air:1;// 8 - true when the vehicle is airborne
uint16_tin_air:1;// 8 - true when the vehicle is airborne
uint8_tarmed:1;// 9 - true when the vehicle motors are armed
uint16_tarmed:1;// 9 - true when the vehicle motors are armed
uint8_twind:1;// 10 - true when wind velocity is being estimated
uint16_twind:1;// 10 - true when wind velocity is being estimated
uint16_tbaro_hgt:1;// 11 - true when baro height is being fused as a primary height reference
uint16_trng_hgt:1;// 12 - true when range finder height is being fused as a primary height reference
uint16_tgps_hgt:1;// 15 - true when range finder height is being fused as a primary height reference