Paparazzi UAS
v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
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 "generated/airframe.h"
34
37
#define AP_MODE_OF_PULSE(pprz) \
38
(pprz > THRESHOLD2 ? AP_MODE_AUTO2 : \
39
(pprz > THRESHOLD1 ? AP_MODE_AUTO1 : AP_MODE_MANUAL))
40
43
#define STICK_PUSHED(pprz) (pprz < THRESHOLD1 || pprz > THRESHOLD2)
44
47
#define FLOAT_OF_PPRZ(pprz, center, travel) ((float)pprz / (float)MAX_PPRZ * travel + center)
48
51
#define THROTTLE_THRESHOLD_TAKEOFF (pprz_t)(MAX_PPRZ * 0.9)
52
55
#define THRESHOLD_MANUAL_PPRZ (MIN_PPRZ / 2)
56
#define THRESHOLD1 THRESHOLD_MANUAL_PPRZ
57
#define THRESHOLD2 (MAX_PPRZ/2)
58
62
// COMMAND_ROLL
63
#define AP_COMMAND_SET_ROLL(_roll) { command_set(COMMAND_ROLL, _roll); }
64
65
// COMMAND_PITCH
66
#define AP_COMMAND_SET_PITCH(_pitch) { command_set(COMMAND_PITCH, _pitch); }
67
68
// COMMAND_YAW
69
#if H_CTL_YAW_LOOP && defined COMMAND_YAW
70
#define AP_COMMAND_SET_YAW(_yaw) { command_set(COMMAND_YAW, _yaw); }
71
#else
72
#define AP_COMMAND_SET_YAW(_yaw) {}
73
#endif
74
75
// COMMAND_THROTTLE
76
#define AP_COMMAND_SET_THROTTLE(_throttle) { \
77
command_set(COMMAND_THROTTLE, _throttle); \
78
autopilot.throttle = _throttle; \
79
}
80
81
// COMMAND_CL
82
#if H_CTL_CL_LOOP && defined COMMAND_CL
83
#define AP_COMMAND_SET_CL(_cl) { command_set(COMMAND_CL, _cl); }
84
#else
85
#define AP_COMMAND_SET_CL(_cl) {}
86
#endif
87
88
// ROLL setpoint from RADIO
89
#define AP_SETPOINT_ROLL(_roll, _max) { \
90
_roll = FLOAT_OF_PPRZ(radio_control_get(RADIO_ROLL), 0., _max); \
91
}
92
93
// PITCH setpoint from RADIO
94
#define AP_SETPOINT_PITCH(_pitch, _max) { \
95
_pitch = FLOAT_OF_PPRZ(radio_control_get(RADIO_PITCH), 0., _max); \
96
}
97
98
// PITCH setpoint from RADIO
99
#if H_CTL_YAW_LOOP && defined RADIO_YAW
100
#define AP_SETPOINT_YAW_RATE(_yaw, _max) { \
101
_yaw = FLOAT_OF_PPRZ(radio_control_get(RADIO_YAW), 0., _max); \
102
}
103
#else
104
#define AP_SETPOINT_YAW_RATE(_yaw, _max) {}
105
#endif
106
107
// THROTTLE setpoint from RADIO
108
#define AP_SETPOINT_THROTTLE(_throttle) { \
109
_throttle = radio_control_get(RADIO_THROTTLE); \
110
}
111
112
113
#endif
// AUTOPILOT_UTILS_H
114
std.h
sw
airborne
firmwares
fixedwing
autopilot_utils.h
Generated on Fri Nov 8 2024 14:10:45 for Paparazzi UAS by
1.9.1