Paparazzi UAS  v5.15_devel-230-gc96ce27
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
autopilot_arming_throttle.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_THROTTLE_H
30 #define AUTOPILOT_ARMING_THROTTLE_H
31 
32 #include "autopilot_rc_helpers.h"
33 #include "autopilot_firmware.h"
34 
35 #define AUTOPILOT_ARMING_DELAY 10
36 
44 };
45 
49 
50 static inline void autopilot_arming_init(void)
51 {
55 }
56 
57 static inline void autopilot_arming_set(bool motors_on)
58 {
59  if (motors_on) {
61  } else {
64  }
65  }
66 }
67 
73 static inline bool autopilot_arming_check_valid(void)
74 {
75  if (!PITCH_STICK_CENTERED()) {
77  } else if (!ROLL_STICK_CENTERED()) {
79  } else if (!YAW_STICK_CENTERED()) {
83  } else if (THROTTLE_STICK_DOWN()) {
85  } else {
86  return true; // all checks valid
87  }
88  return false; // one of the checks failed
89 }
90 
98 static inline void autopilot_arming_check_motors_on(void)
99 {
100 
101  /* only allow switching motor if not in KILL mode */
102  if (autopilot_get_mode() != AP_MODE_KILL) {
103 
104  switch (autopilot_arming_state) {
105  case STATE_UNINIT:
106  autopilot.motors_on = false;
109  break;
110  case STATE_WAITING: // after startup wait until throttle is down before attempting to arm
111  autopilot.motors_on = false;
113  if (THROTTLE_STICK_DOWN()) {
115  } else {
117  }
118  break;
120  autopilot.motors_on = false;
124  }
125  break;
126  case STATE_ARMING:
127  autopilot.motors_on = false;
133  } else {
135  }
136  break;
137  case STATE_MOTORS_ON:
138  autopilot.motors_on = true;
141  if (THROTTLE_STICK_DOWN()) {
143  }
144  break;
145  case STATE_UNARMING:
146  autopilot.motors_on = true;
149  if (!THROTTLE_STICK_DOWN()) {
151  } else if (autopilot_arming_delay_counter == 0) {
153  if (autopilot_get_mode() != MODE_MANUAL) {
155  } else {
157  }
158  }
159  break;
160  default:
161  break;
162  }
163  } else {
165  }
166 
167 }
168 
169 #endif /* AUTOPILOT_ARMING_THROTTLE_H */
#define THROTTLE_STICK_DOWN()
#define AP_ARMING_STATUS_PITCH_NOT_CENTERED
#define AP_MODE_KILL
Static autopilot modes.
#define AP_ARMING_STATUS_DISARMING
enum arming_throttle_state autopilot_arming_state
#define AP_ARMING_STATUS_THROTTLE_DOWN
static void autopilot_arming_set(bool motors_on)
uint8_t autopilot_arming_delay_counter
static void autopilot_arming_check_motors_on(void)
State machine to check if motors should be turned ON or OFF.
#define AP_ARMING_STATUS_THROTTLE_NOT_DOWN
struct pprz_autopilot autopilot
Global autopilot structure.
Definition: autopilot.c:50
#define MODE_MANUAL
Default RC mode.
#define AUTOPILOT_ARMING_DELAY
Some helper functions to check RC sticks.
#define AP_ARMING_STATUS_ARMED
#define ROLL_STICK_CENTERED()
uint8_t arming_status
arming status
Definition: autopilot.h:67
#define YAW_STICK_CENTERED()
#define PITCH_STICK_CENTERED()
bool motors_on
motor status
Definition: autopilot.h:68
unsigned char uint8_t
Definition: types.h:14
#define AP_ARMING_STATUS_ARMING
#define AP_ARMING_STATUS_YAW_NOT_CENTERED
bool autopilot_unarmed_in_auto
#define AP_ARMING_STATUS_ROLL_NOT_CENTERED
static void autopilot_arming_init(void)
static bool autopilot_arming_check_valid(void)
Checks all arm requirements and returns true if OK and false otherwise.
#define AP_ARMING_STATUS_KILLED
#define AP_ARMING_STATUS_NOT_MODE_MANUAL
Rotorcraft specific autopilot interface and initialization.
uint8_t autopilot_get_mode(void)
get autopilot mode
Definition: autopilot.c:184