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
ctrl_module_demo.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2015
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, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
28 #include "state.h"
31 
33  int rc_x;
34  int rc_y;
35  int rc_z;
36  int rc_t;
37 
39 
40 float ctrl_module_demo_pr_ff_gain = 0.2f; // Pitch/Roll
42 float ctrl_module_demo_y_ff_gain = 0.4f; // Yaw
44 
45 void ctrl_module_init(void);
46 void ctrl_module_run(bool_t in_flight);
47 
48 void ctrl_module_init(void)
49 {
54 }
55 
56 // simple rate control without reference model nor attitude
57 void ctrl_module_run(bool_t in_flight)
58 {
59  if (!in_flight) {
60  // Reset integrators
61  stabilization_cmd[COMMAND_ROLL] = 0;
62  stabilization_cmd[COMMAND_PITCH] = 0;
63  stabilization_cmd[COMMAND_YAW] = 0;
64  stabilization_cmd[COMMAND_THRUST] = 0;
65  } else {
72  stabilization_cmd[COMMAND_THRUST] = ctrl_module_demo.rc_t;
73  }
74 }
75 
76 
78 // Call our controller
79 // Implement own Horizontal loops
81 {
83 }
84 
86 {
88 }
89 
91 {
92  // -MAX_PPRZ to MAX_PPRZ
97 }
98 
99 void guidance_h_module_run(bool_t in_flight)
100 {
101  // Call full inner-/outerloop / horizontal-/vertical controller:
102  ctrl_module_run(in_flight);
103 }
104 
106 {
107  // initialization of your custom vertical controller goes here
108 }
109 
110 // Implement own Vertical loops
112 {
113  // your code that should be executed when entering this vertical mode goes here
114 }
115 
116 void guidance_v_module_run(UNUSED bool_t in_flight)
117 {
118  // your vertical controller goes here
119 }
float ctrl_module_demo_y_d_gain
void guidance_h_module_run(bool_t in_flight)
#define RADIO_ROLL
Definition: spektrum_arch.h:43
#define RADIO_YAW
Definition: spektrum_arch.h:45
float ctrl_module_demo_pr_d_gain
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
Definition: radio_control.h:58
float ctrl_module_demo_pr_ff_gain
int32_t r
in rad/s with INT32_RATE_FRAC
void guidance_h_module_enter(void)
static struct Int32Rates * stateGetBodyRates_i(void)
Get vehicle body angular rate (int).
Definition: state.h:1162
void guidance_v_module_init(void)
void guidance_h_module_read_rc(void)
#define RADIO_PITCH
Definition: spektrum_arch.h:44
void guidance_v_module_run(UNUSED bool_t in_flight)
struct RadioControl radio_control
Definition: radio_control.c:30
void ctrl_module_init(void)
#define RADIO_THROTTLE
Definition: spektrum_arch.h:42
example empty controller
void guidance_h_module_init(void)
void guidance_v_module_enter(void)
API to get/set the generic vehicle states.
General stabilization interface for rotorcrafts.
struct ctrl_module_demo_struct ctrl_module_demo
int32_t stabilization_cmd[COMMANDS_NB]
Stabilization commands.
Definition: stabilization.c:28
int32_t p
in rad/s with INT32_RATE_FRAC
int32_t q
in rad/s with INT32_RATE_FRAC
void ctrl_module_run(bool_t in_flight)
float ctrl_module_demo_y_ff_gain