Paparazzi UAS  v5.12_stable-4-g9b43e9b
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ins_int.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2010 The Paparazzi Team
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
29 #include "subsystems/ins/ins_int.h"
30 
31 #include "subsystems/abi.h"
32 
33 #include "subsystems/imu.h"
34 #include "subsystems/gps.h"
35 
36 #include "generated/airframe.h"
37 
38 #if USE_VFF_EXTENDED
40 #else
42 #endif
43 
44 #if USE_HFF
46 #endif
47 
48 #if defined SITL && USE_NPS
49 //#include "nps_fdm.h"
50 #include "nps_autopilot.h"
51 #include <stdio.h>
52 #endif
53 
54 #include "math/pprz_geodetic_int.h"
55 #include "math/pprz_isa.h"
56 
57 
58 #if USE_SONAR
59 #if !USE_VFF_EXTENDED
60 #error USE_SONAR needs USE_VFF_EXTENDED
61 #endif
62 
64 #ifndef INS_INT_SONAR_ID
65 #define INS_INT_SONAR_ID ABI_BROADCAST
66 #endif
68 static void sonar_cb(uint8_t sender_id, float distance);
69 
70 #ifdef INS_SONAR_THROTTLE_THRESHOLD
72 #endif
73 
74 #ifndef INS_SONAR_MIN_RANGE
75 #define INS_SONAR_MIN_RANGE 0.001
76 #endif
77 #ifndef INS_SONAR_MAX_RANGE
78 #define INS_SONAR_MAX_RANGE 4.0
79 #endif
80 #define VFF_R_SONAR_0 0.1
81 #ifndef VFF_R_SONAR_OF_M
82 #define VFF_R_SONAR_OF_M 0.2
83 #endif
84 
85 #ifndef INS_SONAR_UPDATE_ON_AGL
86 #define INS_SONAR_UPDATE_ON_AGL FALSE
87 PRINT_CONFIG_MSG("INS_SONAR_UPDATE_ON_AGL defaulting to FALSE")
88 #endif
89 
90 #endif // USE_SONAR
91 
92 #if USE_GPS
93 #ifndef INS_VFF_R_GPS
94 #define INS_VFF_R_GPS 2.0
95 #endif
96 
97 #ifndef INS_VFF_VZ_R_GPS
98 #define INS_VFF_VZ_R_GPS 2.0
99 #endif
100 #endif // USE_GPS
101 
103 #ifndef INS_MAX_PROPAGATION_STEPS
104 #define INS_MAX_PROPAGATION_STEPS 200
105 #endif
106 
107 #ifndef USE_INS_NAV_INIT
108 #define USE_INS_NAV_INIT TRUE
109 PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
110 #endif
111 
113 #ifndef INS_INT_BARO_ID
114 #if USE_BARO_BOARD
115 #define INS_INT_BARO_ID BARO_BOARD_SENDER_ID
116 #else
117 #define INS_INT_BARO_ID ABI_BROADCAST
118 #endif
119 #endif
120 PRINT_CONFIG_VAR(INS_INT_BARO_ID)
122 static void baro_cb(uint8_t sender_id, float pressure);
123 
127 #ifndef INS_INT_IMU_ID
128 #define INS_INT_IMU_ID ABI_BROADCAST
129 #endif
131 static void accel_cb(uint8_t sender_id, uint32_t stamp, struct Int32Vect3 *accel);
132 
133 #ifndef INS_INT_GPS_ID
134 #define INS_INT_GPS_ID GPS_MULTI_ID
135 #endif
137 static void gps_cb(uint8_t sender_id, uint32_t stamp, struct GpsState *gps_s);
138 
142 #ifndef INS_INT_VEL_ID
143 #define INS_INT_VEL_ID ABI_BROADCAST
144 #endif
146 static void vel_est_cb(uint8_t sender_id, uint32_t stamp, float x, float y, float z, float noise);
147 
149 
150 #if PERIODIC_TELEMETRY
152 
153 static void send_ins(struct transport_tx *trans, struct link_device *dev)
154 {
155  pprz_msg_send_INS(trans, dev, AC_ID,
159 }
160 
161 static void send_ins_z(struct transport_tx *trans, struct link_device *dev)
162 {
163  pprz_msg_send_INS_Z(trans, dev, AC_ID,
165 }
166 
167 static void send_ins_ref(struct transport_tx *trans, struct link_device *dev)
168 {
169  if (ins_int.ltp_initialized) {
170  pprz_msg_send_INS_REF(trans, dev, AC_ID,
174  }
175 }
176 #endif
177 
178 static void ins_ned_to_state(void);
179 static void ins_update_from_vff(void);
180 #if USE_HFF
181 static void ins_update_from_hff(void);
182 #endif
183 
184 
185 void ins_int_init(void)
186 {
187 
188 #if USE_INS_NAV_INIT
190  ins_int.ltp_initialized = true;
191 #else
192  ins_int.ltp_initialized = false;
193 #endif
194 
195  /* we haven't had any measurement updates yet, so set the counter to max */
197 
198  // Bind to BARO_ABS message
199  AbiBindMsgBARO_ABS(INS_INT_BARO_ID, &baro_ev, baro_cb);
200  ins_int.baro_initialized = false;
201 
202 #if USE_SONAR
203  ins_int.update_on_agl = INS_SONAR_UPDATE_ON_AGL;
204  // Bind to AGL message
205  AbiBindMsgAGL(INS_INT_SONAR_ID, &sonar_ev, sonar_cb);
206 #endif
207 
208  ins_int.vf_reset = false;
209  ins_int.hf_realign = false;
210 
211  /* init vertical and horizontal filters */
212  vff_init_zero();
213 #if USE_HFF
214  b2_hff_init(0., 0., 0., 0.);
215 #endif
216 
220 
221 #if PERIODIC_TELEMETRY
225 #endif
226 
227  /*
228  * Subscribe to scaled IMU measurements and attach callbacks
229  */
230  AbiBindMsgIMU_ACCEL_INT32(INS_INT_IMU_ID, &accel_ev, accel_cb);
231  AbiBindMsgGPS(INS_INT_GPS_ID, &gps_ev, gps_cb);
232  AbiBindMsgVELOCITY_ESTIMATE(INS_INT_VEL_ID, &vel_est_ev, vel_est_cb);
233 }
234 
236 {
237 #if USE_GPS
238  if (GpsFixValid()) {
242  ins_int.ltp_initialized = true;
244  } else {
245  ins_int.ltp_initialized = false;
246  }
247 #else
248  ins_int.ltp_initialized = false;
249 #endif
250 
251 #if USE_HFF
252  ins_int.hf_realign = true;
253 #endif
254  ins_int.vf_reset = true;
255 }
256 
258 {
259 #if USE_GPS
260  struct LlaCoor_i lla = {
262  .lon = state.ned_origin_i.lla.lon,
263  .alt = gps.lla_pos.alt
264  };
268 #endif
269  ins_int.vf_reset = true;
270 }
271 
272 void ins_int_propagate(struct Int32Vect3 *accel, float dt)
273 {
274  /* untilt accels */
275  struct Int32Vect3 accel_meas_body;
276  struct Int32RMat *body_to_imu_rmat = orientationGetRMat_i(&imu.body_to_imu);
277  int32_rmat_transp_vmult(&accel_meas_body, body_to_imu_rmat, accel);
278  stateSetAccelBody_i(&accel_meas_body);
279  struct Int32Vect3 accel_meas_ltp;
280  int32_rmat_transp_vmult(&accel_meas_ltp, stateGetNedToBodyRMat_i(), &accel_meas_body);
281 
282  float z_accel_meas_float = ACCEL_FLOAT_OF_BFP(accel_meas_ltp.z);
283 
284  /* Propagate only if we got any measurement during the last INS_MAX_PROPAGATION_STEPS.
285  * Otherwise halt the propagation to not diverge and only set the acceleration.
286  * This should only be relevant in the startup phase when the baro is not yet initialized
287  * and there is no gps fix yet...
288  */
290  vff_propagate(z_accel_meas_float, dt);
292  } else {
293  // feed accel from the sensors
294  // subtract -9.81m/s2 (acceleration measured due to gravity,
295  // but vehicle not accelerating in ltp)
296  ins_int.ltp_accel.z = accel_meas_ltp.z + ACCEL_BFP_OF_REAL(9.81);
297  }
298 
299 #if USE_HFF
300  /* propagate horizontal filter */
302  /* convert and copy result to ins_int */
303  ins_update_from_hff();
304 #else
305  ins_int.ltp_accel.x = accel_meas_ltp.x;
306  ins_int.ltp_accel.y = accel_meas_ltp.y;
307 #endif /* USE_HFF */
308 
310 
311  /* increment the propagation counter, while making sure it doesn't overflow */
314  }
315 }
316 
317 static void baro_cb(uint8_t __attribute__((unused)) sender_id, float pressure)
318 {
319  if (!ins_int.baro_initialized && pressure > 1e-7) {
320  // wait for a first positive value
321  ins_int.qfe = pressure;
322  ins_int.baro_initialized = true;
323  }
324 
326  if (ins_int.vf_reset) {
327  ins_int.vf_reset = false;
328  ins_int.qfe = pressure;
329  vff_realign(0.);
331  } else {
332  float baro_up = pprz_isa_height_of_pressure(pressure, ins_int.qfe);
333 
334  // Calculate the distance to the origin
335  struct EnuCoor_f *enu = stateGetPositionEnu_f();
336  double dist2_to_origin = enu->x*enu->x + enu->y*enu->y;
337 
338  // correction for the earth's curvature
339  const double earth_radius = 6378137.0;
340  float height_correction = (float) (sqrt(earth_radius*earth_radius + dist2_to_origin) - earth_radius);
341 
342  // The VFF will update in the NED frame
343  ins_int.baro_z = -(baro_up - height_correction);
344 
345 #if USE_VFF_EXTENDED
347 #else
349 #endif
350  }
352 
353  /* reset the counter to indicate we just had a measurement update */
355  }
356 }
357 
358 #if USE_GPS
359 void ins_int_update_gps(struct GpsState *gps_s)
360 {
361  if (gps_s->fix < GPS_FIX_3D) {
362  return;
363  }
364 
365  if (!ins_int.ltp_initialized) {
367  }
368 
369  struct NedCoor_i gps_pos_cm_ned;
370  ned_of_ecef_point_i(&gps_pos_cm_ned, &ins_int.ltp_def, &gps_s->ecef_pos);
371 
372  /* calculate body frame position taking BODY_TO_GPS translation (in cm) into account */
373 #ifdef INS_BODY_TO_GPS_X
374  /* body2gps translation in body frame */
375  struct Int32Vect3 b2g_b = {
376  .x = INS_BODY_TO_GPS_X,
377  .y = INS_BODY_TO_GPS_Y,
378  .z = INS_BODY_TO_GPS_Z
379  };
380  /* rotate offset given in body frame to navigation/ltp frame using current attitude */
381  struct Int32Quat q_b2n = *stateGetNedToBodyQuat_i();
382  QUAT_INVERT(q_b2n, q_b2n);
383  struct Int32Vect3 b2g_n;
384  int32_quat_vmult(&b2g_n, &q_b2n, &b2g_b);
385  /* subtract body2gps translation in ltp from gps position */
386  VECT3_SUB(gps_pos_cm_ned, b2g_n);
387 #endif
388 
390  struct NedCoor_i gps_speed_cm_s_ned;
391  ned_of_ecef_vect_i(&gps_speed_cm_s_ned, &ins_int.ltp_def, &gps_s->ecef_vel);
392 
393 #if INS_USE_GPS_ALT
394  vff_update_z_conf(((float)gps_pos_cm_ned.z) / 100.0, INS_VFF_R_GPS);
395 #endif
396 #if INS_USE_GPS_ALT_SPEED
397  vff_update_vz_conf(((float)gps_speed_cm_s_ned.z) / 100.0, INS_VFF_VZ_R_GPS);
399 #endif
400 
401 #if USE_HFF
402  /* horizontal gps transformed to NED in meters as float */
403  struct FloatVect2 gps_pos_m_ned;
404  VECT2_ASSIGN(gps_pos_m_ned, gps_pos_cm_ned.x, gps_pos_cm_ned.y);
405  VECT2_SDIV(gps_pos_m_ned, gps_pos_m_ned, 100.0f);
406 
407  struct FloatVect2 gps_speed_m_s_ned;
408  VECT2_ASSIGN(gps_speed_m_s_ned, gps_speed_cm_s_ned.x, gps_speed_cm_s_ned.y);
409  VECT2_SDIV(gps_speed_m_s_ned, gps_speed_m_s_ned, 100.);
410 
411  if (ins_int.hf_realign) {
412  ins_int.hf_realign = false;
413  const struct FloatVect2 zero = {0.0f, 0.0f};
414  b2_hff_realign(gps_pos_m_ned, zero);
415  }
416  // run horizontal filter
417  b2_hff_update_gps(&gps_pos_m_ned, &gps_speed_m_s_ned);
418  // convert and copy result to ins_int
419  ins_update_from_hff();
420 
421 #else /* hff not used */
422  /* simply copy horizontal pos/speed from gps */
423  INT32_VECT2_SCALE_2(ins_int.ltp_pos, gps_pos_cm_ned,
425  INT32_VECT2_SCALE_2(ins_int.ltp_speed, gps_speed_cm_s_ned,
427 #endif /* USE_HFF */
428 
430 
431  /* reset the counter to indicate we just had a measurement update */
433 }
434 #else
435 void ins_int_update_gps(struct GpsState *gps_s __attribute__((unused))) {}
436 #endif /* USE_GPS */
437 
438 
439 #if USE_SONAR
440 static void sonar_cb(uint8_t __attribute__((unused)) sender_id, float distance)
441 {
442  static float last_offset = 0.;
443 
444  /* update filter assuming a flat ground */
445  if (distance < INS_SONAR_MAX_RANGE && distance > INS_SONAR_MIN_RANGE
446 #ifdef INS_SONAR_THROTTLE_THRESHOLD
447  && stabilization_cmd[COMMAND_THRUST] < INS_SONAR_THROTTLE_THRESHOLD
448 #endif
449 #ifdef INS_SONAR_BARO_THRESHOLD
450  && ins_int.baro_z > -INS_SONAR_BARO_THRESHOLD /* z down */
451 #endif
452  && ins_int.update_on_agl
454  vff_update_z_conf(-(distance), VFF_R_SONAR_0 + VFF_R_SONAR_OF_M * fabsf(distance));
455  last_offset = vff.offset;
456  } else {
457  /* update offset with last value to avoid divergence */
458  vff_update_offset(last_offset);
459  }
460 
461  /* reset the counter to indicate we just had a measurement update */
463 }
464 #endif // USE_SONAR
465 
467 static void ins_ned_to_state(void)
468 {
472 
473 #if defined SITL && USE_NPS
474  if (nps_bypass_ins) {
476  }
477 #endif
478 }
479 
481 static void ins_update_from_vff(void)
482 {
486 }
487 
488 #if USE_HFF
489 
490 static void ins_update_from_hff(void)
491 {
498 }
499 #endif
500 
501 
502 static void accel_cb(uint8_t sender_id __attribute__((unused)),
503  uint32_t stamp, struct Int32Vect3 *accel)
504 {
505  PRINT_CONFIG_MSG("Calculating dt for INS int propagation.")
506  /* timestamp in usec when last callback was received */
507  static uint32_t last_stamp = 0;
508 
509  if (last_stamp > 0) {
510  float dt = (float)(stamp - last_stamp) * 1e-6;
511  ins_int_propagate(accel, dt);
512  }
513  last_stamp = stamp;
514 }
515 
516 static void gps_cb(uint8_t sender_id __attribute__((unused)),
517  uint32_t stamp __attribute__((unused)),
518  struct GpsState *gps_s)
519 {
520  ins_int_update_gps(gps_s);
521 }
522 
523 static void vel_est_cb(uint8_t sender_id __attribute__((unused)),
524  uint32_t stamp,
525  float x, float y, float z,
526  float noise __attribute__((unused)))
527 {
528 
529  struct FloatVect3 vel_body = {x, y, z};
530  static uint32_t last_stamp = 0;
531  float dt = 0;
532 
533  /* rotate velocity estimate to nav/ltp frame */
534  struct FloatQuat q_b2n = *stateGetNedToBodyQuat_f();
535  QUAT_INVERT(q_b2n, q_b2n);
536  struct FloatVect3 vel_ned;
537  float_quat_vmult(&vel_ned, &q_b2n, &vel_body);
538 
539  if (last_stamp > 0) {
540  dt = (float)(stamp - last_stamp) * 1e-6;
541  }
542 
543  last_stamp = stamp;
544 
545 #if USE_HFF
546  (void)dt; //dt is unused variable in this define
547 
548  struct FloatVect2 vel = {vel_ned.x, vel_ned.y};
549  struct FloatVect2 Rvel = {noise, noise};
550 
551  b2_hff_update_vel(vel, Rvel);
552  ins_update_from_hff();
553 #else
556  if (last_stamp > 0) {
557  ins_int.ltp_pos.x = ins_int.ltp_pos.x + POS_BFP_OF_REAL(dt * vel_ned.x);
558  ins_int.ltp_pos.y = ins_int.ltp_pos.y + POS_BFP_OF_REAL(dt * vel_ned.y);
559  }
560 #endif
561 
563 
564  /* reset the counter to indicate we just had a measurement update */
566 }
bool nps_bypass_ins
static void stateSetPositionNed_i(struct NedCoor_i *ned_pos)
Set position from local NED coordinates (int).
Definition: state.h:531
Event structure to store callbacks in a linked list.
Definition: abi_common.h:65
#define VECT3_SUB(_a, _b)
Definition: pprz_algebra.h:153
int32_t z
in centimeters
static abi_event gps_ev
Definition: ins_int.c:136
static struct Int32RMat * orientationGetRMat_i(struct OrientationReps *orientation)
Get vehicle body attitude rotation matrix (int).
bool vf_reset
request to reset vertical filter.
Definition: ins_int.h:53
void vff_update_z_conf(float z_meas, float conf)
Interface for extended vertical filter (in float).
Horizontal filter (x,y) to estimate position and velocity.
void b2_hff_realign(struct FloatVect2 pos, struct FloatVect2 vel)
Definition: hf_float.c:594
Periodic telemetry system header (includes downlink utility and generated code).
static struct Int32RMat * stateGetNedToBodyRMat_i(void)
Get vehicle body attitude rotation matrix (int).
Definition: state.h:1119
#define INS_VFF_VZ_R_GPS
Definition: ins_int.c:98
abi_event sonar_ev
Definition: agl_dist.c:51
static abi_event vel_est_ev
Definition: ins_int.c:145
struct InsInt ins_int
global INS state
Definition: ins_int.c:148
int32_t y
in centimeters
static void vel_est_cb(uint8_t sender_id, uint32_t stamp, float x, float y, float z, float noise)
Definition: ins_int.c:523
vector in East North Up coordinates Units: meters
float qfe
Definition: ins_int.h:62
#define POS_BFP_OF_REAL(_af)
#define QUAT_INVERT(_qo, _qi)
Definition: pprz_algebra.h:574
static void ins_update_from_vff(void)
update ins state from vertical filter
Definition: ins_int.c:481
#define INT32_VECT3_ZERO(_v)
static void stateSetAccelBody_i(struct Int32Vect3 *body_accel)
Set acceleration in Body coordinates (int).
Definition: state.h:855
Main include for ABI (AirBorneInterface).
void vff_update_vz_conf(float vz_meas, float conf)
static void gps_cb(uint8_t sender_id, uint32_t stamp, struct GpsState *gps_s)
Definition: ins_int.c:516
void ins_reset_local_origin(void)
INS local origin reset.
Definition: ins_int.c:235
#define VECT2_ASSIGN(_a, _x, _y)
Definition: pprz_algebra.h:61
float z
z-position estimate in m (NED, z-down)
struct Imu imu
global IMU state
Definition: imu.c:108
#define INT32_SPEED_OF_CM_S_DEN
vector in Latitude, Longitude and Altitude
static void stateSetSpeedNed_i(struct NedCoor_i *ned_speed)
Set ground speed in local NED coordinates (int).
Definition: state.h:763
#define GPS_FIX_3D
3D GPS fix
Definition: gps.h:39
void ltp_def_from_lla_i(struct LtpDef_i *def, struct LlaCoor_i *lla)
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
Definition: state.h:719
int32_t z
Down.
static struct Int32Quat * stateGetNedToBodyQuat_i(void)
Get vehicle body attitude quaternion (int).
Definition: state.h:1113
bool baro_initialized
Definition: ins_int.h:63
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.
struct EcefCoor_i ecef
Reference point in ecef.
int32_t hmsl
Height above mean sea level in mm.
void ins_int_update_gps(struct GpsState *gps_s)
Definition: ins_int.c:359
static void sonar_cb(uint8_t sender_id, float distance)
Definition: agl_dist.c:66
static struct FloatQuat * stateGetNedToBodyQuat_f(void)
Get vehicle body attitude quaternion (float).
Definition: state.h:1131
int32_t alt
in millimeters above WGS84 reference ellipsoid
Vertical filter (in float) estimating altitude, velocity and accel bias.
Roation quaternion.
abi_event baro_ev
Definition: ins_int.c:121
int32_t y
East.
static void stateSetAccelNed_i(struct NedCoor_i *ned_accel)
Set acceleration in NED coordinates (int).
Definition: state.h:986
#define INT32_VECT2_SCALE_2(_a, _b, _num, _den)
static void send_ins_z(struct transport_tx *trans, struct link_device *dev)
Definition: ins_int.c:161
int32_t hmsl
height above mean sea level (MSL) in mm
Definition: gps.h:88
float x
in meters
#define INS_INT_BARO_ID
default barometer to use in INS
Definition: ins_int.c:117
static void send_ins_ref(struct transport_tx *trans, struct link_device *dev)
Definition: ins_int.c:167
data structure for GPS information
Definition: gps.h:81
void ins_int_init(void)
Definition: ins_int.c:185
#define INT32_POS_OF_CM_NUM
static void stateSetLocalOrigin_i(struct LtpDef_i *ltp_def)
Set the local (flat earth) coordinate frame origin (int).
Definition: state.h:457
Device independent GPS code (interface)
Paparazzi atmospheric pressure conversion utilities.
#define ACCEL_FLOAT_OF_BFP(_ai)
bool ltp_initialized
Definition: ins_int.h:41
int32_t x
North.
unsigned long uint32_t
Definition: types.h:18
struct EcefCoor_i ecef_pos
position in ECEF in cm
Definition: gps.h:85
float offset
baro offset estimate
#define INS_INT_IMU_ID
ABI binding for IMU data.
Definition: ins_int.c:128
void vff_update_offset(float offset)
PRINT_CONFIG_MSG("USE_INS_NAV_INIT defaulting to TRUE")
static void ins_ned_to_state(void)
copy position and speed to state interface
Definition: ins_int.c:467
struct LlaCoor_i lla
Reference point in lla.
#define DefaultPeriodic
Set default periodic telemetry.
Definition: telemetry.h:66
int32_t lon
in degrees*1e7
#define INS_MAX_PROPAGATION_STEPS
maximum number of propagation steps without any updates in between
Definition: ins_int.c:104
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
Definition: ins.c:39
void float_quat_vmult(struct FloatVect3 *v_out, struct FloatQuat *q, const struct FloatVect3 *v_in)
rotate 3D vector by quaternion.
void b2_hff_init(float init_x, float init_xdot, float init_y, float init_ydot)
Definition: hf_float.c:268
static void accel_cb(uint8_t sender_id, uint32_t stamp, struct Int32Vect3 *accel)
Definition: ins_int.c:502
Paparazzi fixed point math for geodetic calculations.
void int32_quat_vmult(struct Int32Vect3 *v_out, struct Int32Quat *q, struct Int32Vect3 *v_in)
rotate 3D vector by quaternion.
void vff_init_zero(void)
bool hf_realign
request to realign horizontal filter.
Definition: ins_int.h:48
float zdotdot
z-acceleration in m/s^2 (NED, z-down)
Inertial Measurement Unit interface.
struct NedCoor_i ltp_pos
Definition: ins_int.h:56
void vff_propagate(float accel, float dt)
Propagate the filter in time.
struct HfilterFloat b2_hff_state
Definition: hf_float.c:120
struct OrientationReps body_to_imu
rotation from body to imu frame
Definition: imu.h:49
struct NedCoor_i ltp_accel
Definition: ins_int.h:58
float baro_z
z-position calculated from baro in meters (z-down)
Definition: ins_int.h:61
static const struct usb_device_descriptor dev
Definition: usb_ser_hw.c:73
struct LtpDef_i ned_origin_i
Definition of the local (flat earth) coordinate system.
Definition: state.h:166
#define VECT2_SDIV(_vo, _vi, _s)
Definition: pprz_algebra.h:103
uint32_t propagation_cnt
number of propagation steps since the last measurement update
Definition: ins_int.h:43
void vff_realign(float z_meas)
float x
Definition: hf_float.h:39
float y
Definition: hf_float.h:43
Ins implementation state (fixed point)
Definition: ins_int.h:39
#define INT32_POS_OF_CM_DEN
unsigned char uint8_t
Definition: types.h:14
float xdot
Definition: hf_float.h:41
struct VffExtended vff
float zdot
z-velocity estimate in m/s (NED, z-down)
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.
vector in North East Down coordinates
#define INS_INT_VEL_ID
ABI binding for VELOCITY_ESTIMATE.
Definition: ins_int.c:143
float xdotdot
Definition: hf_float.h:42
static abi_event accel_ev
Definition: ins_int.c:130
#define INT32_SPEED_OF_CM_S_NUM
void b2_hff_propagate(void)
Definition: hf_float.c:470
float ydot
Definition: hf_float.h:45
static void send_ins(struct transport_tx *trans, struct link_device *dev)
Definition: ins_int.c:153
General stabilization interface for rotorcrafts.
int32_t stabilization_cmd[COMMANDS_NB]
Stabilization commands.
Definition: stabilization.c:28
void b2_hff_update_gps(struct FloatVect2 *pos_ned, struct FloatVect2 *speed_ned)
Definition: hf_float.c:532
void int32_rmat_transp_vmult(struct Int32Vect3 *vb, struct Int32RMat *m_b2a, struct Int32Vect3 *va)
rotate 3D vector by transposed rotation matrix.
void vff_update(float z_meas)
Definition: vf_float.c:189
static void baro_cb(uint8_t sender_id, float pressure)
Definition: ins_int.c:317
int32_t x
in centimeters
struct LtpDef_i ltp_def
Definition: ins_int.h:40
void vff_update_baro(float z_meas)
rotation matrix
struct EcefCoor_i ecef_vel
speed ECEF in cm/s
Definition: gps.h:89
#define SPEED_BFP_OF_REAL(_af)
struct LlaCoor_i lla_pos
position in LLA (lat,lon: deg*1e7; alt: mm over ellipsoid)
Definition: gps.h:86
static float pprz_isa_height_of_pressure(float pressure, float ref_p)
Get relative altitude from pressure (using simplified equation).
Definition: pprz_isa.h:95
#define ACCEL_BFP_OF_REAL(_af)
int32_t lat
in degrees*1e7
#define INS_VFF_R_GPS
Definition: ins_int.c:94
uint8_t fix
status of fix
Definition: gps.h:99
#define INS_INT_GPS_ID
Definition: ins_int.c:134
float y
in meters
Rotation quaternion.
struct GpsState gps
global GPS state
Definition: gps.c:75
void ins_int_propagate(struct Int32Vect3 *accel, float dt)
Definition: ins_int.c:272
struct NedCoor_i ltp_speed
Definition: ins_int.h:57
void sim_overwrite_ins(void)
void ltp_def_from_ecef_i(struct LtpDef_i *def, struct EcefCoor_i *ecef)
struct State state
Definition: state.c:36
void b2_hff_update_vel(struct FloatVect2 vel, struct FloatVect2 Rvel)
Definition: hf_float.c:757
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Definition: telemetry.c:46
void ins_reset_altitude_ref(void)
INS altitude reference reset.
Definition: ins_int.c:257
float ydotdot
Definition: hf_float.h:46
INS for rotorcrafts combining vertical and horizontal filters.
#define GpsFixValid()
Definition: gps.h:43