Paparazzi UAS  v5.2.2_stable-0-gd6b9f29
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures 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) {
57 }
58 
59 #ifdef RADIO_KILL_SWITCH
60 static inline bool_t kill_switch_is_on(void) {
62  return TRUE;
63  else
64  return FALSE;
65 }
66 #else
67 static inline bool_t kill_switch_is_on(void) {
68  return FALSE;
69 }
70 #endif
71 
72 static inline uint8_t percent_from_rc(int channel)
73 {
74  int per = (MAX_PPRZ + (int32_t)radio_control.values[channel]) * 50 / MAX_PPRZ;
75  if (per < 0)
76  per = 0;
77  else if (per > 100)
78  per = 100;
79  return per;
80 }
81 
82 
83 #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)
#define PITCH_STICK_CENTERED()
#define FALSE
Definition: imu_chimu.h:141
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
Definition: radio_control.h:55
struct RadioControl radio_control
Definition: radio_control.c:25
static uint8_t percent_from_rc(int channel)
signed long int32_t
Definition: types.h:19
#define TRUE
Definition: imu_chimu.h:144
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