Paparazzi UAS  v4.2.2_stable-4-gcc32f65
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
main_ap.c
Go to the documentation of this file.
1 /*
2  * $Id$
3  *
4  * Copyright (C) 2003-2010 The Paparazzi Team
5  *
6  * This file is part of paparazzi.
7  *
8  * paparazzi is free software; you can redistribute it and/or modify
9  * it under the terms of the GNU General Public License as published by
10  * the Free Software Foundation; either version 2, or (at your option)
11  * any later version.
12  *
13  * paparazzi is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with paparazzi; see the file COPYING. If not, write to
20  * the Free Software Foundation, 59 Temple Place - Suite 330,
21  * Boston, MA 02111-1307, USA.
22  *
23  */
24 
33 #define MODULES_C
34 
35 #include <math.h>
36 
38 #include "mcu.h"
39 #include "mcu_periph/sys_time.h"
40 
41 #include "link_mcu_spi.h"
42 
43 // Sensors
44 #if USE_GPS
45 #include "subsystems/gps.h"
46 #endif
47 #if USE_IMU
48 #include "subsystems/imu.h"
49 #endif
50 #if USE_AHRS
51 #include "subsystems/ahrs.h"
52 #endif
53 #if USE_AHRS_ALIGNER
55 #endif
56 
57 // autopilot & control
59 #include "estimator.h"
61 #include CTRL_TYPE_H
62 #include "subsystems/nav.h"
63 #include "generated/flight_plan.h"
64 #ifdef TRAFFIC_INFO
66 #endif
67 
68 // datalink & telemetry
70 #include "subsystems/settings.h"
73 
74 // modules & settings
75 #include "generated/modules.h"
76 #include "generated/settings.h"
77 #if defined RADIO_CONTROL || defined RADIO_CONTROL_AUTO1
78 #include "rc_settings.h"
79 #endif
80 
81 #include "gpio.h"
82 #include "led.h"
83 
84 #if defined RADIO_CONTROL
85 #pragma message "CAUTION! radio control roll channel input has been changed to follow aerospace sign conventions.\n You will have to change your radio control xml file to get a positive value when banking right!"
86 #endif
87 
88 
89 
90 #if USE_AHRS
91 #if USE_IMU
92 static inline void on_gyro_event( void );
93 static inline void on_accel_event( void );
94 static inline void on_mag_event( void );
95 volatile uint8_t ahrs_timeout_counter = 0;
96 #else
97 static inline void on_ahrs_event(void);
98 #endif // USE_IMU
99 #endif // USE_AHRS
100 
101 #if USE_GPS
102 static inline void on_gps_solution( void );
103 #endif
104 
105 
107 
108 // what version is this ????
109 static const uint16_t version = 1;
110 
113 
115 
116 #if defined RADIO_CONTROL || defined RADIO_CONTROL_AUTO1
117 static uint8_t mcu1_ppm_cpt;
118 #endif
119 
121 
122 bool_t launch = FALSE;
123 
124 
129 
133 static int32_t current; // milliAmpere
134 
138 float energy;
139 
140 bool_t gps_lost = FALSE;
141 
142 
149 
150 #ifndef CONTROL_FREQUENCY
151 #ifdef CONTROL_RATE
152 #define CONTROL_FREQUENCY CONTROL_RATE
153 //#warning "CONTROL_RATE deprecated. Renamed into CONTROL_FREQUENCY (in airframe file)"
154 #else
155 #define CONTROL_FREQUENCY 20
156 #endif
157 #endif
158 
159 #ifndef NAVIGATION_FREQUENCY
160 #define NAVIGATION_FREQUENCY 4
161 #endif
162 
163 #ifndef MODULES_FREQUENCY
164 #define MODULES_FREQUENCY 60
165 #endif
166 
167 void init_ap( void ) {
168 #ifndef SINGLE_MCU
169  mcu_init();
170 #endif /* SINGLE_MCU */
171 
172  /************* Sensors initialization ***************/
173 #if USE_GPS
174  gps_init();
175 #endif
176 
177 #ifdef USE_GPIO
178  GpioInit();
179 #endif
180 
181 #if USE_IMU
182  imu_init();
183 #endif
184 
185 #if USE_AHRS_ALIGNER
187 #endif
188 
189 #if USE_AHRS
190  ahrs_init();
191 #endif
192 
193  /************* Links initialization ***************/
194 #if defined MCU_SPI_LINK || defined MCU_UART_LINK
195  link_mcu_init();
196 #endif
197 #if USE_AUDIO_TELEMETRY
199 #endif
200 
201  /************ Internal status ***************/
202  h_ctl_init();
203  v_ctl_init();
204  estimator_init();
205 #ifdef ALT_KALMAN
206  alt_kalman_init();
207 #endif
208  nav_init();
209 
210  modules_init();
211 
212  settings_init();
213 
214  /**** start timers for periodic functions *****/
219  telemetry_tid = sys_time_register_timer(1./60, NULL);
221 
223  mcu_int_enable();
224 
225 #if defined DATALINK
226 #if DATALINK == XBEE
227  xbee_init();
228 #endif
229 #endif /* DATALINK */
230 
231 #if defined AEROCOMM_DATA_PIN
232  IO0DIR |= _BV(AEROCOMM_DATA_PIN);
233  IO0SET = _BV(AEROCOMM_DATA_PIN);
234 #endif
235 
237 
238  /************ Multi-uavs status ***************/
239 
240 #ifdef TRAFFIC_INFO
242 #endif
243 }
244 
245 
247 
249  sensors_task();
250 
252  navigation_task();
253 
254 #ifndef AHRS_TRIGGERED_ATTITUDE_LOOP
256  attitude_loop();
257 #endif
258 
260  modules_periodic_task();
261 
263  monitor_task();
264 
266  reporting_task();
267  LED_PERIODIC();
268  }
269 
270 }
271 
272 
273 /******************** Interaction with FBW *****************************/
274 
277 #if defined RADIO_CONTROL || defined RADIO_CONTROL_AUTO1
278 static inline uint8_t pprz_mode_update( void ) {
279  if ((pprz_mode != PPRZ_MODE_HOME &&
281 #ifdef UNLOCKED_HOME_MODE
282  || TRUE
283 #endif
284  ) {
285 #ifndef RADIO_AUTO_MODE
287 #else
288 #pragma message "Using RADIO_AUTO_MODE to switch between AUTO1 and AUTO2."
289  /* If RADIO_AUTO_MODE is enabled mode swithing will be seperated between two switches/channels
290  * RADIO_MODE will switch between PPRZ_MODE_MANUAL and any PPRZ_MODE_AUTO mode selected by RADIO_AUTO_MODE.
291  *
292  * This is mainly a cludge for entry level radios with no three-way switch but two available two-way switches which can be used.
293  */
295  /* RADIO_MODE in MANUAL position */
297  } else {
298  /* RADIO_MODE not in MANUAL position.
299  * Select AUTO mode bassed on RADIO_AUTO_MODE channel
300  */
301  return ModeUpdate(pprz_mode, (fbw_state->channels[RADIO_AUTO_MODE] > THRESHOLD2) ? PPRZ_MODE_AUTO2 : PPRZ_MODE_AUTO1);
302  }
303 #endif // RADIO_AUTO_MODE
304  } else
305  return FALSE;
306 }
307 #else // not RADIO_CONTROL
308 static inline uint8_t pprz_mode_update( void ) {
309  return FALSE;
310 }
311 #endif
312 
313 static inline uint8_t mcu1_status_update( void ) {
314  uint8_t new_status = fbw_state->status;
315  if (mcu1_status != new_status) {
316  bool_t changed = ((mcu1_status&MASK_FBW_CHANGED) != (new_status&MASK_FBW_CHANGED));
317  mcu1_status = new_status;
318  return changed;
319  }
320  return FALSE;
321 }
322 
323 
326 static inline void copy_from_to_fbw ( void ) {
327 #ifdef SetAutoCommandsFromRC
328  SetAutoCommandsFromRC(ap_state->commands, fbw_state->channels);
329 #elif defined RADIO_YAW && defined COMMAND_YAW
330  ap_state->commands[COMMAND_YAW] = fbw_state->channels[RADIO_YAW];
331 #endif
332 }
333 
335 #ifndef RC_LOST_MODE
336 #define RC_LOST_MODE PPRZ_MODE_HOME
337 #endif
338 
342 static inline void telecommand_task( void ) {
343  uint8_t mode_changed = FALSE;
345 
346  uint8_t really_lost = bit_is_set(fbw_state->status, STATUS_RADIO_REALLY_LOST) && (pprz_mode == PPRZ_MODE_AUTO1 || pprz_mode == PPRZ_MODE_MANUAL);
348  if (too_far_from_home) {
350  mode_changed = TRUE;
351  }
352  if (really_lost) {
354  mode_changed = TRUE;
355  }
356  }
357  if (bit_is_set(fbw_state->status, AVERAGED_CHANNELS_SENT)) {
358  bool_t pprz_mode_changed = pprz_mode_update();
359  mode_changed |= pprz_mode_changed;
360 #if defined RADIO_CALIB && defined RADIO_CONTROL_SETTINGS
361  bool_t calib_mode_changed = RcSettingsModeUpdate(fbw_state->channels);
362  rc_settings(calib_mode_changed || pprz_mode_changed);
363  mode_changed |= calib_mode_changed;
364 #endif
365  }
366  mode_changed |= mcu1_status_update();
367  if ( mode_changed )
369 
370 #if defined RADIO_CONTROL || defined RADIO_CONTROL_AUTO1
371 
374  if (pprz_mode == PPRZ_MODE_AUTO1) {
376  h_ctl_roll_setpoint = FLOAT_OF_PPRZ(fbw_state->channels[RADIO_ROLL], 0., AUTO1_MAX_ROLL);
377 
379  h_ctl_pitch_setpoint = FLOAT_OF_PPRZ(fbw_state->channels[RADIO_PITCH], 0., AUTO1_MAX_PITCH);
380  }
386  }
389  mcu1_ppm_cpt = fbw_state->ppm_cpt;
390 #endif // RADIO_CONTROL
391 
392 
393  vsupply = fbw_state->vsupply;
394  current = fbw_state->current;
395 
396 #ifdef RADIO_CONTROL
397  if (!estimator_flight_time) {
399  launch = TRUE;
400  }
401  }
402 #endif
403 }
404 
405 
406 /**************************** Periodic tasks ***********************************/
407 
412 void reporting_task( void ) {
413  static uint8_t boot = TRUE;
414 
416  if (boot) {
417  DOWNLINK_SEND_BOOT(DefaultChannel, DefaultDevice, &version);
418  boot = FALSE;
419  }
421  else {
422  PeriodicSendAp(DefaultChannel, DefaultDevice);
423  }
424 }
425 
426 
427 #ifdef FAILSAFE_DELAY_WITHOUT_GPS
428 #define GpsTimeoutError (sys_time.nb_sec - gps.last_fix_time > FAILSAFE_DELAY_WITHOUT_GPS)
429 #endif
430 
434 void navigation_task( void ) {
435 #if defined FAILSAFE_DELAY_WITHOUT_GPS
436 
437  static uint8_t last_pprz_mode;
438 
441  if (launch) {
442  if (GpsTimeoutError) {
444  last_pprz_mode = pprz_mode;
447  gps_lost = TRUE;
448  }
449  } else if (gps_lost) { /* GPS is ok */
451  pprz_mode = last_pprz_mode;
452  gps_lost = FALSE;
453 
455  }
456  }
457 #endif /* GPS && FAILSAFE_DELAY_WITHOUT_GPS */
458 
460  if (pprz_mode == PPRZ_MODE_HOME)
461  nav_home();
463  nav_without_gps();
464  else
466 
467 #ifdef TCAS
468  CallTCAS();
469 #endif
470 
471 #ifndef PERIOD_NAVIGATION_0 // If not sent periodically (in default 0 mode)
473 #endif
474 
476 
477  /* The nav task computes only nav_altitude. However, we are interested
478  by desired_altitude (= nav_alt+alt_shift) in any case.
479  So we always run the altitude control loop */
482 
485 #ifdef H_CTL_RATE_LOOP
486  /* Be sure to be in attitude mode, not roll */
488 #endif
490  h_ctl_course_loop(); /* aka compute nav_desired_roll */
491 
492  // climb_loop(); //4Hz
493  }
494  energy += ((float)current) / 3600.0f * 0.25f; // mAh = mA * dt (4Hz -> hours)
495 }
496 
497 
498 #if USE_AHRS
499 #ifdef AHRS_TRIGGERED_ATTITUDE_LOOP
500 volatile uint8_t new_ins_attitude = 0;
501 #endif
502 #endif
503 
504 void attitude_loop( void ) {
505 
506 #if USE_INFRARED
508 #endif /* USE_INFRARED */
509 
510  if (pprz_mode >= PPRZ_MODE_AUTO2)
511  {
514  else if (v_ctl_mode >= V_CTL_MODE_AUTO_CLIMB)
515  {
517  }
518 
519 #if defined V_CTL_THROTTLE_IDLE
520  Bound(v_ctl_throttle_setpoint, TRIM_PPRZ(V_CTL_THROTTLE_IDLE*MAX_PPRZ), MAX_PPRZ);
521 #endif
522 
523 #ifdef V_CTL_POWER_CTL_BAT_NOMINAL
524  if (vsupply > 0.) {
525  v_ctl_throttle_setpoint *= 10. * V_CTL_POWER_CTL_BAT_NOMINAL / (float)vsupply;
527  }
528 #endif
529 
531  Bound(h_ctl_pitch_setpoint, H_CTL_PITCH_MIN_SETPOINT, H_CTL_PITCH_MAX_SETPOINT);
534  }
535 
536  h_ctl_attitude_loop(); /* Set h_ctl_aileron_setpoint & h_ctl_elevator_setpoint */
538  ap_state->commands[COMMAND_THROTTLE] = v_ctl_throttle_slewed;
539  ap_state->commands[COMMAND_ROLL] = -h_ctl_aileron_setpoint;
540 
541  ap_state->commands[COMMAND_PITCH] = h_ctl_elevator_setpoint;
542 
543 #if defined MCU_SPI_LINK || defined MCU_UART_LINK
544  link_mcu_send();
545 #elif defined INTER_MCU && defined SINGLE_MCU
546 
548 #endif
549 
550 }
551 
552 
554 void sensors_task( void ) {
555 #if USE_IMU
556  imu_periodic();
557 
558 #if USE_AHRS
559  if (ahrs_timeout_counter < 255)
560  ahrs_timeout_counter ++;
561 #endif // USE_AHRS
562 #endif // USE_IMU
563 
564 #if USE_INS
566 #endif
567 }
568 
569 
570 
571 
573 #define LOW_BATTERY_DELAY 5
574 
576 #ifndef KILL_MODE_DISTANCE
577 #define KILL_MODE_DISTANCE (1.5*MAX_DIST_FROM_HOME)
578 #endif
579 
581 #define MIN_SPEED_FOR_TAKEOFF 5.
582 
584 void monitor_task( void ) {
587 #if defined DATALINK || defined SITL
588  datalink_time++;
589 #endif
590 
591  static uint8_t t = 0;
592  if (vsupply < CATASTROPHIC_BAT_LEVEL*10)
593  t++;
594  else
595  t = 0;
598 
599  if (!estimator_flight_time &&
602  launch = TRUE; /* Not set in non auto launch */
603  uint16_t time_sec = sys_time.nb_sec;
604  DOWNLINK_SEND_TAKEOFF(DefaultChannel, DefaultDevice, &time_sec);
605  }
606 
607 #ifdef USE_GPIO
608  GpioUpdate1();
609 #endif
610 }
611 
612 
613 /*********** EVENT ***********************************************************/
614 void event_task_ap( void ) {
615 
616 #ifndef SINGLE_MCU
617 #if defined USE_I2C0 || defined USE_I2C1 || defined USE_I2C2
618  i2c_event();
619 #endif
620 #endif
621 
622 #if USE_AHRS
623 #if USE_IMU
625 #else
626  AhrsEvent(on_ahrs_event);
627 #endif // USE_IMU
628 #endif // USE_AHRS
629 
630 #if USE_GPS
631  GpsEvent(on_gps_solution);
632 #endif
635  DatalinkEvent();
636 
637 
638 #if defined MCU_SPI_LINK || defined MCU_UART_LINK
640 #endif
641 
643  /* receive radio control task from fbw */
646  }
647 
648  modules_event_task();
649 
650 #ifdef AHRS_TRIGGERED_ATTITUDE_LOOP
651  if (new_ins_attitude > 0)
652  {
653  attitude_loop();
654  //LED_TOGGLE(3);
655  new_ins_attitude = 0;
656  }
657 #endif
658 
659 } /* event_task_ap() */
660 
661 
662 #if USE_GPS
663 static inline void on_gps_solution( void ) {
665 #if USE_AHRS
666  ahrs_update_gps();
667 #endif
668 #ifdef GPS_TRIGGERED_FUNCTION
669  GPS_TRIGGERED_FUNCTION();
670 #endif
671 }
672 #endif
673 
674 
675 #if USE_AHRS
676 #if USE_IMU
677 static inline void on_accel_event( void ) {
678 }
679 
680 static inline void on_gyro_event( void ) {
681 
682  ahrs_timeout_counter = 0;
683 
684 #ifdef AHRS_CPU_LED
685  LED_ON(AHRS_CPU_LED);
686 #endif
687 
688 #if USE_AHRS_ALIGNER
689  // Run aligner on raw data as it also makes averages.
690  if (ahrs.status == AHRS_UNINIT) {
691  ImuScaleGyro(imu);
695  ahrs_align();
696  return;
697  }
698 #endif
699 
700 #if PERIODIC_FREQUENCY == 60
701  ImuScaleGyro(imu);
703 
704  ahrs_propagate();
707 
708 #ifdef AHRS_TRIGGERED_ATTITUDE_LOOP
709  new_ins_attitude = 1;
710 #endif
711 
712 #else //PERIODIC_FREQUENCY
713  static uint8_t _reduced_propagation_rate = 0;
714  static uint8_t _reduced_correction_rate = 0;
715  static struct Int32Vect3 acc_avg;
716  static struct Int32Rates gyr_avg;
717 
718  RATES_ADD(gyr_avg, imu.gyro_unscaled);
719  VECT3_ADD(acc_avg, imu.accel_unscaled);
720 
721  _reduced_propagation_rate++;
722  if (_reduced_propagation_rate < (PERIODIC_FREQUENCY / AHRS_PROPAGATE_FREQUENCY))
723  {
724  }
725  else
726  {
727  _reduced_propagation_rate = 0;
728 
730  INT_RATES_ZERO(gyr_avg);
731 
732  ImuScaleGyro(imu);
733 
734  ahrs_propagate();
735 
736  _reduced_correction_rate++;
737  if (_reduced_correction_rate >= (AHRS_PROPAGATE_FREQUENCY / AHRS_CORRECT_FREQUENCY))
738  {
739  _reduced_correction_rate = 0;
740  VECT3_SDIV(imu.accel_unscaled, acc_avg, (PERIODIC_FREQUENCY / AHRS_CORRECT_FREQUENCY) );
741  INT_VECT3_ZERO(acc_avg);
744  }
745 
747 
748 #ifdef AHRS_TRIGGERED_ATTITUDE_LOOP
749  new_ins_attitude = 1;
750 #endif
751  }
752 #endif //PERIODIC_FREQUENCY
753 
754 #ifdef AHRS_CPU_LED
755  LED_OFF(AHRS_CPU_LED);
756 #endif
757 
758 }
759 
760 static inline void on_mag_event(void)
761 {
762 #if USE_MAGNETOMETER
763  ImuScaleMag(imu);
764  if (ahrs.status == AHRS_RUNNING) {
765  ahrs_update_mag();
766  }
767 #endif
768 }
769 
770 #else // USE_IMU not defined
771 static inline void on_ahrs_event(void)
772 {
773 #ifdef AHRS_UPDATE_FW_ESTIMATOR
775 #endif
776 }
777 #endif // USE_IMU
778 
779 #endif // USE_AHRS
780 
void monitor_task(void)
monitor stuff run at 1Hz
Definition: main_ap.c:584
unsigned short uint16_t
Definition: types.h:16
void h_ctl_course_loop(void)
static int32_t current
Supply current in milliAmpere.
Definition: main_ap.c:133
tid_t monitor_tid
id for monitor_task() timer
Definition: main_ap.c:148
tid_t modules_tid
id for modules_periodic_task() timer
Definition: main_ap.c:143
Attitude and Heading Reference System interface.
void traffic_info_init(void)
Definition: traffic_info.c:37
float estimator_hspeed_mod
module of horizontal ground speed in m/s
Definition: estimator.c:64
void imu_periodic(void)
Definition: imu_b2_arch.c:83
static void on_accel_event(void)
Definition: main.c:223
uint16_t estimator_flight_time
flight time in seconds.
Definition: estimator.c:59
void h_ctl_attitude_loop(void)
void ahrs_update_accel(void)
Update AHRS state with accerleration measurements.
#define LATERAL_MODE_MANUAL
Definition: autopilot.h:60
void i2c_event(void)
Definition: i2c_arch.c:344
tid_t telemetry_tid
id for telemetry_periodic() timer
Definition: main_ap.c:144
static uint8_t mcu1_status_update(void)
Definition: main_ap.c:313
Variable setting though the radio control.
pprz_t v_ctl_throttle_setpoint
Definition: energy_ctrl.c:134
void navigation_task(void)
Compute desired_course.
Definition: main_ap.c:434
volatile bool_t inter_mcu_received_ap
Definition: inter_mcu.c:39
AP ( AutoPilot ) process API.
void h_ctl_init(void)
static void audio_telemetry_init(void)
tid_t attitude_tid
id for attitude_loop() timer
Definition: main_ap.c:146
struct Ahrs ahrs
global AHRS state (fixed point version)
Definition: ahrs.c:24
static void telecommand_task(void)
Function to be called when a message from FBW is available.
Definition: main_ap.c:342
#define GpioInit()
Definition: gpio.h:33
volatile bool_t inter_mcu_received_fbw
Definition: inter_mcu.c:38
uint8_t tid_t
sys_time timer id type
Definition: sys_time.h:43
struct Int32Rates gyro_unscaled
unscaled gyroscope measurements
Definition: imu.h:48
#define LED_ON(i)
Definition: led_hw.h:28
#define AHRS_PROPAGATE_FREQUENCY
uint8_t lateral_mode
Definition: main_ap.c:112
#define INT_RATES_ZERO(_e)
tid_t sensors_tid
id for sensors_task() timer
Definition: main_ap.c:145
static void on_gyro_event(void)
Definition: main.c:231
#define V_CTL_MODE_AUTO_THROTTLE
#define ImuScaleGyro(_imu)
Definition: imu_nps.h:89
#define PPRZ_MODE_AUTO2
Definition: autopilot.h:46
void estimator_update_state_gps(void)
Definition: estimator.c:210
uint8_t status
Definition: ahrs_aligner.h:40
#define CONTROL_FREQUENCY
Definition: main_ap.c:155
#define RC_LOST_MODE
mode to enter when RC is lost in PPRZ_MODE_MANUAL or PPRZ_MODE_AUTO1
Definition: main_ap.c:336
uint16_t vsupply
Supply voltage in deciVolt.
Definition: main_ap.c:128
pprz_t h_ctl_elevator_setpoint
pprz_t h_ctl_aileron_setpoint
uint8_t pprz_mode
Definition: main_ap.c:111
void v_ctl_throttle_slew(void)
Computes slewed throttle from throttle setpoint called at 20Hz.
Definition: energy_ctrl.c:411
float dist2_to_home
Definition: common_nav.c:31
#define ImuEvent(_gyro_handler, _accel_handler, _mag_handler)
Definition: imu_navgo.h:58
void v_ctl_climb_loop(void)
Definition: energy_ctrl.c:301
static uint8_t pprz_mode_update(void)
Update paparazzi mode.
Definition: main_ap.c:308
struct fbw_state * fbw_state
Definition: inter_mcu.c:34
void init_ap(void)
Definition: main_ap.c:167
#define PERIODIC_FREQUENCY
Definition: imu_aspirin2.c:54
#define FALSE
Definition: imu_chimu.h:141
#define RADIO_PITCH
Definition: spektrum_arch.h:42
struct ap_state * ap_state
Definition: inter_mcu.c:35
#define CallTCAS()
Definition: tcas.h:59
bool_t gps_lost
Definition: main_ap.c:140
#define RATES_SDIV(_ro, _ri, _s)
Definition: pprz_algebra.h:352
void settings_init(void)
Definition: settings.c:8
#define mcu_int_enable()
Definition: mcu_arch.h:32
void ahrs_update_mag(void)
Update AHRS state with magnetometer measurements.
void ahrs_init(void)
AHRS initialization.
Definition: ins_xsens.c:75
void common_nav_periodic_task_4Hz()
Definition: common_nav.c:97
#define TRIM_UPPRZ(pprz)
Definition: paparazzi.h:14
struct Int32Vect3 accel_unscaled
unscaled accelerometer measurements
Definition: imu.h:49
#define V_CTL_MODE_AUTO_ALT
#define THROTTLE_THRESHOLD_TAKEOFF
Definition: autopilot.h:71
struct AhrsAligner ahrs_aligner
Definition: ahrs_aligner.c:30
volatile uint8_t new_ins_attitude
Definition: ins_chimu_spi.c:36
#define GpsEvent(_sol_available_callback)
Definition: gps_mtk.h:73
void ahrs_update_infrared(void)
Definition: ahrs_infrared.c:89
Architecture independent timing functions.
void ahrs_update_gps(void)
static void copy_from_to_fbw(void)
Send back uncontrolled channels.
Definition: main_ap.c:326
static const uint16_t version
Definition: main_ap.c:109
#define PPRZ_MODE_HOME
Definition: autopilot.h:47
Device independent GPS code (interface)
uint8_t status
status of the AHRS, AHRS_UNINIT or AHRS_RUNNING
Definition: ahrs.h:54
void event_task_ap(void)
Definition: main_ap.c:614
#define AHRS_ALIGNER_LOCKED
Definition: ahrs_aligner.h:32
#define ImuScaleMag(_imu)
Definition: imu_b2.h:199
#define PPRZ_MODE_AUTO1
Definition: autopilot.h:45
#define RATES_ADD(_a, _b)
Definition: pprz_algebra.h:310
#define GpioUpdate1()
Definition: gpio.h:26
void ahrs_align(void)
Aligns the AHRS.
#define INT_VECT3_ZERO(_v)
void reporting_task(void)
Send a series of initialisation messages followed by a stream of periodic ones.
Definition: main_ap.c:412
uint8_t v_ctl_mode
Definition: energy_ctrl.c:77
Inertial Measurement Unit interface.
int sys_time_register_timer(float duration, sys_time_cb cb)
Register a new system timer.
Definition: sys_time.c:35
angular rates
void rc_settings(bool_t mode_changed __attribute__((unused)))
Includes generated code from tuning_rc.xml.
Definition: rc_settings.c:52
#define RADIO_YAW
Definition: spektrum_arch.h:43
#define V_CTL_MODE_AUTO_CLIMB
static bool_t sys_time_check_and_ack_timer(tid_t id)
Definition: sys_time.h:90
void ins_periodic_task(void)
Definition: fw_ins_vn100.c:85
float energy
Fuel consumption (mAh) TODO: move to electrical subsystem.
Definition: main_ap.c:138
#define MODULES_FREQUENCY
Definition: main_ap.c:164
static void on_mag_event(void)
Definition: main.c:271
signed long int32_t
Definition: types.h:19
#define IO0SET
Definition: LPC21xx.h:302
#define AHRS_UNINIT
Definition: ahrs.h:33
#define TRUE
Definition: imu_chimu.h:144
#define IO0DIR
Definition: LPC21xx.h:303
uint16_t datalink_time
Definition: sim_ap.c:46
void ahrs_update_fw_estimator(void)
#define VECT3_ADD(_a, _b)
Definition: pprz_algebra.h:120
#define ModeUpdate(_mode, _value)
Assignment, returning _old_value != _value Using GCC expression statements.
Definition: autopilot.h:82
#define RADIO_MODE
Definition: spektrum_arch.h:63
#define RADIO_THROTTLE
Definition: spektrum_arch.h:40
#define LED_PERIODIC()
Definition: led_hw.h:8
arch independent mcu ( Micro Controller Unit ) utilities
float h_ctl_pitch_setpoint
unsigned char uint8_t
Definition: types.h:14
float h_ctl_roll_setpoint
bool_t h_ctl_auto1_rate
bool_t too_far_from_home
Definition: common_nav.c:34
volatile uint32_t nb_sec
full seconds since startup
Definition: sys_time.h:55
#define FLOAT_OF_PPRZ(pprz, center, travel)
Definition: autopilot.h:69
bool_t launch
Definition: main_ap.c:122
State estimation, fusioning sensors.
#define LED_OFF(i)
Definition: led_hw.h:29
arch independent LED (Light Emitting Diodes) API
#define MIN_SPEED_FOR_TAKEOFF
Define minimal speed for takeoff in m/s.
Definition: main_ap.c:581
void v_ctl_init(void)
Definition: energy_ctrl.c:194
bool_t power_switch
Definition: main_ap.c:106
#define LOW_BATTERY_DELAY
Maximum time allowed for low battery level before going into kill mode.
Definition: main_ap.c:573
#define ImuScaleAccel(_imu)
Definition: imu_analog.h:49
struct Imu imu
global IMU state
Definition: imu_aspirin2.c:50
#define MAX_PPRZ
Definition: paparazzi.h:8
#define RADIO_ROLL
Definition: spektrum_arch.h:41
#define PPRZ_MODE_OF_PULSE(pprz)
Definition: autopilot.h:51
#define PPRZ_MODE_MANUAL
Definition: autopilot.h:44
tid_t navigation_tid
id for navigation_task() timer
Definition: main_ap.c:147
#define KILL_MODE_DISTANCE
Maximum distance from HOME waypoint before going into kill mode.
Definition: main_ap.c:577
void imu_init(void)
Definition: imu.c:32
#define LATERAL_MODE_COURSE
Definition: autopilot.h:63
#define VECT3_SDIV(_vo, _vi, _s)
Definition: pprz_algebra.h:169
static uint8_t mcu1_status
Definition: main_ap.c:114
void ahrs_aligner_init(void)
Definition: ahrs_aligner.c:40
#define TRIM_PPRZ(pprz)
Definition: paparazzi.h:11
pprz_t v_ctl_throttle_slewed
Definition: energy_ctrl.c:135
#define AhrsEvent(_ahrs_handler)
Definition: ins_xsens.h:49
bool_t kill_throttle
Definition: main_ap.c:120
#define THRESHOLD2
Definition: autopilot.h:41
void ahrs_aligner_run(void)
Definition: ahrs_aligner.c:58
void xbee_init(void)
Definition: xbee.c:47
#define NAVIGATION_FREQUENCY
Definition: main_ap.c:160
#define PPRZ_MODE_GPS_OUT_OF_ORDER
Definition: autopilot.h:48
void gps_init(void)
Definition: gps.c:37
void ahrs_propagate(void)
Propagation.
void attitude_loop(void)
Definition: main_ap.c:504
#define AHRS_RUNNING
Definition: ahrs.h:34
void estimator_init(void)
Definition: estimator.c:85
Informations relative to the other aircrafts.
void sensors_task(void)
Run at PERIODIC_FREQUENCY (60Hz if not defined)
Definition: main_ap.c:554
void handle_periodic_tasks_ap(void)
Definition: main_ap.c:246
void v_ctl_altitude_loop(void)
outer loop
Definition: energy_ctrl.c:264