Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
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 
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:
109  break;
110  case STATE_WAITING: // after startup wait until throttle is down before attempting to arm
113  if (THROTTLE_STICK_DOWN()) {
115  } else {
117  }
118  break;
124  }
125  break;
126  case STATE_ARMING:
132  if(autopilot_arming_motors_on(true)) {
134  } else {
136  }
137  } else {
139  }
140  break;
141  case STATE_MOTORS_ON:
145  if (THROTTLE_STICK_DOWN()) {
147  }
148  break;
149  case STATE_UNARMING:
153  if (!THROTTLE_STICK_DOWN()) {
155  } else if (autopilot_arming_delay_counter == 0) {
157  if (autopilot_get_mode() != MODE_MANUAL) {
159  } else {
161  }
162  }
163  break;
164  default:
165  break;
166  }
167  } else {
169  }
170 
171 }
172 
173 #endif /* AUTOPILOT_ARMING_THROTTLE_H */
uint8_t autopilot_get_mode(void)
get autopilot mode
Definition: autopilot.c:222
struct pprz_autopilot autopilot
Global autopilot structure.
Definition: autopilot.c:49
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
uint8_t arming_status
arming status
Definition: autopilot.h:67
Arming procedure for rotorcraft, common definitions.
#define AP_ARMING_STATUS_THROTTLE_NOT_DOWN
#define AP_ARMING_STATUS_THROTTLE_DOWN
#define AP_ARMING_STATUS_ARMED
#define AP_ARMING_STATUS_YAW_NOT_CENTERED
#define AP_ARMING_STATUS_KILLED
#define AP_ARMING_STATUS_DISARMING
#define AP_ARMING_STATUS_ARMING
#define AP_ARMING_STATUS_ROLL_NOT_CENTERED
#define AP_ARMING_STATUS_PITCH_NOT_CENTERED
#define AP_ARMING_STATUS_NOT_MODE_MANUAL
#define AUTOPILOT_ARMING_DELAY
static void autopilot_arming_set(bool motors_on)
bool autopilot_unarmed_in_auto
@ STATE_MOTORS_OFF_READY
uint8_t autopilot_arming_delay_counter
enum arming_throttle_state autopilot_arming_state
static void autopilot_arming_check_motors_on(void)
State machine to check if motors should be turned ON or OFF.
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 THROTTLE_STICK_DOWN()
#define ROLL_STICK_CENTERED()
#define PITCH_STICK_CENTERED()
#define YAW_STICK_CENTERED()
#define MODE_MANUAL
Default RC mode.
#define AP_MODE_KILL
Static autopilot modes.
Rover specific autopilot interface and initialization.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98