Paparazzi UAS  v5.18.0_stable
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:
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 */
STATE_UNINIT
@ STATE_UNINIT
Definition: autopilot_arming_throttle.h:38
AP_ARMING_STATUS_NOT_MODE_MANUAL
#define AP_ARMING_STATUS_NOT_MODE_MANUAL
Definition: autopilot_arming_common.h:41
THROTTLE_STICK_DOWN
#define THROTTLE_STICK_DOWN()
Definition: autopilot_rc_helpers.h:40
AP_ARMING_STATUS_THROTTLE_DOWN
#define AP_ARMING_STATUS_THROTTLE_DOWN
Definition: autopilot_arming_common.h:40
AUTOPILOT_ARMING_DELAY
#define AUTOPILOT_ARMING_DELAY
Definition: autopilot_arming_throttle.h:35
autopilot_arming_set
static void autopilot_arming_set(bool motors_on)
Definition: autopilot_arming_throttle.h:57
AP_ARMING_STATUS_THROTTLE_NOT_DOWN
#define AP_ARMING_STATUS_THROTTLE_NOT_DOWN
Definition: autopilot_arming_common.h:43
AP_MODE_KILL
#define AP_MODE_KILL
Static autopilot modes.
Definition: autopilot_static.h:35
YAW_STICK_CENTERED
#define YAW_STICK_CENTERED()
Definition: autopilot_rc_helpers.h:45
autopilot_arming_check_valid
static bool autopilot_arming_check_valid(void)
Checks all arm requirements and returns true if OK and false otherwise.
Definition: autopilot_arming_throttle.h:73
STATE_ARMING
@ STATE_ARMING
Definition: autopilot_arming_throttle.h:41
autopilot_arming_init
static void autopilot_arming_init(void)
Definition: autopilot_arming_throttle.h:50
autopilot_arming_delay_counter
uint8_t autopilot_arming_delay_counter
Definition: autopilot_arming_throttle.h:47
pprz_autopilot::motors_on
bool motors_on
motor status
Definition: autopilot.h:68
autopilot
struct pprz_autopilot autopilot
Global autopilot structure.
Definition: autopilot.c:50
AP_ARMING_STATUS_YAW_NOT_CENTERED
#define AP_ARMING_STATUS_YAW_NOT_CENTERED
Definition: autopilot_arming_common.h:47
AP_ARMING_STATUS_KILLED
#define AP_ARMING_STATUS_KILLED
Definition: autopilot_arming_common.h:38
uint8_t
unsigned char uint8_t
Definition: types.h:14
autopilot_firmware.h
AP_ARMING_STATUS_PITCH_NOT_CENTERED
#define AP_ARMING_STATUS_PITCH_NOT_CENTERED
Definition: autopilot_arming_common.h:45
AP_ARMING_STATUS_DISARMING
#define AP_ARMING_STATUS_DISARMING
Definition: autopilot_arming_common.h:37
arming_throttle_state
arming_throttle_state
Definition: autopilot_arming_throttle.h:37
autopilot_arming_check_motors_on
static void autopilot_arming_check_motors_on(void)
State machine to check if motors should be turned ON or OFF.
Definition: autopilot_arming_throttle.h:98
AP_ARMING_STATUS_ARMED
#define AP_ARMING_STATUS_ARMED
Definition: autopilot_arming_common.h:36
autopilot_unarmed_in_auto
bool autopilot_unarmed_in_auto
Definition: autopilot_arming_throttle.h:48
STATE_WAITING
@ STATE_WAITING
Definition: autopilot_arming_throttle.h:39
PITCH_STICK_CENTERED
#define PITCH_STICK_CENTERED()
Definition: autopilot_rc_helpers.h:48
STATE_MOTORS_OFF_READY
@ STATE_MOTORS_OFF_READY
Definition: autopilot_arming_throttle.h:40
AP_ARMING_STATUS_ARMING
#define AP_ARMING_STATUS_ARMING
Definition: autopilot_arming_common.h:35
autopilot_arming_state
enum arming_throttle_state autopilot_arming_state
Definition: autopilot_arming_throttle.h:46
ROLL_STICK_CENTERED
#define ROLL_STICK_CENTERED()
Definition: autopilot_rc_helpers.h:51
AP_ARMING_STATUS_ROLL_NOT_CENTERED
#define AP_ARMING_STATUS_ROLL_NOT_CENTERED
Definition: autopilot_arming_common.h:46
autopilot_get_mode
uint8_t autopilot_get_mode(void)
get autopilot mode
Definition: autopilot.c:184
autopilot_arming_common.h
MODE_MANUAL
#define MODE_MANUAL
Default RC mode.
Definition: autopilot_static.h:60
STATE_MOTORS_ON
@ STATE_MOTORS_ON
Definition: autopilot_arming_throttle.h:42
pprz_autopilot::arming_status
uint8_t arming_status
arming status
Definition: autopilot.h:67
STATE_UNARMING
@ STATE_UNARMING
Definition: autopilot_arming_throttle.h:43