Paparazzi UAS  v4.0.4_stable-3-gf39211a
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
stabilization_attitude_rc_setpoint.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 Felix Ruess <felix.ruess@gmail.com>
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 
26 #ifndef STABILISATION_ATTITUDE_RC_SETPOINT_H
27 #define STABILISATION_ATTITUDE_RC_SETPOINT_H
28 
29 #include "std.h"
30 #include "generated/airframe.h"
31 #include "math/pprz_algebra_int.h"
33 
35 #include "subsystems/ahrs.h"
36 
37 #ifdef STABILISATION_ATTITUDE_TYPE_INT
38 #define SP_MAX_PHI (int32_t)ANGLE_BFP_OF_REAL(STABILIZATION_ATTITUDE_SP_MAX_PHI)
39 #define SP_MAX_THETA (int32_t)ANGLE_BFP_OF_REAL(STABILIZATION_ATTITUDE_SP_MAX_THETA)
40 #define SP_MAX_R (int32_t)ANGLE_BFP_OF_REAL(STABILIZATION_ATTITUDE_SP_MAX_R)
41 #endif // STABILISATION_ATTITUDE_TYPE_INT
42 
43 #ifdef STABILISATION_ATTITUDE_TYPE_FLOAT
44 #define SP_MAX_PHI STABILIZATION_ATTITUDE_SP_MAX_PHI
45 #define SP_MAX_THETA STABILIZATION_ATTITUDE_SP_MAX_THETA
46 #define SP_MAX_R STABILIZATION_ATTITUDE_SP_MAX_R
47 #endif // STABILISATION_ATTITUDE_TYPE_FLOAT
48 
49 #define RC_UPDATE_FREQ 40
50 
51 #ifdef STABILIZATION_ATTITUDE_DEADBAND_A
52 #define ROLL_DEADBAND_EXCEEDED() \
53  (radio_control.values[RADIO_ROLL] > STABILIZATION_ATTITUDE_DEADBAND_A || \
54  radio_control.values[RADIO_ROLL] < -STABILIZATION_ATTITUDE_DEADBAND_A)
55 #else
56 #define ROLL_DEADBAND_EXCEEDED() (TRUE)
57 #endif /* STABILIZATION_ATTITUDE_DEADBAND_A */
58 
59 #ifdef STABILIZATION_ATTITUDE_DEADBAND_E
60 #define PITCH_DEADBAND_EXCEEDED() \
61  (radio_control.values[RADIO_PITCH] > STABILIZATION_ATTITUDE_DEADBAND_E || \
62  radio_control.values[RADIO_PITCH] < -STABILIZATION_ATTITUDE_DEADBAND_E)
63 #else
64 #define PITCH_DEADBAND_EXCEEDED() (TRUE)
65 #endif /* STABILIZATION_ATTITUDE_DEADBAND_E */
66 
67 #define YAW_DEADBAND_EXCEEDED() \
68  (radio_control.values[RADIO_YAW] > STABILIZATION_ATTITUDE_DEADBAND_R || \
69  radio_control.values[RADIO_YAW] < -STABILIZATION_ATTITUDE_DEADBAND_R)
70 
71 static inline void stabilization_attitude_read_rc_setpoint_eulers(struct Int32Eulers *sp, bool_t in_flight) {
72 
73  sp->phi = ((int32_t) radio_control.values[RADIO_ROLL] * SP_MAX_PHI / MAX_PPRZ);
75 
76  if (in_flight) {
77  if (YAW_DEADBAND_EXCEEDED()) {
80  }
81  }
82  else { /* if not flying, use current yaw as setpoint */
84  }
85 
86 }
87 
88 
89 #endif /* STABILISATION_ATTITUDE_RC_SETPOINT_H */
int32_t phi
in rad with INT32_ANGLE_FRAC
Attitude and Heading Reference System interface.
struct Ahrs ahrs
global AHRS state (fixed point version)
Definition: ahrs.c:24
int32_t theta
in rad with INT32_ANGLE_FRAC
#define YAW_DEADBAND_EXCEEDED()
#define RADIO_PITCH
Definition: spektrum_arch.h:42
Paparazzi floating point algebra.
static void stabilization_attitude_read_rc_setpoint_eulers(struct Int32Eulers *sp, bool_t in_flight)
struct RadioControl radio_control
Definition: radio_control.c:27
#define INT32_ANGLE_NORMALIZE(_a)
#define RADIO_YAW
Definition: spektrum_arch.h:43
signed long int32_t
Definition: types.h:19
struct Int32Eulers ltp_to_body_euler
Rotation from LocalTangentPlane to body frame as Euler angles.
Definition: ahrs.h:50
int32_t psi
in rad with INT32_ANGLE_FRAC
#define MAX_PPRZ
Definition: paparazzi.h:8
#define RADIO_ROLL
Definition: spektrum_arch.h:41
Paparazzi fixed point algebra.
euler angles