Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
autopilot_generated.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2016 Gautier Hattenberger <gautier.hattenberger@enac.fr>
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, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
27 #define AUTOPILOT_CORE_AP_C
28 
30 #include "autopilot.h"
31 #include "autopilot_arming.h"
32 
34 #include "subsystems/commands.h"
35 #include "subsystems/actuators.h"
36 #include "subsystems/settings.h"
38 
39 #include "generated/settings.h"
40 
41 
43 {
44  // call generated init
45  autopilot_core_ap_init();
46  // copy generated mode to public mode (set at startup)
47  autopilot.mode = autopilot_mode_ap;
48 
49  // init arming
51 }
52 
53 
55 {
56 
57  autopilot_core_ap_periodic_task();
58 
59  // copy generated mode to public mode (may be changed on internal exceptions)
60  autopilot.mode = autopilot_mode_ap;
61 
62  /* Reset ground detection _after_ running flight plan
63  */
64  if (!autopilot_in_flight()) {
65  autopilot.ground_detected = false;
67  }
68 
69 }
70 
76 {
78 }
79 
80 
81 void autopilot_generated_set_mode(uint8_t new_autopilot_mode)
82 {
83  autopilot_core_ap_set_mode(new_autopilot_mode);
84  // copy generated mode to public mode
85  autopilot.mode = autopilot_mode_ap;
86 }
87 
88 
90 {
91  if (ap_ahrs_is_aligned() && motors_on
92 #ifdef AP_MODE_KILL
94 #endif
95  ) {
96  autopilot.motors_on = true;
97  } else {
98  autopilot.motors_on = false;
99  }
101 }
102 
103 
105 {
106 
107  // FIXME what to do here ?
108 
109  /* an arming sequence is used to start/stop motors.
110  * only allow arming if ahrs is aligned
111  */
112  if (ap_ahrs_is_aligned()) {
115  } else {
117  }
118 
119  /* if not in FAILSAFE or HOME mode, read RC and set commands accordingly */
120 // if (autopilot.mode != AP_MODE_FAILSAFE && autopilot.mode != AP_MODE_HOME) {
121 //
122 // /* if there are some commands that should always be set from RC, do it */
123 //#ifdef SetAutoCommandsFromRC
124 // SetAutoCommandsFromRC(commands, radio_control.values);
125 //#endif
126 //
127 // /* if not in NAV_MODE set commands from the rc */
128 //#ifdef SetCommandsFromRC
129 // if (autopilot.mode != AP_MODE_NAV) {
130 // SetCommandsFromRC(commands, radio_control.values);
131 // }
132 //#endif
133 //
134 // guidance_v_read_rc();
135 // guidance_h_read_rc(autopilot.in_flight);
136 // }
137 
138 }
radio_control.h
autopilot_generated_periodic
void autopilot_generated_periodic(void)
Definition: autopilot_generated.c:50
autopilot_arming.h
autopilot_generated_init
void autopilot_generated_init(void)
Definition: autopilot_generated.c:41
settings.h
autopilot_generated_on_rc_frame
void autopilot_generated_on_rc_frame(void)
Definition: autopilot_generated.c:104
pprz_autopilot::mode
uint8_t mode
current autopilot mode
Definition: autopilot.h:63
autopilot_generated_SetModeHandler
void autopilot_generated_SetModeHandler(float mode)
AP mode setting handler.
Definition: autopilot_generated.c:71
ap_ahrs_is_aligned
bool ap_ahrs_is_aligned(void)
Display descent speed in failsafe mode if needed.
Definition: autopilot_utils.c:41
AP_MODE_KILL
#define AP_MODE_KILL
Static autopilot modes.
Definition: autopilot_static.h:35
autopilot_in_flight
bool autopilot_in_flight(void)
get in_flight flag
Definition: autopilot.c:257
telemetry.h
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
uint8_t
unsigned char uint8_t
Definition: types.h:14
autopilot_generated_set_mode
void autopilot_generated_set_mode(uint8_t new_autopilot_mode)
Definition: autopilot_generated.c:77
autopilot_arming_init
static void autopilot_arming_init(void)
Definition: autopilot_arming_switch.h:48
pprz_autopilot::ground_detected
bool ground_detected
automatic detection of landing
Definition: autopilot.h:74
autopilot.h
autopilot_generated_set_motors_on
void autopilot_generated_set_motors_on(bool motors_on)
Definition: autopilot_generated.c:85
AP_ARMING_STATUS_AHRS_NOT_ALLIGNED
#define AP_ARMING_STATUS_AHRS_NOT_ALLIGNED
Definition: autopilot_arming_common.h:48
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 using the kill switch.
Definition: autopilot_arming_switch.h:79
autopilot_generated.h
autopilot_arming_set
static void autopilot_arming_set(bool motors_on)
Definition: autopilot_arming_switch.h:54
mode
static uint8_t mode
mode holds the current sonar mode mode = 0 used at high altitude, uses 16 wave patterns mode = 1 used...
Definition: sonar_bebop.c:69
commands.h
Hardware independent code for commands handling.
pprz_autopilot::kill_throttle
bool kill_throttle
allow autopilot to use throttle
Definition: autopilot.h:69
pprz_autopilot::arming_status
uint8_t arming_status
arming status
Definition: autopilot.h:67
pprz_autopilot::detect_ground_once
bool detect_ground_once
enable automatic detection of ground (one shot)
Definition: autopilot.h:75
actuators.h