Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
autopilot_arming_yaw.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_YAW_H
30 #define AUTOPILOT_ARMING_YAW_H
31 
33 #include "autopilot_firmware.h"
34 #include "autopilot.h"
35 #include "mcu_periph/sys_time.h"
36 
41 #ifndef MOTOR_ARMING_DELAY
42 #define MOTOR_ARMING_DELAY 40
43 #endif
44 
45 // Allow re-arming from motors_on after RC kill within 10 seconds
46 #define MOTOR_RE_ARM_TIME 10.0
47 
60 };
61 
65 
66 
67 static inline void autopilot_arming_init(void)
68 {
71  motor_kill_time = 0;
72 }
73 
76 static inline void autopilot_arming_set(bool motors_on)
77 {
78  if (motors_on) {
83  } else {
85  }
86 }
87 
88 #define YAW_MUST_BE_CENTERED true
89 #define YAW_MUST_BE_PUSHED false
96 static inline bool autopilot_arming_check_valid(bool yaw_must_be_centered)
97 {
98  if (!THROTTLE_STICK_DOWN()) {
100  } else if (!PITCH_STICK_CENTERED()) {
102  } else if (!ROLL_STICK_CENTERED()) {
104  } else {
105  if (yaw_must_be_centered && !YAW_STICK_CENTERED()) {
107  } else if (!yaw_must_be_centered && YAW_STICK_CENTERED()) {
109  } else {
110  return true; // all checks valid
111  }
112  }
113  return false; // one of the checks failed
114 }
115 
122 static inline void autopilot_arming_check_motors_on(void)
123 {
124  /* only allow switching motor if not in KILL mode */
125  if (autopilot_get_mode() != AP_MODE_KILL) {
126 
128  case STATUS_INITIALISE_RC: // Wait until RC is initialised (it being centered is a good pointer to this)
131  }
132  break;
133  case STATUS_MOTORS_RC_KILLED: // Motors were killed by kill mode
134  // If the vehicle was killed accidentally, allow rapid re-arm
137  autopilot.motors_on = true; // Bypass preflight-checks and force the motors on
138  } else {
141  }
142  break;
143  case STATUS_MOTORS_AUTOMATICALLY_OFF: // Motors were disarmed externally
144  //(possibly due to crash)
145  //wait extra delay before enabling the normal arming state machine
150  }
151  break;
156  } else {
158  }
159  break;
160  case STATUS_MOTORS_OFF:
164  if (autopilot_arming_check_valid(YAW_MUST_BE_PUSHED)) { // stick pushed
166  }
167  break;
173  } else if (!autopilot_arming_check_valid(YAW_MUST_BE_PUSHED)) { // stick released too soon
175  } else {
177  }
178  break;
179  case STATUS_START_MOTORS:
182  autopilot_set_in_flight(false); // stop fc from starting control (integration and yaw) till arm process is complete
183  if (YAW_STICK_CENTERED()) { // wait until stick released
184  // Verify if motors are really on else go back to STATUS_MOTORS_OFF
187  else
189  }
190  break;
191  case STATUS_MOTORS_ON:
195  if (THROTTLE_STICK_DOWN() && YAW_STICK_PUSHED()) { // stick pushed
197  }
198  break;
202  if (autopilot_motors_on_counter == 0) {
204  } else if (!(THROTTLE_STICK_DOWN() && YAW_STICK_PUSHED())) { // stick released too soon
206  } else {
208  }
209  break;
210  case STATUS_STOP_MOTORS:
213  if (autopilot_arming_check_valid(YAW_MUST_BE_CENTERED)) { // wait till release disarm stick before allowing to re-arm
215  }
216  break;
217  default:
218  break;
219  }
220  } else {
222  if (kill_switch_is_on()) {
224  }
225  }
226 }
227 
228 #endif /* AUTOPILOT_ARMING_YAW_H */
uint8_t autopilot_get_mode(void)
get autopilot mode
Definition: autopilot.c:222
void autopilot_set_in_flight(bool in_flight)
set in_flight flag
Definition: autopilot.c:330
struct pprz_autopilot autopilot
Global autopilot structure.
Definition: autopilot.c:49
bool autopilot_get_motors_on(void)
get motors status
Definition: autopilot.c:295
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
Core autopilot interface common to all firmwares.
bool motors_on
motor status
Definition: autopilot.h:68
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_ARMED
#define AP_ARMING_STATUS_YAW_NOT_CENTERED
#define AP_ARMING_STATUS_WAITING
#define AP_ARMING_STATUS_KILLED
#define AP_ARMING_STATUS_DISARMING
#define AP_ARMING_STATUS_ROLL_NOT_CENTERED
#define AP_ARMING_STATUS_YAW_CENTERED
#define AP_ARMING_STATUS_PITCH_NOT_CENTERED
#define YAW_MUST_BE_CENTERED
#define MOTOR_ARMING_DELAY
Delay until motors are armed/disarmed.
float motor_kill_time
static void autopilot_arming_set(bool motors_on)
Update the status of the check_motors state machine.
#define YAW_MUST_BE_PUSHED
static bool autopilot_arming_check_valid(bool yaw_must_be_centered)
Checks all arm requirements and returns true if OK and false otherwise.
static void autopilot_arming_check_motors_on(void)
State machine to check if motors should be turned ON or OFF.
@ STATUS_START_MOTORS
@ STATUS_MOTORS_RC_KILLED
@ STATUS_MOTORS_OFF
@ STATUS_MOTORS_AUTOMATICALLY_OFF
@ STATUS_MOTORS_ON
@ STATUS_STOP_MOTORS
@ STATUS_MOTORS_AUTOMATICALLY_OFF_SAFETY_WAIT
@ STATUS_M_OFF_STICK_PUSHED
@ STATUS_M_ON_STICK_PUSHED
@ STATUS_INITIALISE_RC
#define MOTOR_RE_ARM_TIME
static void autopilot_arming_init(void)
enum arming_state autopilot_check_motor_status
uint32_t autopilot_motors_on_counter
#define THROTTLE_STICK_DOWN()
#define ROLL_STICK_CENTERED()
#define PITCH_STICK_CENTERED()
#define YAW_STICK_CENTERED()
static bool kill_switch_is_on(void)
#define YAW_STICK_PUSHED()
#define AP_MODE_KILL
Static autopilot modes.
Rover specific autopilot interface and initialization.
Architecture independent timing functions.
static float get_sys_time_float(void)
Get the time in seconds since startup.
Definition: sys_time.h:138
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
Definition: vl53l1_types.h:78