|
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"
48 #if defined SITL && USE_NPS
64 #error USE_SONAR needs USE_VFF_EXTENDED
67 #ifdef INS_SONAR_THROTTLE_THRESHOLD
71 #ifndef INS_SONAR_MIN_RANGE
72 #define INS_SONAR_MIN_RANGE 0.001
74 #ifndef INS_SONAR_MAX_RANGE
75 #define INS_SONAR_MAX_RANGE 4.0
77 #define VFF_R_SONAR_0 0.2
78 #ifndef VFF_R_SONAR_OF_M
79 #define VFF_R_SONAR_OF_M 0.2
86 #define INS_VFF_R_GPS 2.0
89 #ifndef INS_VFF_VZ_R_GPS
90 #define INS_VFF_VZ_R_GPS 2.0
95 #ifndef INS_MAX_PROPAGATION_STEPS
96 #define INS_MAX_PROPAGATION_STEPS 200
99 #ifndef USE_INS_NAV_INIT
100 #define USE_INS_NAV_INIT TRUE
105 #define INS_BARO_MAX_INIT_VAR 1.f // variance threshold to set initial baro measurement
106 #ifndef INS_INT_BARO_ID
108 #define INS_INT_BARO_ID BARO_BOARD_SENDER_ID
110 #define INS_INT_BARO_ID ABI_BROADCAST
120 #ifndef INS_INT_IMU_ID
121 #define INS_INT_IMU_ID ABI_BROADCAST
126 #ifndef INS_INT_GPS_ID
127 #define INS_INT_GPS_ID GPS_MULTI_ID
135 #ifndef INS_INT_VEL_ID
136 #define INS_INT_VEL_ID ABI_BROADCAST
141 float x,
float y,
float z,
142 float noise_x,
float noise_y,
float noise_z);
143 #ifndef INS_INT_POS_ID
144 #define INS_INT_POS_ID ABI_BROADCAST
149 float x,
float y,
float z,
150 float noise_x,
float noise_y,
float noise_z);
155 #ifndef INS_INT_AGL_ID
156 #define INS_INT_AGL_ID ABI_BROADCAST
163 #if PERIODIC_TELEMETRY
166 static void send_ins(
struct transport_tx *trans,
struct link_device *
dev)
168 pprz_msg_send_INS(trans,
dev, AC_ID,
176 pprz_msg_send_INS_Z(trans,
dev, AC_ID,
183 pprz_msg_send_INS_REF(trans,
dev, AC_ID,
194 static void ins_update_from_hff(
void);
228 #if PERIODIC_TELEMETRY
314 ins_update_from_hff();
337 #define press_hist_len 10
341 press_hist[
idx] = pressure;
352 float height_correction = 0.f;
356 double dist2_to_origin = enu->
x * enu->
x + enu->
y * enu->
y;
359 const double earth_radius = 6378137.0;
360 height_correction = (float)(sqrt(earth_radius * earth_radius + dist2_to_origin) - earth_radius);
401 #ifdef INS_BODY_TO_GPS_X
404 .
x = INS_BODY_TO_GPS_X,
405 .y = INS_BODY_TO_GPS_Y,
406 .z = INS_BODY_TO_GPS_Z
424 #if INS_USE_GPS_ALT_SPEED
436 VECT2_ASSIGN(gps_speed_m_s_ned, gps_speed_cm_s_ned.
x, gps_speed_cm_s_ned.
y);
437 VECT2_SDIV(gps_speed_m_s_ned, gps_speed_m_s_ned, 100.
f);
446 ins_update_from_hff();
470 static void agl_cb(
uint8_t __attribute__((unused)) sender_id, __attribute__((unused))
uint32_t stamp,
float distance) {
480 #ifdef INS_AGL_THROTTLE_THRESHOLD
485 #ifdef INS_AGL_BARO_THRESHOLD
492 vff_update_agl(-distance, VFF_R_SONAR_0 + VFF_R_SONAR_OF_M * fabsf(distance));
501 static void agl_cb(
uint8_t __attribute__((unused)) sender_id, __attribute__((unused))
uint32_t stamp, __attribute__((unused))
float distance) {}
511 #if defined SITL && USE_NPS
528 static void ins_update_from_hff(
void)
547 if (last_stamp > 0) {
548 float dt = (float)(stamp - last_stamp) * 1e-6;
555 uint32_t stamp __attribute__((unused)),
565 uint32_t stamp __attribute__((unused)),
566 float x,
float y,
float z,
567 float noise_x,
float noise_y,
float noise_z)
583 ins_update_from_hff();
594 static uint32_t last_stamp_x = 0, last_stamp_y = 0;
595 if (noise_x >= 0.
f) {
596 if (last_stamp_x > 0)
598 float dt = (float)(stamp - last_stamp_x) * 1e-6;
601 last_stamp_x = stamp;
606 if (last_stamp_y > 0)
608 float dt = (float)(stamp - last_stamp_y) * 1e-6;
611 last_stamp_y = stamp;
627 uint32_t stamp __attribute__((unused)),
628 float x,
float y,
float z,
629 float noise_x,
float noise_y,
float noise_z)
637 ins_update_from_hff();
static void stateSetAccelNed_i(struct NedCoor_i *ned_accel)
Set acceleration in NED coordinates (int).
static void ins_update_from_vff(void)
update ins state from vertical filter
int32_t lon
in degrees*1e7
void ins_reset_local_origin(void)
INS local origin reset.
int32_t alt
in millimeters above WGS84 reference ellipsoid
bool hf_realign
request to realign horizontal filter.
float baro_z
z-position calculated from baro in meters (z-down)
void ins_int_propagate(struct Int32Vect3 *accel, float dt)
void ltp_def_from_ecef_i(struct LtpDef_i *def, struct EcefCoor_i *ecef)
struct NedCoor_i ltp_accel
struct LtpDef_i ned_origin_i
Definition of the local (flat earth) coordinate system.
void vff_update_vz_conf(float vz_meas, float conf)
Paparazzi fixed point math for geodetic calculations.
void ins_int_update_gps(struct GpsState *gps_s)
struct EcefCoor_i ecef
Reference point in ecef.
data structure for GPS information
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
static struct Int32Quat * stateGetNedToBodyQuat_i(void)
Get vehicle body attitude quaternion (int).
Event structure to store callbacks in a linked list.
#define SPEED_BFP_OF_REAL(_af)
struct OrientationReps body_to_imu
rotation from body to imu frame
uint32_t propagation_cnt
number of propagation steps since the last measurement update
void vff_update_z_conf(float z_meas, float conf)
#define VECT3_SUB(_a, _b)
static void baro_cb(uint8_t sender_id, uint32_t stamp, float pressure)
static void send_ins_z(struct transport_tx *trans, struct link_device *dev)
static void stateSetAccelBody_i(struct Int32Vect3 *body_accel)
Set acceleration in Body coordinates (int).
#define INT32_POS_OF_CM_NUM
float z
z-position estimate in m (NED, z-down)
#define INS_INT_IMU_ID
ABI binding for IMU data.
#define INS_SONAR_MIN_RANGE
Default AGL sensor minimum range.
#define INT32_POS_OF_CM_DEN
#define VECT2_SDIV(_vo, _vi, _s)
static void gps_cb(uint8_t sender_id, uint32_t stamp, struct GpsState *gps_s)
int32_t lat
in degrees*1e7
void vff_update(float z_meas)
#define INT32_VECT3_ZERO(_v)
static struct Int32RMat * stateGetNedToBodyRMat_i(void)
Get vehicle body attitude rotation matrix (int).
void hff_init(float init_x, float init_xdot, float init_y, float init_ydot)
#define INS_MAX_PROPAGATION_STEPS
maximum number of propagation steps without any updates in between
static void accel_cb(uint8_t sender_id, uint32_t stamp, struct Int32Vect3 *accel)
#define ACCEL_FLOAT_OF_BFP(_ai)
Device independent GPS code (interface)
void int32_quat_vmult(struct Int32Vect3 *v_out, struct Int32Quat *q, struct Int32Vect3 *v_in)
rotate 3D vector by quaternion.
#define INS_BARO_MAX_INIT_VAR
default barometer to use in INS
void vff_update_agl(float z_meas, float conf)
void int32_rmat_transp_vmult(struct Int32Vect3 *vb, struct Int32RMat *m_b2a, struct Int32Vect3 *va)
rotate 3D vector by transposed rotation matrix.
static struct FloatQuat * stateGetNedToBodyQuat_f(void)
Get vehicle body attitude quaternion (float).
vector in North East Down coordinates
static const struct usb_device_descriptor dev
#define INT32_SPEED_OF_CM_S_DEN
void hff_update_pos(struct FloatVect2 pos, struct FloatVect2 Rpos)
Update position.
#define INS_INT_VEL_ID
ABI binding for VELOCITY_ESTIMATE.
#define ACCEL_BFP_OF_REAL(_af)
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
static void stateSetLocalOrigin_i(struct LtpDef_i *ltp_def)
Set the local (flat earth) coordinate frame origin (int).
vector in East North Up coordinates Units: meters
static abi_event agl_ev
The agl ABI event.
void hff_update_gps(struct FloatVect2 *pos_ned, struct FloatVect2 *speed_ned)
float zdot
z-velocity estimate in m/s (NED, z-down)
static abi_event accel_ev
void ned_of_ecef_vect_i(struct NedCoor_i *ned, struct LtpDef_i *def, struct EcefCoor_i *ecef)
Rotate a vector from ECEF to NED.
static void send_ins(struct transport_tx *trans, struct link_device *dev)
void ltp_def_from_lla_i(struct LtpDef_i *def, struct LlaCoor_i *lla)
void ins_init_origin_i_from_flightplan(struct LtpDef_i *ltp_def)
initialize the local origin (ltp_def in fixed point) from flight plan position
static void stateSetPositionNed_i(struct NedCoor_i *ned_pos)
Set position from local NED coordinates (int).
void vff_realign(float z_meas)
struct Imu imu
global IMU state
Ins implementation state (fixed point)
uint16_t f
Camera baseline, in meters (i.e. horizontal distance between the two cameras of the stereo setup)
void float_quat_vmult(struct FloatVect3 *v_out, struct FloatQuat *q, const struct FloatVect3 *v_in)
rotate 3D vector by quaternion.
static void send_ins_ref(struct transport_tx *trans, struct link_device *dev)
static float pprz_isa_height_of_pressure(float pressure, float ref_p)
Get relative altitude from pressure (using simplified equation).
void vff_update_baro(float z_meas)
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
struct EcefCoor_i ecef_pos
position in ECEF in cm
float zdotdot
z-acceleration in m/s^2 (NED, z-down)
#define QUAT_INVERT(_qo, _qi)
#define VECT2_ASSIGN(_a, _x, _y)
void sim_overwrite_ins(void)
static void agl_cb(uint8_t sender_id, uint32_t stamp, float distance)
agl_cb This callback handles all estimates of the height of the vehicle above the ground under it Thi...
float variance_f(float *array, uint32_t n_elements)
Compute the variance of an array of values (float).
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.
#define INS_SONAR_MAX_RANGE
Default AGL sensor maximum range.
static void ins_ned_to_state(void)
copy position and speed to state interface
static void pos_est_cb(uint8_t sender_id, uint32_t stamp, float x, float y, float z, float noise_x, float noise_y, float noise_z)
void ins_reset_altitude_ref(void)
INS altitude reference reset.
static void vel_est_cb(uint8_t sender_id, uint32_t stamp, float x, float y, float z, float noise_x, float noise_y, float noise_z)
void vff_propagate(float accel, float dt)
Propagate the filter in time.
int32_t hmsl
height above mean sea level (MSL) in mm
void hff_update_vel(struct FloatVect2 vel, struct FloatVect2 Rvel)
struct NedCoor_i ltp_speed
int32_t stabilization_cmd[COMMANDS_NB]
Stabilization commands.
static struct Int32RMat * orientationGetRMat_i(struct OrientationReps *orientation)
Get vehicle body attitude rotation matrix (int).
#define POS_BFP_OF_REAL(_af)
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.
bool vf_reset
request to reset vertical filter.
struct EcefCoor_i ecef_vel
speed ECEF in cm/s
void hff_realign(struct FloatVect2 pos, struct FloatVect2 vel)
#define INS_INT_AGL_ID
ABI binding for AGL.
static abi_event pos_est_ev
struct GpsState gps
global GPS state
static void stateSetSpeedNed_i(struct NedCoor_i *ned_speed)
Set ground speed in local NED coordinates (int).
#define GPS_FIX_3D
3D GPS fix
struct LlaCoor_i lla
Reference point in lla.
static abi_event vel_est_ev
#define INT32_SPEED_OF_CM_S_NUM
#define DefaultPeriodic
Set default periodic telemetry.
Paparazzi atmospheric pressure conversion utilities.
struct InsInt ins_int
global INS state
#define INT32_VECT2_SCALE_2(_a, _b, _num, _den)