Paparazzi UAS  v5.12_stable-4-g9b43e9b
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
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 
32 #include "autopilot_rc_helpers.h"
33 
38 #ifndef MOTOR_ARMING_DELAY
39 #define MOTOR_ARMING_DELAY 40
40 #endif
41 
53 };
54 
57 
58 
59 static inline void autopilot_arming_init(void)
60 {
63 }
64 
65 
68 static inline void autopilot_arming_set(bool motors_on)
69 {
70  if (motors_on) {
72  } else {
74  }
75 }
76 
83 static inline void autopilot_arming_check_motors_on(void)
84 {
85  /* only allow switching motor if not in KILL mode */
87 
89  case STATUS_INITIALISE_RC: // Wait until RC is initialised (it being centered is a good pointer to this)
92  }
93  break;
94  case STATUS_MOTORS_AUTOMATICALLY_OFF: // Motors were disarmed externally
95  //(possibly due to crash)
96  //wait extra delay before enabling the normal arming state machine
97  autopilot.motors_on = false;
99  if (THROTTLE_STICK_DOWN() && YAW_STICK_CENTERED()) { // stick released
101  }
102  break;
107  }
108  break;
109  case STATUS_MOTORS_OFF:
110  autopilot.motors_on = false;
112  if (THROTTLE_STICK_DOWN() && YAW_STICK_PUSHED()) { // stick pushed
114  }
115  break;
117  autopilot.motors_on = false;
121  } else if (!(THROTTLE_STICK_DOWN() && YAW_STICK_PUSHED())) { // stick released too soon
123  }
124  break;
125  case STATUS_START_MOTORS:
126  autopilot.motors_on = true;
128  if (!(THROTTLE_STICK_DOWN() && YAW_STICK_PUSHED())) { // wait until stick released
130  }
131  break;
132  case STATUS_MOTORS_ON:
133  autopilot.motors_on = true;
135  if (THROTTLE_STICK_DOWN() && YAW_STICK_PUSHED()) { // stick pushed
137  }
138  break;
140  autopilot.motors_on = true;
142  if (autopilot_motors_on_counter == 0) {
144  } else if (!(THROTTLE_STICK_DOWN() && YAW_STICK_PUSHED())) { // stick released too soon
146  }
147  break;
148  case STATUS_STOP_MOTORS:
149  autopilot.motors_on = false;
151  if (!(THROTTLE_STICK_DOWN() && YAW_STICK_PUSHED())) { // wait until stick released
153  }
154  break;
155  default:
156  break;
157  }
158  }
159 }
160 
161 #endif /* AUTOPILOT_ARMING_YAW_H */
#define THROTTLE_STICK_DOWN()
uint32_t autopilot_motors_on_counter
static void autopilot_arming_set(bool motors_on)
Update the status of the check_motors state machine.
#define AP_MODE_KILL
Static autopilot modes.
enum arming_state autopilot_check_motor_status
#define MOTOR_ARMING_DELAY
Delay until motors are armed/disarmed.
struct pprz_autopilot autopilot
Global autopilot structure.
Definition: autopilot.c:50
Some helper functions to check RC sticks.
unsigned long uint32_t
Definition: types.h:18
#define ROLL_STICK_CENTERED()
static void autopilot_arming_check_motors_on(void)
State machine to check if motors should be turned ON or OFF.
#define YAW_STICK_CENTERED()
#define PITCH_STICK_CENTERED()
bool motors_on
motor status
Definition: autopilot.h:62
#define YAW_STICK_PUSHED()
static void autopilot_arming_init(void)
uint8_t autopilot_get_mode(void)
get autopilot mode
Definition: autopilot.c:179