Paparazzi UAS  v5.8.2_stable-0-g6260b7c
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
autopilot_rc_helpers.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2012 The Paparazzi Team
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 
28 #ifndef AUTOPILOT_RC_HELPERS_H
29 #define AUTOPILOT_RC_HELPERS_H
30 
31 #include "generated/airframe.h"
33 
34 #define AUTOPILOT_THROTTLE_THRESHOLD (MAX_PPRZ / 20)
35 #define AUTOPILOT_YAW_THRESHOLD (MAX_PPRZ * 19 / 20)
36 #ifndef AUTOPILOT_STICK_CENTER_THRESHOLD
37 #define AUTOPILOT_STICK_CENTER_THRESHOLD (MAX_PPRZ * 1 / 20)
38 #endif
39 
40 #define THROTTLE_STICK_DOWN() \
41  (radio_control.values[RADIO_THROTTLE] < AUTOPILOT_THROTTLE_THRESHOLD)
42 #define YAW_STICK_PUSHED() \
43  (radio_control.values[RADIO_YAW] > AUTOPILOT_YAW_THRESHOLD || \
44  radio_control.values[RADIO_YAW] < -AUTOPILOT_YAW_THRESHOLD)
45 #define YAW_STICK_CENTERED() \
46  (radio_control.values[RADIO_YAW] < AUTOPILOT_STICK_CENTER_THRESHOLD && \
47  radio_control.values[RADIO_YAW] > -AUTOPILOT_STICK_CENTER_THRESHOLD)
48 #define PITCH_STICK_CENTERED() \
49  (radio_control.values[RADIO_PITCH] < AUTOPILOT_STICK_CENTER_THRESHOLD && \
50  radio_control.values[RADIO_PITCH] > -AUTOPILOT_STICK_CENTER_THRESHOLD)
51 #define ROLL_STICK_CENTERED() \
52  (radio_control.values[RADIO_ROLL] < AUTOPILOT_STICK_CENTER_THRESHOLD && \
53  radio_control.values[RADIO_ROLL] > -AUTOPILOT_STICK_CENTER_THRESHOLD)
54 
55 static inline bool_t rc_attitude_sticks_centered(void)
56 {
58 }
59 
60 #ifdef RADIO_KILL_SWITCH
61 static inline bool_t kill_switch_is_on(void)
62 {
64  return TRUE;
65  } else {
66  return FALSE;
67  }
68 }
69 #else
70 static inline bool_t kill_switch_is_on(void)
71 {
72  return FALSE;
73 }
74 #endif
75 
76 static inline uint8_t percent_from_rc(int channel)
77 {
78  int per = (MAX_PPRZ + (int32_t)radio_control.values[channel]) * 50 / MAX_PPRZ;
79  if (per < 0) {
80  per = 0;
81  } else if (per > 100) {
82  per = 100;
83  }
84  return per;
85 }
86 
87 
88 #endif /* AUTOPILOT_RC_HELPERS_H */
#define ROLL_STICK_CENTERED()
static bool_t kill_switch_is_on(void)
#define RADIO_KILL_SWITCH
static bool_t rc_attitude_sticks_centered(void)
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
Definition: radio_control.h:58
#define PITCH_STICK_CENTERED()
#define FALSE
Definition: std.h:5
#define TRUE
Definition: std.h:4
struct RadioControl radio_control
Definition: radio_control.c:30
static uint8_t percent_from_rc(int channel)
signed long int32_t
Definition: types.h:19
unsigned char uint8_t
Definition: types.h:14
#define YAW_STICK_CENTERED()
#define MAX_PPRZ
Definition: paparazzi.h:8
static uint8_t channel
Definition: ADS8344.c:80