Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
autopilot_utils.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, write to
18 * the Free Software Foundation, 59 Temple Place - Suite 330,
19 * Boston, MA 02111-1307, USA.
20 */
21
30#include "autopilot.h"
32#include "state.h"
34
37
38#if (defined MODE_MANUAL) && (defined MODE_AUTO1)
39
40#if defined RADIO_MODE_2x3
41
42#define THRESHOLD_1d3_PPRZ (MAX_PPRZ / 3)
43#define THRESHOLD_2d3_PPRZ ((MAX_PPRZ / 3) * 2)
57{
60 val = MAX_PPRZ + val;
61 }
62 if (val < THRESHOLD_1d3_PPRZ) {
63 return MODE_MANUAL;
64 } else if (val < THRESHOLD_2d3_PPRZ) {
65 return MODE_AUTO1;
66 } else {
68 }
69}
70
71#else
72
73#define THRESHOLD_1_PPRZ (MIN_PPRZ / 2)
74#define THRESHOLD_2_PPRZ (MAX_PPRZ / 2)
75
78{
82 return MODE_AUTO1;
83 } else {
84 return MODE_MANUAL;
85 }
86}
87
88#endif
89
98#if defined RADIO_AUTO_MODE || defined(__DOXYGEN__)
100{
102 /* RADIO_MODE in MANUAL position */
103 return MODE_MANUAL;
104 } else {
105 /* RADIO_MODE not in MANUAL position.
106 * Select AUTO mode bassed on RADIO_AUTO_MODE channel
107 */
110 } else {
111 return MODE_AUTO1;
112 }
113 }
114}
115#endif
116
117#endif // MODE_MANUAL && MODE_AUTO1
118
123void WEAK set_rotorcraft_commands(pprz_t *cmd_out, int32_t *cmd_in, bool in_flight __attribute__((unused)), bool motors_on __attribute__((unused)))
124{
125#if !ROTORCRAFT_IS_HELI
126#if !ROTORCRAFT_COMMANDS_YAW_ALWAYS_ENABLED && defined(COMMAND_YAW)
127 if (!in_flight) {
128 cmd_in[COMMAND_YAW] = 0;
129 }
130#endif
131 if (!motors_on) {
133 }
134#endif
135#ifdef COMMAND_ROLL
137#endif
138#ifdef COMMAND_PITCH
140#endif
141#ifdef COMMAND_YAW
143#endif
145}
146
Core autopilot interface common to all firmwares.
uint16_t foo
Definition main_demo5.c:58
PRINT_CONFIG_VAR(ONELOOP_ANDI_FILT_CUTOFF)
int16_t pprz_t
Definition paparazzi.h:6
#define MAX_PPRZ
Definition paparazzi.h:8
struct RadioControl radio_control
Generic interface for radio control modules.
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
uint8_t autopilot_mode_auto2
Some helper functions to check RC sticks.
#define MODE_AUTO1
#define MODE_MANUAL
Default RC mode.
void WEAK set_rotorcraft_commands(pprz_t *cmd_out, int32_t *cmd_in, bool in_flight, bool motors_on)
Display descent speed in failsafe mode if needed.
Utility functions and includes for autopilots.
uint8_t ap_mode_of_3way_switch(void)
get autopilot mode as set by RADIO_MODE 3-way switch
#define FAILSAFE_DESCENT_SPEED
Set descent speed in failsafe mode.
#define THRESHOLD_2_PPRZ
#define THRESHOLD_1_PPRZ
Display descent speed in failsafe mode if needed.
API to get/set the generic vehicle states.
uint16_t val[TCOUPLE_NB]
int int32_t
Typedef defining 32 bit int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.