Paparazzi UAS
v5.14.0_stable-0-g3f680d1
Paparazzi is a free software Unmanned Aircraft System.
Main Page
Related Pages
Modules
Data Structures
Files
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Macros
Modules
Pages
autopilot_utils.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2017 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
29
#ifndef AUTOPILOT_UTILS_H
30
#define AUTOPILOT_UTILS_H
31
32
#include "
std.h
"
33
#include "
inter_mcu.h
"
34
#include "generated/airframe.h"
35
38
#define AP_MODE_OF_PULSE(pprz) \
39
(pprz > THRESHOLD2 ? AP_MODE_AUTO2 : \
40
(pprz > THRESHOLD1 ? AP_MODE_AUTO1 : AP_MODE_MANUAL))
41
44
#define STICK_PUSHED(pprz) (pprz < THRESHOLD1 || pprz > THRESHOLD2)
45
48
#define FLOAT_OF_PPRZ(pprz, center, travel) ((float)pprz / (float)MAX_PPRZ * travel + center)
49
52
#define THROTTLE_THRESHOLD_TAKEOFF (pprz_t)(MAX_PPRZ * 0.9)
53
56
#define THRESHOLD_MANUAL_PPRZ (MIN_PPRZ / 2)
57
#define THRESHOLD1 THRESHOLD_MANUAL_PPRZ
58
#define THRESHOLD2 (MAX_PPRZ/2)
59
63
// COMMAND_ROLL
64
#define AP_COMMAND_SET_ROLL(_roll) { ap_state->commands[COMMAND_ROLL] = _roll; }
65
66
// COMMAND_PITCH
67
#define AP_COMMAND_SET_PITCH(_pitch) { ap_state->commands[COMMAND_PITCH] = _pitch; }
68
69
// COMMAND_YAW
70
#if H_CTL_YAW_LOOP && defined COMMAND_YAW
71
#define AP_COMMAND_SET_YAW(_yaw) { ap_state->commands[COMMAND_YAW] = _yaw; }
72
#else
73
#define AP_COMMAND_SET_YAW(_yaw) {}
74
#endif
75
76
// COMMAND_THROTTLE
77
#define AP_COMMAND_SET_THROTTLE(_throttle) { ap_state->commands[COMMAND_THROTTLE] = _throttle; }
78
79
// COMMAND_CL
80
#if H_CTL_CL_LOOP && defined COMMAND_CL
81
#define AP_COMMAND_SET_CL(_cl) { ap_state->commands[COMMAND_CL] = cl; }
82
#else
83
#define AP_COMMAND_SET_CL(_cl) {}
84
#endif
85
86
// ROLL setpoint from RADIO
87
#define AP_SETPOINT_ROLL(_roll, _max) { \
88
_roll = FLOAT_OF_PPRZ(fbw_state->channels[RADIO_ROLL], 0., _max); \
89
}
90
91
// PITCH setpoint from RADIO
92
#define AP_SETPOINT_PITCH(_pitch, _max) { \
93
_pitch = FLOAT_OF_PPRZ(fbw_state->channels[RADIO_PITCH], 0., _max); \
94
}
95
96
// PITCH setpoint from RADIO
97
#if H_CTL_YAW_LOOP && defined RADIO_YAW
98
#define AP_SETPOINT_YAW_RATE(_yaw, _max) { \
99
_yaw = FLOAT_OF_PPRZ(fbw_state->channels[RADIO_YAW], 0., _max); \
100
}
101
#else
102
#define AP_SETPOINT_YAW_RATE(_yaw, _max) {}
103
#endif
104
105
// THROTTLE setpoint from RADIO
106
#define AP_SETPOINT_THROTTLE(_throttle) { \
107
_throttle = fbw_state->channels[RADIO_THROTTLE]; \
108
}
109
110
111
#endif // AUTOPILOT_UTILS_H
112
inter_mcu.h
Communication between fbw and ap processes.
std.h
sw
airborne
firmwares
fixedwing
autopilot_utils.h
Generated on Sat Feb 9 2019 07:05:38 for Paparazzi UAS by
1.8.8