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
96 static void alt_kalman(
float z_meas,
float dt);
178 float dt = (float)(now_ts -
last_ts) / 1e6;
182 Bound(dt, 0.002, 1.0)
232 const float dt = GPS_DT;
239 float dt = (float)(now_ts -
last_ts) / 1e6;
269 #define GPS_SIGMA2 1.
272 static float p[2][2];
296 #elif USE_BARO_MS5534A
306 #elif USE_BARO_MS5611
325 q[0][0] = dt * dt * dt * dt / 4.;
326 q[0][1] = dt * dt * dt / 2.;
327 q[1][0] = dt * dt * dt / 2.;
333 p[0][0] =
p[0][0] +
p[1][0] * dt + dt * (
p[0][1] +
p[1][1] * dt) + SIGMA2 * q[0][0];
334 p[0][1] =
p[0][1] +
p[1][1] * dt + SIGMA2 * q[0][1];
335 p[1][0] =
p[1][0] +
p[1][1] * dt + SIGMA2 * q[1][0];
336 p[1][1] =
p[1][1] + SIGMA2 * q[1][1];
339 float e =
p[0][0] + R;
341 if (fabs(e) > 1e-5) {
342 float k_0 =
p[0][0] / e;
343 float k_1 =
p[1][0] / e;
350 p[1][0] = -
p[0][0] * k_1 +
p[1][0];
351 p[1][1] = -
p[0][1] * k_1 +
p[1][1];
352 p[0][0] =
p[0][0] * (1 - k_0);
353 p[0][1] =
p[0][1] * (1 - k_0);
356 #ifdef DEBUG_ALT_KALMAN
369 uint32_t stamp __attribute__((unused)),
376 uint32_t stamp __attribute__((unused)),
Main include for ABI (AirBorneInterface).
#define ABI_BROADCAST
Broadcast address.
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(uint16_t id, struct NedCoor_i *ned_accel)
Set acceleration in NED coordinates (int).
static void stateSetAccelBody_i(uint16_t id, struct Int32Vect3 *body_accel)
Set acceleration in Body coordinates (int).
static struct Int32RMat * stateGetNedToBodyRMat_i(void)
Get vehicle body attitude rotation matrix (int).
static struct UtmCoor_f * stateGetUtmOrigin_f(void)
Get the coordinate UTM frame origin (int)
static struct UtmCoor_f * stateGetPositionUtm_f(void)
Get position in UTM coordinates (float).
static void stateSetPositionUtm_f(uint16_t id, struct UtmCoor_f *utm_pos)
Set position from UTM coordinates (float).
static void stateSetLocalUtmOrigin_f(uint16_t id, struct UtmCoor_f *utm_def)
Set the local (flat earth) coordinate frame origin from UTM (float).
static void stateSetSpeedNed_f(uint16_t id, struct NedCoor_f *ned_speed)
Set ground speed in local NED coordinates (float).
static struct NedCoor_f * stateGetSpeedNed_f(void)
Get ground speed in local NED coordinates (float).
#define INS_RESET_VERTICAL_REF
#define INS_RESET_REF
flags for INS reset
static void reset_vertical_ref(void)
static void gps_cb(uint8_t sender_id, uint32_t stamp, struct GpsState *gps_s)
static void reset_cb(uint8_t sender_id, uint8_t flag)
static void reset_ref(void)
static abi_event accel_ev
#define INS_ALT_GPS_ID
ABI binding for gps data.
static void alt_kalman_init(void)
static abi_event reset_ev
static void alt_kalman(float z_meas, float dt)
static void baro_cb(uint8_t sender_id, uint32_t stamp, float pressure)
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.