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
97 static void alt_kalman(
float z_meas,
float dt);
172 float dt = (float)(now_ts - last_ts) / 1e6;
176 Bound(dt, 0.002, 1.0)
225 const float dt = GPS_DT;
232 float dt = (float)(now_ts - last_ts) / 1e6;
254 gps_s->ned_vel.
x / 100.0f,
255 gps_s->ned_vel.y / 100.0f,
265 #define GPS_SIGMA2 1.
268 static float p[2][2];
292 #elif USE_BARO_MS5534A
302 #elif USE_BARO_MS5611
318 #endif // USE_BAROMETER
321 q[0][0] = dt * dt * dt * dt / 4.;
322 q[0][1] = dt * dt * dt / 2.;
323 q[1][0] = dt * dt * dt / 2.;
329 p[0][0] = p[0][0] + p[1][0] * dt + dt * (p[0][1] + p[1][1] * dt) + SIGMA2 * q[0][0];
330 p[0][1] = p[0][1] + p[1][1] * dt + SIGMA2 * q[0][1];
331 p[1][0] = p[1][0] + p[1][1] * dt + SIGMA2 * q[1][0];
332 p[1][1] = p[1][1] + SIGMA2 * q[1][1];
335 float e = p[0][0] + R;
337 if (fabs(e) > 1e-5) {
338 float k_0 = p[0][0] / e;
339 float k_1 = p[1][0] / e;
346 p[1][0] = -p[0][0] * k_1 + p[1][0];
347 p[1][1] = -p[0][1] * k_1 + p[1][1];
348 p[0][0] = p[0][0] * (1 - k_0);
349 p[0][1] = p[0][1] * (1 - k_0);
352 #ifdef DEBUG_ALT_KALMAN
365 uint32_t stamp __attribute__((unused)),
372 uint32_t stamp __attribute__((unused)),
Event structure to store callbacks in a linked list.
static void baro_cb(uint8_t sender_id, uint32_t stamp, float pressure)
void ins_reset_local_origin(void)
Reset the geographic reference to the current GPS fix.
static void orientationSetQuat_f(struct OrientationReps *orientation, struct FloatQuat *quat)
Set vehicle body attitude from quaternion (float).
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
static struct Int32RMat * orientationGetRMat_i(struct OrientationReps *orientation)
Get vehicle body attitude rotation matrix (int).
Common barometric sensor implementation.
static abi_event accel_ev
float alt
in meters (above WGS84 reference ellipsoid or above MSL)
static abi_event body_to_imu_ev
float ground_alt
size == nb_waypoint, waypoint 0 is a dummy waypoint
static void gps_cb(uint8_t sender_id, uint32_t stamp, struct GpsState *gps_s)
static struct Int32RMat * stateGetNedToBodyRMat_i(void)
Get vehicle body attitude rotation matrix (int).
static void accel_cb(uint8_t sender_id, uint32_t stamp, struct Int32Vect3 *accel)
Main include for ABI (AirBorneInterface).
static void alt_kalman_init(void)
position in UTM coordinates Units: meters
float alt
estimated altitude above MSL in meters
#define GPS_FIX_3D
3D GPS fix
void ins_alt_float_update_baro(float pressure)
Ins implementation state (altitude, float)
static void body_to_imu_cb(uint8_t sender_id, struct FloatQuat *q_b2i_f)
static void stateSetPositionUtm_f(struct UtmCoor_f *utm_pos)
Set position from UTM coordinates (float).
static void stateSetAccelNed_i(struct NedCoor_i *ned_accel)
Set acceleration in NED coordinates (int).
static void stateSetSpeedNed_f(struct NedCoor_f *ned_speed)
Set ground speed in local NED coordinates (float).
static void orientationSetEulers_i(struct OrientationReps *orientation, struct Int32Eulers *eulers)
Set vehicle body attitude from euler angles (int).
static void alt_kalman(float z_meas, float dt)
struct InsAltFloat ins_altf
int32_t hmsl
height above mean sea level (MSL) in mm
vector in North East Down coordinates Units: meters
void ins_alt_float_update_gps(struct GpsState *gps_s)
static struct NedCoor_f * stateGetSpeedNed_f(void)
Get ground speed in local NED coordinates (float).
Architecture independent timing functions.
data structure for GPS information
void ins_alt_float_init(void)
Device independent GPS code (interface)
Paparazzi atmospheric pressure conversion utilities.
bool reset_alt_ref
flag to request reset of altitude reference to current alt
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
float baro_MS5534A_sigma2
struct UtmCoor_f utm_origin_f
Definition of the origin of Utm coordinate system.
static struct UtmCoor_f * stateGetPositionUtm_f(void)
Get position in UTM coordinates (float).
struct UtmCoor_f utm_float_from_gps(struct GpsState *gps_s, uint8_t zone)
Convenience functions to get utm position from GPS state.
API to get/set the generic vehicle states.
vector in North East Down coordinates
void int32_rmat_transp_vmult(struct Int32Vect3 *vb, struct Int32RMat *m_b2a, struct Int32Vect3 *va)
rotate 3D vector by transposed rotation matrix.
Common code for AP and FBW telemetry.
float alt_dot
estimated vertical speed in m/s (positive-up)
static struct OrientationReps body_to_imu
Filters altitude and climb rate for fixedwings.
static float pprz_isa_height_of_pressure(float pressure, float ref_p)
Get relative altitude from pressure (using simplified equation).
#define ACCEL_BFP_OF_REAL(_af)
Fixedwing Navigation library.
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
static void alt_kalman_reset(void)
void ins_reset_altitude_ref(void)
INS altitude reference reset.
static void stateSetLocalUtmOrigin_f(struct UtmCoor_f *utm_def)
Set the local (flat earth) coordinate frame origin from UTM (float).
struct GpsState gps
global GPS state
#define INS_ALT_GPS_ID
ABI binding for gps data.
bool origin_initialized
TRUE if UTM origin was initialized.
#define UTM_COPY(_u1, _u2)