Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
telemetry.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2009 Antoine Drouin <poinix@gmail.com>
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 
22 #ifndef TELEMETRY_H
23 #define TELEMETRY_H
24 
25 #include "std.h"
26 #include "messages.h"
27 #include "mcu_periph/uart.h"
28 
30 #include "generated/periodic_telemetry.h"
31 
32 #ifdef RADIO_CONTROL
34 #endif
35 
36 #include "state.h"
37 
40 
41 #include "subsystems/actuators.h"
42 
43 #include "mcu_periph/sys_time.h"
44 #include "subsystems/electrical.h"
45 #include "subsystems/imu.h"
46 #if USE_GPS
47 #include "subsystems/gps.h"
48 #endif
49 #include "subsystems/ins.h"
50 #include "subsystems/ahrs.h"
51 // I2C Error counters
52 #include "mcu_periph/i2c.h"
53 
54 #define PERIODIC_SEND_ALIVE(_trans, _dev) DOWNLINK_SEND_ALIVE(_trans, _dev, 16, MD5SUM)
55 
56 #if USE_GPS
57 #define PERIODIC_SEND_ROTORCRAFT_STATUS(_trans, _dev) { \
58  uint32_t imu_nb_err = 0; \
59  uint8_t _twi_blmc_nb_err = 0; \
60  uint16_t time_sec = sys_time.nb_sec; \
61  DOWNLINK_SEND_ROTORCRAFT_STATUS(_trans, _dev, \
62  &imu_nb_err, \
63  &_twi_blmc_nb_err, \
64  &radio_control.status, \
65  &radio_control.frame_rate, \
66  &gps.fix, \
67  &autopilot_mode, \
68  &autopilot_in_flight, \
69  &autopilot_motors_on, \
70  &guidance_h_mode, \
71  &guidance_v_mode, \
72  &electrical.vsupply, \
73  &time_sec \
74  ); \
75  }
76 #else /* !USE_GPS */
77 #define PERIODIC_SEND_ROTORCRAFT_STATUS(_trans, _dev) { \
78  uint32_t imu_nb_err = 0; \
79  uint8_t twi_blmc_nb_err = 0; \
80  uint8_t fix = GPS_FIX_NONE; \
81  uint16_t time_sec = sys_time.nb_sec; \
82  DOWNLINK_SEND_ROTORCRAFT_STATUS(_trans, _dev, \
83  &imu_nb_err, \
84  &twi_blmc_nb_err, \
85  &radio_control.status, \
86  &radio_control.frame_rate, \
87  &fix, \
88  &autopilot_mode, \
89  &autopilot_in_flight, \
90  &autopilot_motors_on, \
91  &guidance_h_mode, \
92  &guidance_v_mode, \
93  &electrical.vsupply, \
94  &time_sec \
95  ); \
96  }
97 #endif /* USE_GPS */
98 
99 #ifdef RADIO_CONTROL
100 #define PERIODIC_SEND_RC(_trans, _dev) DOWNLINK_SEND_RC(_trans, _dev, RADIO_CONTROL_NB_CHANNEL, radio_control.values)
101 #if defined RADIO_KILL_SWITCH
102 #define PERIODIC_SEND_ROTORCRAFT_RADIO_CONTROL(_trans, _dev) SEND_ROTORCRAFT_RADIO_CONTROL( _trans, _dev, &radio_control.values[RADIO_KILL_SWITCH])
103 #else /* ! RADIO_KILL_SWITCH */
104 #define PERIODIC_SEND_ROTORCRAFT_RADIO_CONTROL(_trans, _dev) { \
105  int16_t foo = -42; \
106  SEND_ROTORCRAFT_RADIO_CONTROL( _trans, _dev, &foo) \
107 }
108 #endif /* !RADIO_KILL_SWITCH */
109 #define SEND_ROTORCRAFT_RADIO_CONTROL(_trans, _dev, _kill_switch) { \
110  DOWNLINK_SEND_ROTORCRAFT_RADIO_CONTROL(_trans, _dev, \
111  &radio_control.values[RADIO_ROLL], \
112  &radio_control.values[RADIO_PITCH], \
113  &radio_control.values[RADIO_YAW], \
114  &radio_control.values[RADIO_THROTTLE], \
115  &radio_control.values[RADIO_MODE], \
116  _kill_switch, \
117  &radio_control.status);}
118 #else /* ! RADIO_CONTROL */
119 #define PERIODIC_SEND_RC(_trans, _dev) {}
120 #define PERIODIC_SEND_ROTORCRAFT_RADIO_CONTROL(_trans, _dev) {}
121 #endif
122 
123 #ifdef RADIO_CONTROL_TYPE_PPM
124 #define PERIODIC_SEND_PPM(_trans, _dev) { \
125  uint16_t ppm_pulses_usec[RADIO_CONTROL_NB_CHANNEL]; \
126  for (int i=0;i<RADIO_CONTROL_NB_CHANNEL;i++) \
127  ppm_pulses_usec[i] = USEC_OF_RC_PPM_TICKS(ppm_pulses[i]); \
128  DOWNLINK_SEND_PPM(_trans, _dev, \
129  &radio_control.frame_rate, \
130  PPM_NB_CHANNEL, \
131  ppm_pulses_usec); \
132  }
133 #else
134 #define PERIODIC_SEND_PPM(_trans, _dev) {}
135 #endif
136 
137 #ifdef ACTUATORS
138 #define PERIODIC_SEND_ACTUATORS(_trans, _dev) DOWNLINK_SEND_ACTUATORS(_trans, _dev, ACTUATORS_NB, actuators)
139 #else
140 #define PERIODIC_SEND_ACTUATORS(_trans, _dev) {}
141 #endif
142 
143 #define PERIODIC_SEND_IMU_GYRO_SCALED(_trans, _dev) { \
144  DOWNLINK_SEND_IMU_GYRO_SCALED(_trans, _dev, \
145  &imu.gyro.p, \
146  &imu.gyro.q, \
147  &imu.gyro.r); \
148  }
149 
150 #define PERIODIC_SEND_IMU_ACCEL_SCALED(_trans, _dev) { \
151  DOWNLINK_SEND_IMU_ACCEL_SCALED(_trans, _dev, \
152  &imu.accel.x, \
153  &imu.accel.y, \
154  &imu.accel.z); \
155  }
156 
157 #define PERIODIC_SEND_IMU_MAG_SCALED(_trans, _dev) { \
158  DOWNLINK_SEND_IMU_MAG_SCALED(_trans, _dev, \
159  &imu.mag.x, \
160  &imu.mag.y, \
161  &imu.mag.z); \
162  }
163 
164 #define PERIODIC_SEND_IMU_GYRO_RAW(_trans, _dev) { \
165  DOWNLINK_SEND_IMU_GYRO_RAW(_trans, _dev, \
166  &imu.gyro_unscaled.p, \
167  &imu.gyro_unscaled.q, \
168  &imu.gyro_unscaled.r); \
169  }
170 
171 #define PERIODIC_SEND_IMU_ACCEL_RAW(_trans, _dev) { \
172  DOWNLINK_SEND_IMU_ACCEL_RAW(_trans, _dev, \
173  &imu.accel_unscaled.x, \
174  &imu.accel_unscaled.y, \
175  &imu.accel_unscaled.z); \
176  }
177 
178 #define PERIODIC_SEND_IMU_MAG_RAW(_trans, _dev) { \
179  DOWNLINK_SEND_IMU_MAG_RAW(_trans, _dev, \
180  &imu.mag_unscaled.x, \
181  &imu.mag_unscaled.y, \
182  &imu.mag_unscaled.z); \
183  }
184 
185 #define PERIODIC_SEND_IMU_MAG_CURRENT_CALIBRATION(_trans, _dev) { \
186  DOWNLINK_SEND_IMU_MAG_CURRENT_CALIBRATION(_trans, _dev, \
187  &imu.mag_unscaled.x, \
188  &imu.mag_unscaled.y, \
189  &imu.mag_unscaled.z, \
190  &electrical.current); \
191  }
192 
193 #include "subsystems/sensors/baro.h"
194 #define PERIODIC_SEND_BARO_RAW(_trans, _dev) { \
195  DOWNLINK_SEND_BARO_RAW(_trans, _dev, \
196  &baro.absolute, \
197  &baro.differential); \
198  }
199 
200 
201 
203 #define PERIODIC_SEND_RATE_LOOP(_trans, _dev) { \
204  DOWNLINK_SEND_RATE_LOOP(_trans, _dev, \
205  &stabilization_rate_sp.p, \
206  &stabilization_rate_sp.q, \
207  &stabilization_rate_sp.r, \
208  &stabilization_rate_ref.p, \
209  &stabilization_rate_ref.q, \
210  &stabilization_rate_ref.r, \
211  &stabilization_rate_refdot.p, \
212  &stabilization_rate_refdot.q, \
213  &stabilization_rate_refdot.r, \
214  &stabilization_rate_sum_err.p, \
215  &stabilization_rate_sum_err.q, \
216  &stabilization_rate_sum_err.r, \
217  &stabilization_rate_ff_cmd.p, \
218  &stabilization_rate_ff_cmd.q, \
219  &stabilization_rate_ff_cmd.r, \
220  &stabilization_rate_fb_cmd.p, \
221  &stabilization_rate_fb_cmd.q, \
222  &stabilization_rate_fb_cmd.r, \
223  &stabilization_cmd[COMMAND_THRUST]); \
224  }
225 
226 
227 #ifdef STABILIZATION_ATTITUDE_NO_REF
228 #define PERIODIC_SEND_STAB_ATTITUDE(_trans, _dev) {}
229 #define PERIODIC_SEND_STAB_ATTITUDE_REF(_trans, _dev) {}
230 
231 #elif defined STABILIZATION_ATTITUDE_TYPE_INT
232 
233 #define PERIODIC_SEND_STAB_ATTITUDE(_trans, _dev) { \
234  struct Int32Rates* body_rate = stateGetBodyRates_i(); \
235  struct Int32Eulers* att = stateGetNedToBodyEulers_i(); \
236  DOWNLINK_SEND_STAB_ATTITUDE_INT(_trans, _dev, \
237  &(body_rate->p), &(body_rate->q), &(body_rate->r), \
238  &(att->phi), &(att->theta), &(att->psi), \
239  &stab_att_sp_euler.phi, \
240  &stab_att_sp_euler.theta, \
241  &stab_att_sp_euler.psi, \
242  &stabilization_att_sum_err.phi, \
243  &stabilization_att_sum_err.theta, \
244  &stabilization_att_sum_err.psi, \
245  &stabilization_att_fb_cmd[COMMAND_ROLL], \
246  &stabilization_att_fb_cmd[COMMAND_PITCH], \
247  &stabilization_att_fb_cmd[COMMAND_YAW], \
248  &stabilization_att_ff_cmd[COMMAND_ROLL], \
249  &stabilization_att_ff_cmd[COMMAND_PITCH], \
250  &stabilization_att_ff_cmd[COMMAND_YAW], \
251  &stabilization_cmd[COMMAND_ROLL], \
252  &stabilization_cmd[COMMAND_PITCH], \
253  &stabilization_cmd[COMMAND_YAW]); \
254 }
255 
256 #define PERIODIC_SEND_STAB_ATTITUDE_REF(_trans, _dev) { \
257  DOWNLINK_SEND_STAB_ATTITUDE_REF_INT(_trans, _dev, \
258  &stab_att_sp_euler.phi, \
259  &stab_att_sp_euler.theta, \
260  &stab_att_sp_euler.psi, \
261  &stab_att_ref_euler.phi, \
262  &stab_att_ref_euler.theta, \
263  &stab_att_ref_euler.psi, \
264  &stab_att_ref_rate.p, \
265  &stab_att_ref_rate.q, \
266  &stab_att_ref_rate.r, \
267  &stab_att_ref_accel.p, \
268  &stab_att_ref_accel.q, \
269  &stab_att_ref_accel.r); \
270  }
271 
272 #elif defined STABILIZATION_ATTITUDE_TYPE_FLOAT
273 
274 #define PERIODIC_SEND_STAB_ATTITUDE(_trans, _dev) { \
275  struct FloatRates* body_rate = stateGetBodyRates_f(); \
276  struct FloatEulers* att = stateGetNedToBodyEulers_f(); \
277  float foo; \
278  DOWNLINK_SEND_STAB_ATTITUDE_FLOAT(_trans, _dev, \
279  &(body_rate->p), &(body_rate->q), &(body_rate->r), \
280  &(att->phi), &(att->theta), &(att->psi), \
281  &stab_att_ref_euler.phi, \
282  &stab_att_ref_euler.theta, \
283  &stab_att_ref_euler.psi, \
284  &stabilization_att_sum_err_eulers.phi, \
285  &stabilization_att_sum_err_eulers.theta, \
286  &stabilization_att_sum_err_eulers.psi, \
287  &stabilization_att_fb_cmd[COMMAND_ROLL], \
288  &stabilization_att_fb_cmd[COMMAND_PITCH], \
289  &stabilization_att_fb_cmd[COMMAND_YAW], \
290  &stabilization_att_ff_cmd[COMMAND_ROLL], \
291  &stabilization_att_ff_cmd[COMMAND_PITCH], \
292  &stabilization_att_ff_cmd[COMMAND_YAW], \
293  &stabilization_cmd[COMMAND_ROLL], \
294  &stabilization_cmd[COMMAND_PITCH], \
295  &stabilization_cmd[COMMAND_YAW], \
296  &foo, &foo, &foo); \
297  }
298 
299 #define PERIODIC_SEND_STAB_ATTITUDE_REF(_trans, _dev) { \
300  DOWNLINK_SEND_STAB_ATTITUDE_REF_FLOAT(_trans, _dev, \
301  &stab_att_sp_euler.phi, \
302  &stab_att_sp_euler.theta, \
303  &stab_att_sp_euler.psi, \
304  &stab_att_ref_euler.phi, \
305  &stab_att_ref_euler.theta, \
306  &stab_att_ref_euler.psi, \
307  &stab_att_ref_rate.p, \
308  &stab_att_ref_rate.q, \
309  &stab_att_ref_rate.r, \
310  &stab_att_ref_accel.p, \
311  &stab_att_ref_accel.q, \
312  &stab_att_ref_accel.r); \
313  }
314 
315 #endif /* STABILIZATION_ATTITUDE_TYPE_FLOAT */
316 
317 
319 #define PERIODIC_SEND_FILTER_ALIGNER(_trans, _dev) { \
320  DOWNLINK_SEND_FILTER_ALIGNER(_trans, _dev, \
321  &ahrs_aligner.lp_gyro.p, \
322  &ahrs_aligner.lp_gyro.q, \
323  &ahrs_aligner.lp_gyro.r, \
324  &imu.gyro.p, \
325  &imu.gyro.q, \
326  &imu.gyro.r, \
327  &ahrs_aligner.noise, \
328  &ahrs_aligner.low_noise_cnt, \
329  &ahrs_aligner.status); \
330  }
331 
332 
333 #define PERIODIC_SEND_ROTORCRAFT_CMD(_trans, _dev) { \
334  DOWNLINK_SEND_ROTORCRAFT_CMD(_trans, _dev, \
335  &stabilization_cmd[COMMAND_ROLL], \
336  &stabilization_cmd[COMMAND_PITCH], \
337  &stabilization_cmd[COMMAND_YAW], \
338  &stabilization_cmd[COMMAND_THRUST]); \
339  }
340 
341 
342 #if USE_AHRS_CMPL_EULER
344 #define PERIODIC_SEND_FILTER(_trans, _dev) { \
345  DOWNLINK_SEND_FILTER(_trans, _dev, \
346  &ahrs_impl.ltp_to_imu_euler.phi, \
347  &ahrs_impl.ltp_to_imu_euler.theta, \
348  &ahrs_impl.ltp_to_imu_euler.psi, \
349  &ahrs_impl.measure.phi, \
350  &ahrs_impl.measure.theta, \
351  &ahrs_impl.measure.psi, \
352  &ahrs_impl.hi_res_euler.phi, \
353  &ahrs_impl.hi_res_euler.theta, \
354  &ahrs_impl.hi_res_euler.psi, \
355  &ahrs_impl.residual.phi, \
356  &ahrs_impl.residual.theta, \
357  &ahrs_impl.residual.psi, \
358  &ahrs_impl.gyro_bias.p, \
359  &ahrs_impl.gyro_bias.q, \
360  &ahrs_impl.gyro_bias.r); \
361  }
362 #else
363 #define PERIODIC_SEND_FILTER(_trans, _dev) {}
364 #endif
365 
366 #if USE_AHRS_ARDRONE2
368 #define PERIODIC_SEND_AHRS_ARDRONE2(_trans, _dev) { \
369  DOWNLINK_SEND_AHRS_ARDRONE2(_trans, _dev, \
370  &ahrs_impl.state, \
371  &ahrs_impl.control_state, \
372  &ahrs_impl.eulers.phi, \
373  &ahrs_impl.eulers.theta, \
374  &ahrs_impl.eulers.psi, \
375  &ahrs_impl.speed.x, \
376  &ahrs_impl.speed.y, \
377  &ahrs_impl.speed.z, \
378  &ahrs_impl.accel.x, \
379  &ahrs_impl.accel.y, \
380  &ahrs_impl.accel.z, \
381  &ahrs_impl.altitude, \
382  &ahrs_impl.battery); \
383  }
384 #else
385 #define PERIODIC_SEND_AHRS_ARDRONE2(_trans, _dev) {}
386 #endif
387 
388 #if USE_AHRS_CMPL_EULER || USE_AHRS_CMPL_QUAT
389 #define PERIODIC_SEND_AHRS_GYRO_BIAS_INT(_trans, _dev) { \
390  DOWNLINK_SEND_AHRS_GYRO_BIAS_INT(_trans, _dev, \
391  &ahrs_impl.gyro_bias.p, \
392  &ahrs_impl.gyro_bias.q, \
393  &ahrs_impl.gyro_bias.r); \
394  }
395 #else
396 #define PERIODIC_SEND_AHRS_GYRO_BIAS_INT(_trans, _dev) {}
397 #endif
398 
399 #if USE_AHRS_LKF
400 #include "subsystems/ahrs.h"
401 #include "ahrs/ahrs_float_lkf.h"
402 #define PERIODIC_SEND_AHRS_LKF(_trans, _dev) { \
403  DOWNLINK_SEND_AHRS_LKF(&bafl_eulers.phi, \
404  _trans, _dev, \
405  &bafl_eulers.theta, \
406  &bafl_eulers.psi, \
407  &bafl_quat.qi, \
408  &bafl_quat.qx, \
409  &bafl_quat.qy, \
410  &bafl_quat.qz, \
411  &bafl_rates.p, \
412  &bafl_rates.q, \
413  &bafl_rates.r, \
414  &bafl_accel_measure.x, \
415  &bafl_accel_measure.y, \
416  &bafl_accel_measure.z, \
417  &bafl_mag.x, \
418  &bafl_mag.y, \
419  &bafl_mag.z); \
420  }
421 #define PERIODIC_SEND_AHRS_LKF_DEBUG(_trans, _dev) { \
422  DOWNLINK_SEND_AHRS_LKF_DEBUG(_trans, _dev, \
423  &bafl_X[0], \
424  &bafl_X[1], \
425  &bafl_X[2], \
426  &bafl_bias.p, \
427  &bafl_bias.q, \
428  &bafl_bias.r, \
429  &bafl_qnorm, \
430  &bafl_phi_accel, \
431  &bafl_theta_accel, \
432  &bafl_P[0][0], \
433  &bafl_P[1][1], \
434  &bafl_P[2][2], \
435  &bafl_P[3][3], \
436  &bafl_P[4][4], \
437  &bafl_P[5][5]); \
438  }
439 #define PERIODIC_SEND_AHRS_LKF_ACC_DBG(_trans, _dev) { \
440  DOWNLINK_SEND_AHRS_LKF_ACC_DBG(_trans, _dev, \
441  &bafl_q_a_err.qi, \
442  &bafl_q_a_err.qx, \
443  &bafl_q_a_err.qy, \
444  &bafl_q_a_err.qz, \
445  &bafl_b_a_err.p, \
446  &bafl_b_a_err.q, \
447  &bafl_b_a_err.r); \
448  }
449 #define PERIODIC_SEND_AHRS_LKF_MAG_DBG(_trans, _dev) { \
450  DOWNLINK_SEND_AHRS_LKF_MAG_DBG(_trans, _dev, \
451  &bafl_q_m_err.qi, \
452  &bafl_q_m_err.qx, \
453  &bafl_q_m_err.qy, \
454  &bafl_q_m_err.qz, \
455  &bafl_b_m_err.p, \
456  &bafl_b_m_err.q, \
457  &bafl_b_m_err.r); \
458  }
459 #else
460 #define PERIODIC_SEND_AHRS_LKF(_trans, _dev) {}
461 #define PERIODIC_SEND_AHRS_LKF_DEBUG(_trans, _dev) {}
462 #define PERIODIC_SEND_AHRS_LKF_MAG_DBG(_trans, _dev) {}
463 #define PERIODIC_SEND_AHRS_LKF_ACC_DBG(_trans, _dev) {}
464 #endif
465 
466 #if defined STABILIZATION_ATTITUDE_TYPE_QUAT && defined STABILIZATION_ATTITUDE_TYPE_INT
467 #define PERIODIC_SEND_AHRS_REF_QUAT(_trans, _dev) { \
468  DOWNLINK_SEND_AHRS_REF_QUAT(_trans, _dev, \
469  &stab_att_ref_quat.qi, \
470  &stab_att_ref_quat.qx, \
471  &stab_att_ref_quat.qy, \
472  &stab_att_ref_quat.qz, \
473  &(stateGetNedToBodyQuat_i()->qi), \
474  &(stateGetNedToBodyQuat_i()->qx), \
475  &(stateGetNedToBodyQuat_i()->qy), \
476  &(stateGetNedToBodyQuat_i()->qz)); \
477  }
478 #else
479 #define PERIODIC_SEND_AHRS_REF_QUAT(_trans, _dev) {}
480 #endif /* STABILIZATION_ATTITUDE_TYPE_QUAT */
481 
482 #ifndef AHRS_FLOAT
483 #define PERIODIC_SEND_AHRS_QUAT_INT(_trans, _dev) { \
484  DOWNLINK_SEND_AHRS_QUAT_INT(_trans, _dev, \
485  &ahrs_impl.ltp_to_imu_quat.qi, \
486  &ahrs_impl.ltp_to_imu_quat.qx, \
487  &ahrs_impl.ltp_to_imu_quat.qy, \
488  &ahrs_impl.ltp_to_imu_quat.qz, \
489  &(stateGetNedToBodyQuat_i()->qi), \
490  &(stateGetNedToBodyQuat_i()->qx), \
491  &(stateGetNedToBodyQuat_i()->qy), \
492  &(stateGetNedToBodyQuat_i()->qz)); \
493  }
494 #endif
495 
496 #if USE_AHRS_CMPL_EULER
497 #define PERIODIC_SEND_AHRS_EULER_INT(_trans, _dev) { \
498  DOWNLINK_SEND_AHRS_EULER_INT(_trans, _dev, \
499  &ahrs_impl.ltp_to_imu_euler.phi, \
500  &ahrs_impl.ltp_to_imu_euler.theta, \
501  &ahrs_impl.ltp_to_imu_euler.psi, \
502  &(stateGetNedToBodyEulers_i()->phi), \
503  &(stateGetNedToBodyEulers_i()->theta), \
504  &(stateGetNedToBodyEulers_i()->psi)); \
505  }
506 #else
507 #ifndef AHRS_FLOAT
508 #define PERIODIC_SEND_AHRS_EULER_INT(_trans, _dev) { \
509  struct Int32Eulers ltp_to_imu_euler; \
510  INT32_EULERS_OF_QUAT(ltp_to_imu_euler, ahrs_impl.ltp_to_imu_quat); \
511  DOWNLINK_SEND_AHRS_EULER_INT(_trans, _dev, \
512  &ltp_to_imu_euler.phi, \
513  &ltp_to_imu_euler.theta, \
514  &ltp_to_imu_euler.psi, \
515  &(stateGetNedToBodyEulers_i()->phi), \
516  &(stateGetNedToBodyEulers_i()->theta), \
517  &(stateGetNedToBodyEulers_i()->psi)); \
518 }
519 #else
520 #define PERIODIC_SEND_AHRS_EULER_INT(_trans, _dev) { \
521  struct FloatEulers ltp_to_imu_euler; \
522  FLOAT_EULERS_OF_QUAT(ltp_to_imu_euler, ahrs_impl.ltp_to_imu_quat); \
523  struct Int32Eulers euler_i; \
524  EULERS_BFP_OF_REAL(euler_i, ltp_to_imu_euler); \
525  DOWNLINK_SEND_AHRS_EULER_INT(_trans, _dev, \
526  &euler_i.phi, \
527  &euler_i.theta, \
528  &euler_i.psi, \
529  &(stateGetNedToBodyEulers_i()->phi), \
530  &(stateGetNedToBodyEulers_i()->theta), \
531  &(stateGetNedToBodyEulers_i()->psi)); \
532  }
533 #endif
534 #endif
535 
536 #define PERIODIC_SEND_AHRS_RMAT_INT(_trans, _dev) { \
537  struct Int32RMat* att_rmat = stateGetNedToBodyRMat_i(); \
538  DOWNLINK_SEND_AHRS_RMAT(_trans, _dev, \
539  &ahrs_impl.ltp_to_imu_rmat.m[0], \
540  &ahrs_impl.ltp_to_imu_rmat.m[1], \
541  &ahrs_impl.ltp_to_imu_rmat.m[2], \
542  &ahrs_impl.ltp_to_imu_rmat.m[3], \
543  &ahrs_impl.ltp_to_imu_rmat.m[4], \
544  &ahrs_impl.ltp_to_imu_rmat.m[5], \
545  &ahrs_impl.ltp_to_imu_rmat.m[6], \
546  &ahrs_impl.ltp_to_imu_rmat.m[7], \
547  &ahrs_impl.ltp_to_imu_rmat.m[8], \
548  &(att_rmat->m[0]), \
549  &(att_rmat->m[1]), \
550  &(att_rmat->m[2]), \
551  &(att_rmat->m[3]), \
552  &(att_rmat->m[4]), \
553  &(att_rmat->m[5]), \
554  &(att_rmat->m[6]), \
555  &(att_rmat->m[7]), \
556  &(att_rmat->m[8])); \
557 }
558 
559 
560 
561 #if USE_VFF
562 #include "subsystems/ins/vf_float.h"
563 #define PERIODIC_SEND_VFF(_trans, _dev) { \
564  DOWNLINK_SEND_VFF(_trans, _dev, \
565  &vff_z_meas, \
566  &vff_z, \
567  &vff_zdot, \
568  &vff_bias, \
569  & vff_P[0][0], \
570  & vff_P[1][1], \
571  & vff_P[2][2]); \
572  }
573 #else
574 #define PERIODIC_SEND_VFF(_trans, _dev) {}
575 #endif
576 
577 #if USE_VFF_EXTENDED
579 #define PERIODIC_SEND_VFF_EXTENDED(_trans, _dev) { \
580  DOWNLINK_SEND_VFF_EXTENDED(_trans, _dev, \
581  &vff_z_meas, \
582  &vff_z_meas_baro, \
583  &vff_z, \
584  &vff_zdot, \
585  &vff_bias, \
586  &vff_offset); \
587  }
588 #else
589 #define PERIODIC_SEND_VFF_EXTENDED(_trans, _dev) {}
590 #endif
591 
592 #if USE_HFF
593 #include "subsystems/ins/hf_float.h"
594 #define PERIODIC_SEND_HFF(_trans, _dev) { \
595  DOWNLINK_SEND_HFF(_trans, _dev, \
596  &b2_hff_state.x, \
597  &b2_hff_state.y, \
598  &b2_hff_state.xdot, \
599  &b2_hff_state.ydot, \
600  &b2_hff_state.xdotdot, \
601  &b2_hff_state.ydotdot); \
602  }
603 #define PERIODIC_SEND_HFF_DBG(_trans, _dev) { \
604  DOWNLINK_SEND_HFF_DBG(_trans, _dev, \
605  &b2_hff_x_meas, \
606  &b2_hff_y_meas, \
607  &b2_hff_xd_meas, \
608  &b2_hff_yd_meas, \
609  &b2_hff_state.xP[0][0], \
610  &b2_hff_state.yP[0][0], \
611  &b2_hff_state.xP[1][1], \
612  &b2_hff_state.yP[1][1]); \
613  }
614 #ifdef GPS_LAG
615 #define PERIODIC_SEND_HFF_GPS(_trans, _dev) { \
616  DOWNLINK_SEND_HFF_GPS(_trans, _dev, \
617  &(b2_hff_rb_last->lag_counter), \
618  &lag_counter_err, \
619  &save_counter); \
620  }
621 #else
622 #define PERIODIC_SEND_HFF_GPS(_trans, _dev) {}
623 #endif
624 #else
625 #define PERIODIC_SEND_HFF(_trans, _dev) {}
626 #define PERIODIC_SEND_HFF_DBG(_trans, _dev) {}
627 #define PERIODIC_SEND_HFF_GPS(_trans, _dev) {}
628 #endif
629 
630 #define PERIODIC_SEND_GUIDANCE_H_INT(_trans, _dev) { \
631  DOWNLINK_SEND_GUIDANCE_H_INT(_trans, _dev, \
632  &guidance_h_pos_sp.x, \
633  &guidance_h_pos_sp.y, \
634  &guidance_h_pos_ref.x, \
635  &guidance_h_pos_ref.y, \
636  &ins_ltp_pos.x, \
637  &ins_ltp_pos.y); \
638  }
639 
640 #define PERIODIC_SEND_INS_Z(_trans, _dev) { \
641  DOWNLINK_SEND_INS_Z(_trans, _dev, \
642  &ins_baro_alt, \
643  &ins_ltp_pos.z, \
644  &ins_ltp_speed.z, \
645  &ins_ltp_accel.z); \
646  }
647 
648 #define PERIODIC_SEND_INS(_trans, _dev) { \
649  DOWNLINK_SEND_INS(_trans, _dev, \
650  &ins_ltp_pos.x, \
651  &ins_ltp_pos.y, \
652  &ins_ltp_pos.z, \
653  &ins_ltp_speed.x, \
654  &ins_ltp_speed.y, \
655  &ins_ltp_speed.z, \
656  &ins_ltp_accel.x, \
657  &ins_ltp_accel.y, \
658  &ins_ltp_accel.z); \
659  }
660 
661 #define PERIODIC_SEND_INS_REF(_trans, _dev) { \
662  if (ins_ltp_initialised) \
663  DOWNLINK_SEND_INS_REF(_trans, _dev, \
664  &ins_ltp_def.ecef.x, \
665  &ins_ltp_def.ecef.y, \
666  &ins_ltp_def.ecef.z, \
667  &ins_ltp_def.lla.lat, \
668  &ins_ltp_def.lla.lon, \
669  &ins_ltp_def.lla.alt, \
670  &ins_ltp_def.hmsl, \
671  &ins_qfe); \
672  }
673 
674 #define PERIODIC_SEND_VERT_LOOP(_trans, _dev) { \
675  DOWNLINK_SEND_VERT_LOOP(_trans, _dev, \
676  &guidance_v_z_sp, \
677  &guidance_v_zd_sp, \
678  &ins_ltp_pos.z, \
679  &ins_ltp_speed.z, \
680  &ins_ltp_accel.z, \
681  &guidance_v_z_ref, \
682  &guidance_v_zd_ref, \
683  &guidance_v_zdd_ref, \
684  &gv_adapt_X, \
685  &gv_adapt_P, \
686  &gv_adapt_Xmeas, \
687  &guidance_v_z_sum_err, \
688  &guidance_v_ff_cmd, \
689  &guidance_v_fb_cmd, \
690  &guidance_v_delta_t); \
691  }
692 
693 #define PERIODIC_SEND_HOVER_LOOP(_trans, _dev) { \
694  DOWNLINK_SEND_HOVER_LOOP(_trans, _dev, \
695  &guidance_h_pos_sp.x, \
696  &guidance_h_pos_sp.y, \
697  &ins_ltp_pos.x, \
698  &ins_ltp_pos.y, \
699  &ins_ltp_speed.x, \
700  &ins_ltp_speed.y, \
701  &ins_ltp_accel.x, \
702  &ins_ltp_accel.y, \
703  &guidance_h_pos_err.x, \
704  &guidance_h_pos_err.y, \
705  &guidance_h_speed_err.x, \
706  &guidance_h_speed_err.y, \
707  &guidance_h_pos_err_sum.x, \
708  &guidance_h_pos_err_sum.y, \
709  &guidance_h_nav_err.x, \
710  &guidance_h_nav_err.y, \
711  &guidance_h_command_earth.x, \
712  &guidance_h_command_earth.y, \
713  &guidance_h_command_body.phi, \
714  &guidance_h_command_body.theta, \
715  &guidance_h_command_body.psi); \
716  }
717 
718 #define PERIODIC_SEND_GUIDANCE_H_REF(_trans, _dev) { \
719  DOWNLINK_SEND_GUIDANCE_H_REF_INT(_trans, _dev, \
720  &guidance_h_pos_sp.x, \
721  &guidance_h_pos_ref.x, \
722  &guidance_h_speed_ref.x, \
723  &guidance_h_accel_ref.x, \
724  &guidance_h_pos_sp.y, \
725  &guidance_h_pos_ref.y, \
726  &guidance_h_speed_ref.y, \
727  &guidance_h_accel_ref.y); \
728 }
729 
731 #define PERIODIC_SEND_ROTORCRAFT_FP(_trans, _dev) { \
732  int32_t carrot_up = -guidance_v_z_sp; \
733  DOWNLINK_SEND_ROTORCRAFT_FP( _trans, _dev, \
734  &(stateGetPositionEnu_i()->x), \
735  &(stateGetPositionEnu_i()->y), \
736  &(stateGetPositionEnu_i()->z), \
737  &(stateGetSpeedEnu_i()->x), \
738  &(stateGetSpeedEnu_i()->y), \
739  &(stateGetSpeedEnu_i()->z), \
740  &(stateGetNedToBodyEulers_i()->phi), \
741  &(stateGetNedToBodyEulers_i()->theta), \
742  &(stateGetNedToBodyEulers_i()->psi), \
743  &guidance_h_pos_sp.y, \
744  &guidance_h_pos_sp.x, \
745  &carrot_up, \
746  &guidance_h_command_body.psi, \
747  &stabilization_cmd[COMMAND_THRUST], \
748  &autopilot_flight_time); \
749  }
750 
751 #if USE_GPS
752 #define PERIODIC_SEND_GPS_INT(_trans, _dev) { \
753  DOWNLINK_SEND_GPS_INT( _trans, _dev, \
754  &gps.ecef_pos.x, \
755  &gps.ecef_pos.y, \
756  &gps.ecef_pos.z, \
757  &gps.lla_pos.lat, \
758  &gps.lla_pos.lon, \
759  &gps.lla_pos.alt, \
760  &gps.hmsl, \
761  &gps.ecef_vel.x, \
762  &gps.ecef_vel.y, \
763  &gps.ecef_vel.z, \
764  &gps.pacc, \
765  &gps.sacc, \
766  &gps.tow, \
767  &gps.pdop, \
768  &gps.num_sv, \
769  &gps.fix); \
770  static uint8_t i; \
771  static uint8_t last_cnos[GPS_NB_CHANNELS]; \
772  if (i == gps.nb_channels) i = 0; \
773  if (i < gps.nb_channels && gps.svinfos[i].cno > 0 && gps.svinfos[i].cno != last_cnos[i]) { \
774  DOWNLINK_SEND_SVINFO(DefaultChannel, DefaultDevice, &i, &gps.svinfos[i].svid, &gps.svinfos[i].flags, &gps.svinfos[i].qi, &gps.svinfos[i].cno, &gps.svinfos[i].elev, &gps.svinfos[i].azim); \
775  last_cnos[i] = gps.svinfos[i].cno; \
776  } \
777  i++; \
778  }
779 #else
780 #define PERIODIC_SEND_GPS_INT(_trans, _dev) {}
781 #endif
782 
784 #define PERIODIC_SEND_ROTORCRAFT_NAV_STATUS(_trans, _dev) { \
785  DOWNLINK_SEND_ROTORCRAFT_NAV_STATUS(_trans, _dev, \
786  &block_time, \
787  &stage_time, \
788  &nav_block, \
789  &nav_stage, \
790  &horizontal_mode); \
791  if (horizontal_mode == HORIZONTAL_MODE_ROUTE) { \
792  float sx = POS_FLOAT_OF_BFP(waypoints[nav_segment_start].x); \
793  float sy = POS_FLOAT_OF_BFP(waypoints[nav_segment_start].y); \
794  float ex = POS_FLOAT_OF_BFP(waypoints[nav_segment_end].x); \
795  float ey = POS_FLOAT_OF_BFP(waypoints[nav_segment_end].y); \
796  DOWNLINK_SEND_SEGMENT(_trans, _dev, &sx, &sy, &ex, &ey); \
797  } \
798  else if (horizontal_mode == HORIZONTAL_MODE_CIRCLE) { \
799  float cx = POS_FLOAT_OF_BFP(waypoints[nav_circle_centre].x); \
800  float cy = POS_FLOAT_OF_BFP(waypoints[nav_circle_centre].y); \
801  float r = POS_FLOAT_OF_BFP(nav_circle_radius); \
802  DOWNLINK_SEND_CIRCLE(_trans, _dev, &cx, &cy, &r); \
803  } \
804  }
805 
806 #define PERIODIC_SEND_WP_MOVED(_trans, _dev) { \
807  static uint8_t i; \
808  i++; if (i >= nb_waypoint) i = 0; \
809  DOWNLINK_SEND_WP_MOVED_ENU(_trans, _dev, \
810  &i, \
811  &(waypoints[i].x), \
812  &(waypoints[i].y), \
813  &(waypoints[i].z)); \
814  }
815 
816 #if USE_CAM
817 #define PERIODIC_SEND_ROTORCRAFT_CAM(_trans, _dev) DOWNLINK_SEND_ROTORCRAFT_CAM(_trans, _dev,&rotorcraft_cam_tilt,&rotorcraft_cam_pan);
818 #else
819 #define PERIODIC_SEND_ROTORCRAFT_CAM(_trans, _dev) {}
820 #endif
821 
822 #ifndef AHRS_FLOAT
823 #define PERIODIC_SEND_ROTORCRAFT_TUNE_HOVER(_trans, _dev) { \
824  DOWNLINK_SEND_ROTORCRAFT_TUNE_HOVER(_trans, _dev, \
825  &radio_control.values[RADIO_ROLL], \
826  &radio_control.values[RADIO_PITCH], \
827  &radio_control.values[RADIO_YAW], \
828  &stabilization_cmd[COMMAND_ROLL], \
829  &stabilization_cmd[COMMAND_PITCH], \
830  &stabilization_cmd[COMMAND_YAW], \
831  &stabilization_cmd[COMMAND_THRUST], \
832  &ahrs_impl.ltp_to_imu_euler.phi, \
833  &ahrs_impl.ltp_to_imu_euler.theta, \
834  &ahrs_impl.ltp_to_imu_euler.psi, \
835  &(stateGetNedToBodyEulers_i()->phi), \
836  &(stateGetNedToBodyEulers_i()->theta), \
837  &(stateGetNedToBodyEulers_i()->psi)); \
838  }
839 #endif
840 
841 #ifdef USE_I2C0
842 #define PERIODIC_SEND_I2C0_ERRORS(_trans, _dev) { \
843  uint16_t i2c0_ack_fail_cnt = i2c0.errors->ack_fail_cnt; \
844  uint16_t i2c0_miss_start_stop_cnt = i2c0.errors->miss_start_stop_cnt; \
845  uint16_t i2c0_arb_lost_cnt = i2c0.errors->arb_lost_cnt; \
846  uint16_t i2c0_over_under_cnt = i2c0.errors->over_under_cnt; \
847  uint16_t i2c0_pec_recep_cnt = i2c0.errors->pec_recep_cnt; \
848  uint16_t i2c0_timeout_tlow_cnt = i2c0.errors->timeout_tlow_cnt; \
849  uint16_t i2c0_smbus_alert_cnt = i2c0.errors->smbus_alert_cnt; \
850  uint16_t i2c0_unexpected_event_cnt = i2c0.errors->unexpected_event_cnt; \
851  uint32_t i2c0_last_unexpected_event = i2c0.errors->last_unexpected_event; \
852  const uint8_t _bus0 = 0; \
853  DOWNLINK_SEND_I2C_ERRORS(_trans, _dev, \
854  &i2c0_ack_fail_cnt, \
855  &i2c0_miss_start_stop_cnt, \
856  &i2c0_arb_lost_cnt, \
857  &i2c0_over_under_cnt, \
858  &i2c0_pec_recep_cnt, \
859  &i2c0_timeout_tlow_cnt, \
860  &i2c0_smbus_alert_cnt, \
861  &i2c0_unexpected_event_cnt, \
862  &i2c0_last_unexpected_event, \
863  &_bus0); \
864  }
865 #else
866 #define PERIODIC_SEND_I2C0_ERRORS(_trans, _dev) {}
867 #endif
868 
869 #ifdef USE_I2C1
870 #define PERIODIC_SEND_I2C1_ERRORS(_trans, _dev) { \
871  uint16_t i2c1_ack_fail_cnt = i2c1.errors->ack_fail_cnt; \
872  uint16_t i2c1_miss_start_stop_cnt = i2c1.errors->miss_start_stop_cnt; \
873  uint16_t i2c1_arb_lost_cnt = i2c1.errors->arb_lost_cnt; \
874  uint16_t i2c1_over_under_cnt = i2c1.errors->over_under_cnt; \
875  uint16_t i2c1_pec_recep_cnt = i2c1.errors->pec_recep_cnt; \
876  uint16_t i2c1_timeout_tlow_cnt = i2c1.errors->timeout_tlow_cnt; \
877  uint16_t i2c1_smbus_alert_cnt = i2c1.errors->smbus_alert_cnt; \
878  uint16_t i2c1_unexpected_event_cnt = i2c1.errors->unexpected_event_cnt; \
879  uint32_t i2c1_last_unexpected_event = i2c1.errors->last_unexpected_event; \
880  const uint8_t _bus1 = 1; \
881  DOWNLINK_SEND_I2C_ERRORS(_trans, _dev, \
882  &i2c1_ack_fail_cnt, \
883  &i2c1_miss_start_stop_cnt, \
884  &i2c1_arb_lost_cnt, \
885  &i2c1_over_under_cnt, \
886  &i2c1_pec_recep_cnt, \
887  &i2c1_timeout_tlow_cnt, \
888  &i2c1_smbus_alert_cnt, \
889  &i2c1_unexpected_event_cnt, \
890  &i2c1_last_unexpected_event, \
891  &_bus1); \
892  }
893 #else
894 #define PERIODIC_SEND_I2C1_ERRORS(_trans, _dev) {}
895 #endif
896 
897 #ifdef USE_I2C2
898 #define PERIODIC_SEND_I2C2_ERRORS(_trans, _dev) { \
899  uint16_t i2c2_ack_fail_cnt = i2c2.errors->ack_fail_cnt; \
900  uint16_t i2c2_miss_start_stop_cnt = i2c2.errors->miss_start_stop_cnt; \
901  uint16_t i2c2_arb_lost_cnt = i2c2.errors->arb_lost_cnt; \
902  uint16_t i2c2_over_under_cnt = i2c2.errors->over_under_cnt; \
903  uint16_t i2c2_pec_recep_cnt = i2c2.errors->pec_recep_cnt; \
904  uint16_t i2c2_timeout_tlow_cnt = i2c2.errors->timeout_tlow_cnt; \
905  uint16_t i2c2_smbus_alert_cnt = i2c2.errors->smbus_alert_cnt; \
906  uint16_t i2c2_unexpected_event_cnt = i2c2.errors->unexpected_event_cnt; \
907  uint32_t i2c2_last_unexpected_event = i2c2.errors->last_unexpected_event; \
908  const uint8_t _bus2 = 2; \
909  DOWNLINK_SEND_I2C_ERRORS(_trans, _dev, \
910  &i2c2_ack_fail_cnt, \
911  &i2c2_miss_start_stop_cnt, \
912  &i2c2_arb_lost_cnt, \
913  &i2c2_over_under_cnt, \
914  &i2c2_pec_recep_cnt, \
915  &i2c2_timeout_tlow_cnt, \
916  &i2c2_smbus_alert_cnt, \
917  &i2c2_unexpected_event_cnt, \
918  &i2c2_last_unexpected_event, \
919  &_bus2); \
920  }
921 #else
922 #define PERIODIC_SEND_I2C2_ERRORS(_trans, _dev) {}
923 #endif
924 
925 #ifndef SITL
926 #define PERIODIC_SEND_I2C_ERRORS(_trans, _dev) { \
927  static uint8_t _i2c_nb_cnt = 0; \
928  switch (_i2c_nb_cnt) { \
929  case 0: \
930  PERIODIC_SEND_I2C0_ERRORS(_trans, _dev); break; \
931  case 1: \
932  PERIODIC_SEND_I2C1_ERRORS(_trans, _dev); break; \
933  case 2: \
934  PERIODIC_SEND_I2C2_ERRORS(_trans, _dev); break; \
935  default: \
936  break; \
937  } \
938  _i2c_nb_cnt++; \
939  if (_i2c_nb_cnt == 3) \
940  _i2c_nb_cnt = 0; \
941  }
942 #else
943 #define PERIODIC_SEND_I2C_ERRORS(_trans, _dev) {}
944 #endif
945 
946 #ifdef BOOZ2_TRACK_CAM
947 #include "cam_track.h"
948 #define PERIODIC_SEND_CAM_TRACK(_trans, _dev) DOWNLINK_SEND_NPS_SPEED_POS(_trans, _dev, \
949  &target_accel_ned.x, \
950  &target_accel_ned.y, \
951  &target_accel_ned.z, \
952  &target_speed_ned.x, \
953  &target_speed_ned.y, \
954  &target_speed_ned.z, \
955  &target_pos_ned.x, \
956  &target_pos_ned.y, \
957  &target_pos_ned.z)
958 #else
959 #define PERIODIC_SEND_CAM_TRACK(_trans, _dev) {}
960 #endif
961 
962 #ifdef ARDRONE2_RAW
963 #include "navdata.h"
964 #define PERIODIC_SEND_ARDRONE_NAVDATA(_trans, _dev) DOWNLINK_SEND_ARDRONE_NAVDATA(_trans, _dev, \
965  &navdata->taille, \
966  &navdata->nu_trame, \
967  &navdata->ax, \
968  &navdata->ay, \
969  &navdata->az, \
970  &navdata->vx, \
971  &navdata->vy, \
972  &navdata->vz, \
973  &navdata->temperature_acc, \
974  &navdata->temperature_gyro, \
975  &navdata->ultrasound, \
976  &navdata->us_debut_echo, \
977  &navdata->us_fin_echo, \
978  &navdata->us_association_echo, \
979  &navdata->us_distance_echo, \
980  &navdata->us_curve_time, \
981  &navdata->us_curve_value, \
982  &navdata->us_curve_ref, \
983  &navdata->nb_echo, \
984  &navdata->sum_echo, \
985  &navdata->gradient, \
986  &navdata->flag_echo_ini, \
987  &navdata->pressure, \
988  &navdata->temperature_pressure, \
989  &navdata->mx, \
990  &navdata->my, \
991  &navdata->mz, \
992  &navdata->chksum \
993  )
994 #else
995 #define PERIODIC_SEND_ARDRONE_NAVDATA(_trans, _dev) {}
996 #endif
997 
998 #include "generated/settings.h"
999 #define PERIODIC_SEND_DL_VALUE(_trans, _dev) PeriodicSendDlValue(_trans, _dev)
1000 
1001 /*
1002  * Sending of UART errors.
1003  */
1004 #ifdef USE_UART1
1005 #define PERIODIC_SEND_UART1_ERRORS(_trans, _dev) { \
1006  const uint8_t _bus1 = 1; \
1007  DOWNLINK_SEND_UART_ERRORS(_trans, _dev, \
1008  &uart1.ore, \
1009  &uart1.ne_err, \
1010  &uart1.fe_err, \
1011  &_bus1); \
1012  }
1013 #else
1014 #define PERIODIC_SEND_UART1_ERRORS(_trans, _dev) {}
1015 #endif
1016 
1017 #ifdef USE_UART2
1018 #define PERIODIC_SEND_UART2_ERRORS(_trans, _dev) { \
1019  const uint8_t _bus2 = 2; \
1020  DOWNLINK_SEND_UART_ERRORS(_trans, _dev, \
1021  &uart2.ore, \
1022  &uart2.ne_err, \
1023  &uart2.fe_err, \
1024  &_bus2); \
1025  }
1026 #else
1027 #define PERIODIC_SEND_UART2_ERRORS(_trans, _dev) {}
1028 #endif
1029 
1030 #ifdef USE_UART3
1031 #define PERIODIC_SEND_UART3_ERRORS(_trans, _dev) { \
1032  const uint8_t _bus3 = 3; \
1033  DOWNLINK_SEND_UART_ERRORS(_trans, _dev, \
1034  &uart3.ore, \
1035  &uart3.ne_err, \
1036  &uart3.fe_err, \
1037  &_bus3); \
1038  }
1039 #else
1040 #define PERIODIC_SEND_UART3_ERRORS(_trans, _dev) {}
1041 #endif
1042 
1043 #ifdef USE_UART5
1044 #define PERIODIC_SEND_UART5_ERRORS(_trans, _dev) { \
1045  const uint8_t _bus5 = 5; \
1046  DOWNLINK_SEND_UART_ERRORS(_trans, _dev, \
1047  &uart5.ore, \
1048  &uart5.ne_err, \
1049  &uart5.fe_err, \
1050  &_bus5); \
1051  }
1052 #else
1053 #define PERIODIC_SEND_UART5_ERRORS(_trans, _dev) {}
1054 #endif
1055 
1056 
1057 #ifndef SITL
1058 #define PERIODIC_SEND_UART_ERRORS(_trans, _dev) { \
1059  static uint8_t uart_nb_cnt = 0; \
1060  switch (uart_nb_cnt) { \
1061  case 0: \
1062  PERIODIC_SEND_UART1_ERRORS(_trans, _dev); break; \
1063  case 1: \
1064  PERIODIC_SEND_UART2_ERRORS(_trans, _dev); break; \
1065  case 2: \
1066  PERIODIC_SEND_UART3_ERRORS(_trans, _dev); break; \
1067  case 3: \
1068  PERIODIC_SEND_UART5_ERRORS(_trans, _dev); break; \
1069  default: break; \
1070  } \
1071  uart_nb_cnt++; \
1072  if (uart_nb_cnt == 4) \
1073  uart_nb_cnt = 0; \
1074  }
1075 #else
1076 #define PERIODIC_SEND_UART_ERRORS(_trans, _dev) {}
1077 #endif
1078 
1079 #endif /* TELEMETRY_H */
Interface to align the AHRS via low-passed measurements at startup.
arch independent UART (Universal Asynchronous Receiver/Transmitter) API
Attitude and Heading Reference System interface.
Complementary filter in euler representation (fixed-point).
Common barometric sensor implementation.
Interface for extended vertical filter (in float).
Horizontal filter (x,y) to estimate position and velocity.
Integrated Navigation System interface.
Autopilot modes.
blob tracking with cmucam
Vertical filter (in float) estimating altitude, velocity and accel bias.
AHRS implementation for ardrone2-sdk based on AT-commands.
Architecture independent timing functions.
Device independent GPS code (interface)
Hardware independent API for actuators (servos, motor controllers).
Inertial Measurement Unit interface.
API to get/set the generic vehicle states.
General stabilization interface for rotorcrafts.
Linearized Kalman Filter for attitude estimation.
Architecture independent I2C (Inter-Integrated Circuit Bus) API.