40 #include "generated/airframe.h"
41 #include "generated/modules.h"
43 #ifdef DEBUG_ALT_KALMAN
48 #ifndef USE_INS_NAV_INIT
49 #define USE_INS_NAV_INIT TRUE
59 PRINT_CONFIG_MSG(
"USE_BAROMETER is TRUE: Using baro for altitude estimation.")
62 #ifndef INS_ALT_BARO_ID
64 #define INS_ALT_BARO_ID BARO_BOARD_SENDER_ID
66 #define INS_ALT_BARO_ID ABI_BROADCAST
78 #ifndef INS_ALT_GPS_ID
79 #define INS_ALT_GPS_ID GPS_MULTI_ID
85 #ifndef INS_ALT_IMU_ID
86 #define INS_ALT_IMU_ID ABI_BROADCAST
93 static void alt_kalman(
float z_meas,
float dt);
163 float dt = (float)(now_ts -
last_ts) / 1e6;
167 Bound(dt, 0.002, 1.0)
217 const float dt = GPS_DT;
224 float dt = (float)(now_ts -
last_ts) / 1e6;
254 #define GPS_SIGMA2 1.
257 static float p[2][2];
281 #elif USE_BARO_MS5534A
291 #elif USE_BARO_MS5611
310 q[0][0] = dt * dt * dt * dt / 4.;
311 q[0][1] = dt * dt * dt / 2.;
312 q[1][0] = dt * dt * dt / 2.;
318 p[0][0] =
p[0][0] +
p[1][0] * dt + dt * (
p[0][1] +
p[1][1] * dt) + SIGMA2 * q[0][0];
319 p[0][1] =
p[0][1] +
p[1][1] * dt + SIGMA2 * q[0][1];
320 p[1][0] =
p[1][0] +
p[1][1] * dt + SIGMA2 * q[1][0];
321 p[1][1] =
p[1][1] + SIGMA2 * q[1][1];
324 float e =
p[0][0] + R;
326 if (fabs(e) > 1e-5) {
327 float k_0 =
p[0][0] / e;
328 float k_1 =
p[1][0] / e;
335 p[1][0] = -
p[0][0] * k_1 +
p[1][0];
336 p[1][1] = -
p[0][1] * k_1 +
p[1][1];
337 p[0][0] =
p[0][0] * (1 - k_0);
338 p[0][1] =
p[0][1] * (1 - k_0);
341 #ifdef DEBUG_ALT_KALMAN
354 uint32_t stamp __attribute__((unused)),
361 uint32_t stamp __attribute__((unused)),
Main include for ABI (AirBorneInterface).
Event structure to store callbacks in a linked list.
Common barometric sensor implementation.
float baro_MS5534A_sigma2
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
float ground_alt
size == nb_waypoint, waypoint 0 is a dummy waypoint
Common code for AP and FBW telemetry.
struct UtmCoor_f utm_float_from_gps(struct GpsState *gps_s, uint8_t zone)
Convenience functions to get utm position from GPS state.
struct NedCoor_f ned_vel_float_from_gps(struct GpsState *gps_s)
Get GPS ned velocity (float) Converted on the fly if not available.
struct GpsState gps
global GPS state
Device independent GPS code (interface)
int32_t hmsl
height above mean sea level (MSL) in mm
#define GPS_FIX_3D
3D GPS fix
data structure for GPS information
#define ACCEL_BFP_OF_REAL(_af)
void int32_rmat_transp_vmult(struct Int32Vect3 *vb, struct Int32RMat *m_b2a, struct Int32Vect3 *va)
rotate 3D vector by transposed rotation matrix.
#define UTM_COPY(_u1, _u2)
vector in North East Down coordinates
static float pprz_isa_height_of_pressure(float pressure, float ref_p)
Get relative altitude from pressure (using simplified equation).
static void stateSetAccelNed_i(struct NedCoor_i *ned_accel)
Set acceleration in NED coordinates (int).
static struct Int32RMat * stateGetNedToBodyRMat_i(void)
Get vehicle body attitude rotation matrix (int).
static struct UtmCoor_f * stateGetPositionUtm_f(void)
Get position in UTM coordinates (float).
struct UtmCoor_f utm_origin_f
Definition of the origin of Utm coordinate system.
static void stateSetPositionUtm_f(struct UtmCoor_f *utm_pos)
Set position from UTM coordinates (float).
static void stateSetLocalUtmOrigin_f(struct UtmCoor_f *utm_def)
Set the local (flat earth) coordinate frame origin from UTM (float).
static void stateSetAccelBody_i(struct Int32Vect3 *body_accel)
Set acceleration in Body coordinates (int).
static struct NedCoor_f * stateGetSpeedNed_f(void)
Get ground speed in local NED coordinates (float).
static void stateSetSpeedNed_f(struct NedCoor_f *ned_speed)
Set ground speed in local NED coordinates (float).
void ins_reset_local_origin(void)
Reset the geographic reference to the current GPS fix.
static void gps_cb(uint8_t sender_id, uint32_t stamp, struct GpsState *gps_s)
static abi_event accel_ev
#define INS_ALT_GPS_ID
ABI binding for gps data.
static void alt_kalman_init(void)
static void alt_kalman(float z_meas, float dt)
static void baro_cb(uint8_t sender_id, uint32_t stamp, float pressure)
void ins_reset_altitude_ref(void)
INS altitude reference reset.
struct InsAltFloat ins_altf
static void accel_cb(uint8_t sender_id, uint32_t stamp, struct Int32Vect3 *accel)
void ins_alt_float_update_gps(struct GpsState *gps_s)
void ins_alt_float_init(void)
static void alt_kalman_reset(void)
void ins_alt_float_update_baro(float pressure)
Filters altitude and climb rate for fixedwings.
float alt_dot
estimated vertical speed in m/s (positive-up)
bool reset_alt_ref
flag to request reset of altitude reference to current alt
float alt
estimated altitude above MSL in meters
bool origin_initialized
TRUE if UTM origin was initialized.
Ins implementation state (altitude, float)
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
Fixedwing Navigation library.
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
float alt
in meters (above WGS84 reference ellipsoid or above MSL)
vector in North East Down coordinates Units: meters
position in UTM coordinates Units: meters
Paparazzi atmospheric pressure conversion utilities.
API to get/set the generic vehicle states.
Architecture independent timing functions.
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.