|
Paparazzi UAS
v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
|
Go to the documentation of this file.
36 #include "generated/airframe.h"
37 #include "generated/flight_plan.h"
50 #if SEND_INVARIANT_FILTER || PERIODIC_TELEMETRY
54 #if LOG_INVARIANT_FILTER
97 #define INS_INV_MVZ 15.
101 #define INS_INV_MH 0.2
105 #define INS_INV_NX 0.8
109 #define INS_INV_NXZ 0.5
113 #define INS_INV_NH 1.2
117 #define INS_INV_OV 1.2
121 #define INS_INV_OB 1.
125 #define INS_INV_RV 4.
129 #define INS_INV_RH 8.
133 #define INS_INV_SH 0.01
144 #define B ins_float_inv.mag_h
153 #ifndef INS_INV_HEADING_UPDATE_GPS_MIN_SPEED
154 #define INS_INV_HEADING_UPDATE_GPS_MIN_SPEED 5.f
161 static inline void invariant_model(
float *o,
const float *
x,
const int n,
const float *u,
const int m);
192 #if SEND_INVARIANT_FILTER || PERIODIC_TELEMETRY
197 pprz_msg_send_INV_FILTER(trans,
dev,
227 utm0.
alt = GROUND_ALT;
233 llh_nav0.
lat = NAV_LAT0;
234 llh_nav0.
lon = NAV_LON0;
236 llh_nav0.
alt = NAV_ALT0 + NAV_MSL0;
276 #if PERIODIC_TELEMETRY
317 struct FloatVect3 *lp_mag __attribute__((unused)))
389 #if SEND_INVARIANT_FILTER
393 #if LOG_INVARIANT_FILTER
398 "p q r ax ay az gx gy gz gvx gvy gvz mx my mz b qi qx qy qz bp bq br vx vy vz px py pz hb as\n");
402 "%.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f %.3f\n",
459 struct NedCoor_i gps_pos_cm_ned, ned_pos;
470 #if !USE_MAGNETOMETER
494 static float alpha = 10.0f;
496 static float baro_moy = 0.0f;
497 static float baro_prev = 0.0f;
504 baro_prev = pressure;
506 baro_moy = (baro_moy * (i - 1) + pressure) / i;
507 alpha = (10.*
alpha + (baro_moy - baro_prev)) / (11.0f);
508 baro_prev = baro_moy;
510 if (fabs(
alpha) < 0.1f) {
525 #define MAG_FROZEN_COUNT 30
532 if (last_mx == mag->
x) {
534 if (mag_frozen_count == 0) {
555 static inline void invariant_model(
float *o,
const float *x,
const int n,
const float *u,
556 const int m __attribute__((unused)))
559 #pragma GCC diagnostic push // require GCC 4.6
560 #pragma GCC diagnostic ignored "-Wcast-qual"
563 #pragma GCC diagnostic pop // require GCC 4.6
599 if (
s->as < 0.5f ||
s->as > 1.5f) {
607 memcpy(o, &s_dot, n *
sizeof(
float));
661 temp = (_ins->
gains.
lb / 100.) * temp;
683 temp = (-_ins->
gains.
ob / 1000.) * temp;
float mvz
Tuning parameter of vertical speed error on speed.
float nxz
Tuning parameter of vertical position error on position.
bool ins_baro_initialized
VIC slots used for the LPC2148 define name e g gps UART1_VIC_SLOT e g modem SPI1_VIC_SLOT SPI1 in mcu_periph spi_arch c or spi_slave_hs_arch c(and some others not using the SPI peripheral yet..) I2C0_VIC_SLOT 8 mcu_periph/i2c_arch.c I2C1_VIC_SLOT 9 mcu_periph/i2c_arch.c USB_VIC_SLOT 10 usb
bool reset
flag to request reset/reinit the filter
void float_quat_vmul_right(struct FloatQuat *mright, const struct FloatQuat *q, struct FloatVect3 *vi)
Right multiplication by a quaternion.
int32_t lon
in degrees*1e7
static void send_inv_filter(struct transport_tx *trans, struct link_device *dev)
vector in North East Down coordinates Units: meters
struct FloatVect3 ME
Correction gains on gyro biases.
float rh
Tuning parameter of baro error on accel biases (vertical projection)
float sh
Tuning parameter of baro error on baro bias.
int32_t alt
in millimeters above WGS84 reference ellipsoid
#define INT32_VECT3_SCALE_2(_a, _b, _num, _den)
static void stateSetSpeedNed_f(struct NedCoor_f *ned_speed)
Set ground speed in local NED coordinates (float).
void ltp_def_from_ecef_i(struct LtpDef_i *def, struct EcefCoor_i *ecef)
#define VECT3_SMUL(_vo, _vi, _s)
static void float_quat_identity(struct FloatQuat *q)
initialises a quaternion to identity
static void invariant_model(float *o, const float *x, const int n, const float *u, const int m)
Compute dynamic mode.
struct LtpDef_i ned_origin_i
Definition of the local (flat earth) coordinate system.
struct inv_command cmd
command vector
#define INS_INV_HEADING_UPDATE_GPS_MIN_SPEED
struct VehicleInterface vi
#define FLOAT_RATES_ZERO(_r)
struct FloatRates rates
Input gyro rates.
definition of the local (flat earth) coordinate system
#define VECT3_CROSS_PRODUCT(_vo, _v1, _v2)
struct NedCoor_f speed
Estimates speed.
struct inv_correction_gains corr
correction gains
void ned_of_ecef_vect_f(struct NedCoor_f *ned, struct LtpDef_f *def, struct EcefCoor_f *ecef)
data structure for GPS information
#define VECT3_SUM(_c, _a, _b)
#define VECT3_DIFF(_c, _a, _b)
#define VECT3_DOT_PRODUCT(_v1, _v2)
void ecef_of_lla_i(struct EcefCoor_i *out, struct LlaCoor_i *in)
Convert a LLA to ECEF.
static void init_invariant_state(void)
static void stateSetPositionUtm_f(struct UtmCoor_f *utm_pos)
Set position from UTM coordinates (float).
Paparazzi floating point algebra.
struct FloatRates bias
Estimated gyro biases.
#define VECT3_ADD(_a, _b)
static void stateSetAccelBody_i(struct Int32Vect3 *body_accel)
Set acceleration in Body coordinates (int).
#define INT32_POS_OF_CM_NUM
float RE
Correction gains on accel bias.
Runge-Kutta library (float version)
struct NedCoor_i ned_vel
speed NED in cm/s
#define INT32_POS_OF_CM_DEN
static struct FloatRMat * orientationGetRMat_f(struct OrientationReps *orientation)
Get vehicle body attitude rotation matrix (float).
float ov
Tuning parameter of speed error on gyro biases.
float lv
Tuning parameter of speed error on attitude.
Paparazzi fixed point algebra.
float mv
Tuning parameter of horizontal speed error on speed.
Invariant filter structure.
struct NedCoor_f pos
Estimates position.
void float_rmat_transp_vmult(struct FloatVect3 *vb, struct FloatRMat *m_b2a, struct FloatVect3 *va)
rotate 3D vector by transposed rotation matrix.
int32_t lat
in degrees*1e7
#define NED_FLOAT_OF_BFP(_o, _i)
void ins_reset_altitude_ref(void)
INS altitude reference reset.
static void error_output(struct InsFloatInv *_ins)
Compute correction vectors E = ( ลท - y ) LE, ME, NE, OE : ( gain matrix * error )
#define RATES_ASSIGN(_ra, _p, _q, _r)
static void stateSetLocalUtmOrigin_f(struct UtmCoor_f *utm_def)
Set the local (flat earth) coordinate frame origin from UTM (float).
#define INV_STATE_DIM
Invariant filter state dimension.
static float float_vect2_norm(struct FloatVect2 *v)
#define ACCELS_BFP_OF_REAL(_ef, _ei)
struct inv_gains gains
tuning gains
Device independent GPS code (interface)
void ins_float_invariant_init(void)
float alt
in meters (above WGS84 reference ellipsoid or above MSL)
#define RATES_DIFF(_c, _a, _b)
uint8_t zone
UTM zone number.
float SE
Correction gains on barometer bias.
#define FLOAT_VECT3_ZERO(_v)
static void orientationSetQuat_f(struct OrientationReps *orientation, struct FloatQuat *quat)
Set vehicle body attitude from quaternion (float).
vector in EarthCenteredEarthFixed coordinates
vector in North East Down coordinates
static const struct usb_device_descriptor dev
static void stateSetBodyRates_f(struct FloatRates *body_rate)
Set vehicle body angular rate (float).
#define ECEF_FLOAT_OF_BFP(_o, _i)
bool utm_initialized_f
True if utm origin (float) coordinate frame is initialsed.
static void float_quat_normalize(struct FloatQuat *q)
static void float_quat_invert(struct FloatQuat *qo, struct FloatQuat *qi)
struct inv_measures meas
measurement vector
struct inv_state state
state vector
static void runge_kutta_4_float(float *xo, const float *x, const int n, const float *u, const int m, void(*f)(float *o, const float *x, const int n, const float *u, const int m), const float dt)
Fourth-Order Runge-Kutta.
float nh
Tuning parameter of baro error on vertical position.
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
struct LtpDef_f ned_origin_f
Definition of the local (flat earth) coordinate system.
#define FLOAT_QUAT_NORM2(_q)
struct NedCoor_f pos_gps
Measured gps position.
static void stateSetLocalOrigin_i(struct LtpDef_i *ltp_def)
Set the local (flat earth) coordinate frame origin (int).
void ins_float_invariant_update_mag(struct FloatVect3 *mag)
float NE
Correction gains on accel bias.
void ins_float_invariant_update_gps(struct GpsState *gps_s)
float lb
Tuning parameter of mag error on attitude.
float mh
Tuning parameter of baro error on vertical speed.
struct NedCoor_f speed_gps
Measured gps speed.
void ltp_def_from_lla_i(struct LtpDef_i *def, struct LlaCoor_i *lla)
void float_quat_vmult(struct FloatVect3 *v_out, struct FloatQuat *q, const struct FloatVect3 *v_in)
rotate 3D vector by quaternion.
static float pprz_isa_height_of_pressure(float pressure, float ref_p)
Get relative altitude from pressure (using simplified equation).
static void stateSetAccelNed_f(struct NedCoor_f *ned_accel)
Set acceleration in NED coordinates (float).
#define QUAT_SMUL(_qo, _qi, _s)
struct EcefCoor_i ecef_pos
position in ECEF in cm
Invariant filter command vector.
float OE
Correction gains on magnetometer sensitivity.
struct UtmCoor_f utm_float_from_gps(struct GpsState *gps_s, uint8_t zone)
Convenience functions to get utm position from GPS state.
#define INV_COMMAND_DIM
Invariant filter command vector dimension.
struct FloatVect3 LE
Correction gains on attitude.
static void ahrs_float_get_quat_from_accel(struct FloatQuat *q, struct FloatVect3 *accel)
Compute a quaternion representing roll and pitch from an accelerometer measurement.
void ins_float_invariant_align(struct FloatRates *lp_gyro, struct FloatVect3 *lp_accel, struct FloatVect3 *lp_mag)
void float_quat_derivative(struct FloatQuat *qd, struct FloatRates *r, struct FloatQuat *q)
Quaternion derivative from rotational velocity.
#define QUAT_ADD(_qo, _qi)
vector in Latitude, Longitude and Altitude
struct LlaCoor_i lla_pos
position in LLA (lat,lon: deg*1e7; alt: mm over ellipsoid)
int32_t hmsl
Height above mean sea level in mm.
void ins_reset_local_origin(void)
INS local origin reset.
vector in EarthCenteredEarthFixed coordinates
#define QUAT_ASSIGN(_q, _i, _x, _y, _z)
static void stateSetPositionNed_f(struct NedCoor_f *ned_pos)
Set position from local NED coordinates (float).
position in UTM coordinates Units: meters
#define FLOAT_QUAT_EXTRACT(_vo, _qi)
struct FloatVect3 accel
Input accelerometers.
int32_t hmsl
height above mean sea level (MSL) in mm
void float_rmat_transp_ratemult(struct FloatRates *rb, struct FloatRMat *m_b2a, struct FloatRates *ra)
rotate anglular rates by transposed rotation matrix.
static const struct FloatVect3 A
struct OrientationReps body_to_imu
body_to_imu rotation
struct UtmCoor_f utm_origin_f
Definition of the origin of Utm coordinate system.
float as
Estimated accelerometer sensitivity.
bool ned_initialized_f
True if local float coordinate frame is initialsed.
static void ahrs_float_get_quat_from_accel_mag(struct FloatQuat *q, struct FloatVect3 *accel, struct FloatVect3 *mag)
void ins_float_invariant_update_baro(float pressure)
struct InsFloatInv ins_float_inv
void ned_of_ecef_point_i(struct NedCoor_i *ned, struct LtpDef_i *def, struct EcefCoor_i *ecef)
Convert a point from ECEF to local NED.
float nx
Tuning parameter of horizontal position error on position.
struct FloatVect3 mag
Measured magnetic field.
void ins_float_invariant_propagate(struct FloatRates *gyro, struct FloatVect3 *accel, float dt)
void float_eulers_of_quat(struct FloatEulers *e, struct FloatQuat *q)
euler rotation 'ZYX'
struct EcefCoor_i ecef_vel
speed ECEF in cm/s
struct GpsState gps
global GPS state
#define GPS_FIX_3D
3D GPS fix
struct LlaCoor_i lla
Reference point in lla.
#define DefaultPeriodic
Set default periodic telemetry.
#define VECT3_COPY(_a, _b)
void ins_float_inv_set_body_to_imu_quat(struct FloatQuat *q_b2i)
static void stateSetNedToBodyQuat_f(struct FloatQuat *ned_to_body_quat)
Set vehicle body attitude from quaternion (float).
#define PPRZ_ISA_SEA_LEVEL_PRESSURE
ISA sea level standard atmospheric pressure in Pascal.
struct FloatQuat quat
Estimated attitude (quaternion)
float rv
Tuning parameter of speed error on accel biases.
Paparazzi atmospheric pressure conversion utilities.
float hb
Estimates barometers bias.
float baro_alt
Measured barometric altitude.
float ob
Tuning parameter of mag error on gyro biases.