|
|
@ -30,6 +30,7 @@ |
|
|
|
#include "AP_NavEKF2.h" |
|
|
|
#include "AP_NavEKF2.h" |
|
|
|
#include <stdio.h> |
|
|
|
#include <stdio.h> |
|
|
|
#include <AP_Math/vectorN.h> |
|
|
|
#include <AP_Math/vectorN.h> |
|
|
|
|
|
|
|
#include <AP_NavEKF/AP_NavEKF_core_common.h> |
|
|
|
#include <AP_NavEKF2/AP_NavEKF2_Buffer.h> |
|
|
|
#include <AP_NavEKF2/AP_NavEKF2_Buffer.h> |
|
|
|
#include <AP_InertialSensor/AP_InertialSensor.h> |
|
|
|
#include <AP_InertialSensor/AP_InertialSensor.h> |
|
|
|
|
|
|
|
|
|
|
@ -58,7 +59,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
class AP_AHRS; |
|
|
|
class AP_AHRS; |
|
|
|
|
|
|
|
|
|
|
|
class NavEKF2_core |
|
|
|
class NavEKF2_core : public NavEKF_core_common |
|
|
|
{ |
|
|
|
{ |
|
|
|
public: |
|
|
|
public: |
|
|
|
// Constructor
|
|
|
|
// Constructor
|
|
|
@ -327,9 +328,6 @@ public: |
|
|
|
// return true when external nav data is also being used as a yaw observation
|
|
|
|
// return true when external nav data is also being used as a yaw observation
|
|
|
|
bool isExtNavUsedForYaw(void); |
|
|
|
bool isExtNavUsedForYaw(void); |
|
|
|
|
|
|
|
|
|
|
|
// return size of core_common for use in frontend allocation
|
|
|
|
|
|
|
|
static uint32_t get_core_common_size(void) { return sizeof(core_common); } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
private: |
|
|
|
// Reference to the global EKF frontend for parameters
|
|
|
|
// Reference to the global EKF frontend for parameters
|
|
|
|
NavEKF2 *frontend; |
|
|
|
NavEKF2 *frontend; |
|
|
@ -339,7 +337,6 @@ private: |
|
|
|
uint8_t core_index; |
|
|
|
uint8_t core_index; |
|
|
|
uint8_t imu_buffer_length; |
|
|
|
uint8_t imu_buffer_length; |
|
|
|
|
|
|
|
|
|
|
|
typedef float ftype; |
|
|
|
|
|
|
|
#if MATH_CHECK_INDEXES |
|
|
|
#if MATH_CHECK_INDEXES |
|
|
|
typedef VectorN<ftype,2> Vector2; |
|
|
|
typedef VectorN<ftype,2> Vector2; |
|
|
|
typedef VectorN<ftype,3> Vector3; |
|
|
|
typedef VectorN<ftype,3> Vector3; |
|
|
@ -359,7 +356,6 @@ private: |
|
|
|
typedef VectorN<ftype,24> Vector24; |
|
|
|
typedef VectorN<ftype,24> Vector24; |
|
|
|
typedef VectorN<ftype,25> Vector25; |
|
|
|
typedef VectorN<ftype,25> Vector25; |
|
|
|
typedef VectorN<ftype,31> Vector31; |
|
|
|
typedef VectorN<ftype,31> Vector31; |
|
|
|
typedef VectorN<ftype,28> Vector28; |
|
|
|
|
|
|
|
typedef VectorN<VectorN<ftype,3>,3> Matrix3; |
|
|
|
typedef VectorN<VectorN<ftype,3>,3> Matrix3; |
|
|
|
typedef VectorN<VectorN<ftype,24>,24> Matrix24; |
|
|
|
typedef VectorN<VectorN<ftype,24>,24> Matrix24; |
|
|
|
typedef VectorN<VectorN<ftype,34>,50> Matrix34_50; |
|
|
|
typedef VectorN<VectorN<ftype,34>,50> Matrix34_50; |
|
|
@ -382,7 +378,6 @@ private: |
|
|
|
typedef ftype Vector23[23]; |
|
|
|
typedef ftype Vector23[23]; |
|
|
|
typedef ftype Vector24[24]; |
|
|
|
typedef ftype Vector24[24]; |
|
|
|
typedef ftype Vector25[25]; |
|
|
|
typedef ftype Vector25[25]; |
|
|
|
typedef ftype Vector28[28]; |
|
|
|
|
|
|
|
typedef ftype Matrix3[3][3]; |
|
|
|
typedef ftype Matrix3[3][3]; |
|
|
|
typedef ftype Matrix24[24][24]; |
|
|
|
typedef ftype Matrix24[24][24]; |
|
|
|
typedef ftype Matrix34_50[34][50]; |
|
|
|
typedef ftype Matrix34_50[34][50]; |
|
|
@ -485,22 +480,6 @@ private: |
|
|
|
bool posReset; // true when the position measurement has been reset
|
|
|
|
bool posReset; // true when the position measurement has been reset
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
common intermediate variables used by all cores. These save a |
|
|
|
|
|
|
|
lot memory by avoiding allocating these arrays on every core |
|
|
|
|
|
|
|
Having these as stack variables would save even more memory, but |
|
|
|
|
|
|
|
would give us very high stack usage in some functions, which |
|
|
|
|
|
|
|
poses a risk of stack overflow until we have infrastructure in |
|
|
|
|
|
|
|
place to calculate maximum stack usage using static analysis. |
|
|
|
|
|
|
|
On SITL this structure is assumed to contain only float |
|
|
|
|
|
|
|
variables (for the fill_nanf()) |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
struct core_common { |
|
|
|
|
|
|
|
Matrix24 KH; |
|
|
|
|
|
|
|
Matrix24 KHP; |
|
|
|
|
|
|
|
Matrix24 nextP; |
|
|
|
|
|
|
|
} *common; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// bias estimates for the IMUs that are enabled but not being used
|
|
|
|
// bias estimates for the IMUs that are enabled but not being used
|
|
|
|
// by this core.
|
|
|
|
// by this core.
|
|
|
|
struct { |
|
|
|
struct { |
|
|
@ -818,8 +797,6 @@ private: |
|
|
|
bool badIMUdata; // boolean true if the bad IMU data is detected
|
|
|
|
bool badIMUdata; // boolean true if the bad IMU data is detected
|
|
|
|
|
|
|
|
|
|
|
|
float gpsNoiseScaler; // Used to scale the GPS measurement noise and consistency gates to compensate for operation with small satellite counts
|
|
|
|
float gpsNoiseScaler; // Used to scale the GPS measurement noise and consistency gates to compensate for operation with small satellite counts
|
|
|
|
Matrix24 &KH; // intermediate result used for covariance updates
|
|
|
|
|
|
|
|
Matrix24 &KHP; // intermediate result used for covariance updates
|
|
|
|
|
|
|
|
Matrix24 P; // covariance matrix
|
|
|
|
Matrix24 P; // covariance matrix
|
|
|
|
imu_ring_buffer_t<imu_elements> storedIMU; // IMU data buffer
|
|
|
|
imu_ring_buffer_t<imu_elements> storedIMU; // IMU data buffer
|
|
|
|
obs_ring_buffer_t<gps_elements> storedGPS; // GPS data buffer
|
|
|
|
obs_ring_buffer_t<gps_elements> storedGPS; // GPS data buffer
|
|
|
@ -874,7 +851,6 @@ private: |
|
|
|
bool allMagSensorsFailed; // true if all magnetometer sensors have timed out on this flight and we are no longer using magnetometer data
|
|
|
|
bool allMagSensorsFailed; // true if all magnetometer sensors have timed out on this flight and we are no longer using magnetometer data
|
|
|
|
uint32_t lastYawTime_ms; // time stamp when yaw observation was last fused (msec)
|
|
|
|
uint32_t lastYawTime_ms; // time stamp when yaw observation was last fused (msec)
|
|
|
|
uint32_t ekfStartTime_ms; // time the EKF was started (msec)
|
|
|
|
uint32_t ekfStartTime_ms; // time the EKF was started (msec)
|
|
|
|
Matrix24 &nextP; // Predicted covariance matrix before addition of process noise to diagonals
|
|
|
|
|
|
|
|
Vector2f lastKnownPositionNE; // last known position
|
|
|
|
Vector2f lastKnownPositionNE; // last known position
|
|
|
|
uint32_t lastDecayTime_ms; // time of last decay of GPS position offset
|
|
|
|
uint32_t lastDecayTime_ms; // time of last decay of GPS position offset
|
|
|
|
float velTestRatio; // sum of squares of GPS velocity innovation divided by fail threshold
|
|
|
|
float velTestRatio; // sum of squares of GPS velocity innovation divided by fail threshold
|
|
|
|