Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
autopilot_arming_switch.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 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 #ifndef AUTOPILOT_ARMING_SWITCH_H
30 #define AUTOPILOT_ARMING_SWITCH_H
31 
33 
34 #ifndef RADIO_KILL_SWITCH
35 #error "You need to have a RADIO_KILL_SWITCH configured to arm the motors with the switch!"
36 #endif
37 
43 };
44 
47 
48 static inline void autopilot_arming_init(void)
49 {
52 }
53 
54 static inline void autopilot_arming_set(bool motors_on)
55 {
56  if (motors_on) {
58  } else {
61  /* if turned off in an AUTO mode, remember it so it can be turned on again in AUTO */
65  } else {
67  }
68  }
69  }
70 }
71 
79 static inline void autopilot_arming_check_motors_on(void)
80 {
81  switch (autopilot_arming_state) {
82  case STATE_UNINIT:
84  if (kill_switch_is_on()) {
86  } else {
88  }
89  break;
90  case STATE_WAITING:
92  if (kill_switch_is_on()) {
94  }
95  break;
96  case STATE_STARTABLE:
98  /* don't allow to start if in KILL mode or kill switch is on */
100  break;
101  }
104  /* start motors if preflight is successful */
107  }
108  break;
109  case STATE_MOTORS_ON:
110  if (kill_switch_is_on()) {
111  /* kill motors, go to startable state */
114  /* if turned off in an AUTO mode, remember it so it can be turned on again in AUTO */
118  } else {
120  }
121  } else {
123  }
124  break;
125  default:
126  break;
127  }
128 
129 }
130 
131 #endif /* AUTOPILOT_ARMING_SWITCH_H */
uint8_t autopilot_get_mode(void)
get autopilot mode
Definition: autopilot.c:222
bool autopilot_arming_motors_on(bool motors_on)
turn motors on/off during arming, not done automatically prevents takeoff with preflight checks
Definition: autopilot.c:273
Arming procedure for rotorcraft, common definitions.
enum arming_state autopilot_arming_state
static void autopilot_arming_set(bool motors_on)
bool autopilot_unarmed_in_auto
static void autopilot_arming_check_motors_on(void)
State machine to check if motors should be turned ON or OFF using the kill switch.
@ STATE_STARTABLE
@ STATE_MOTORS_ON
static void autopilot_arming_init(void)
#define THROTTLE_STICK_DOWN()
static bool kill_switch_is_on(void)
static bool rc_attitude_sticks_centered(void)
Convenience macro for 3way switch.
#define MODE_MANUAL
Default RC mode.
#define AP_MODE_KILL
Static autopilot modes.
#define AP_MODE_FAILSAFE