Paparazzi UAS  v5.15_devel-112-g521f3cf
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ctrl_module_innerloop_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 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 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 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 in_flight)
117 {
118  // your vertical controller goes here
119 }
struct ctrl_module_demo_struct ctrl_module_demo
#define RADIO_ROLL
Definition: intermcu_ap.h:41
float ctrl_module_demo_pr_d_gain
void guidance_h_module_run(bool in_flight)
uint8_t last_wp UNUSED
Definition: navigation.c:92
void ctrl_module_run(bool in_flight)
void guidance_h_module_init(void)
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
Definition: radio_control.h:69
void guidance_h_module_read_rc(void)
int32_t r
in rad/s with INT32_RATE_FRAC
static struct Int32Rates * stateGetBodyRates_i(void)
Get vehicle body angular rate (int).
Definition: state.h:1191
void guidance_h_module_enter(void)
float ctrl_module_demo_y_ff_gain
struct RadioControl radio_control
Definition: radio_control.c:30
void guidance_v_module_run(UNUSED bool in_flight)
#define RADIO_THROTTLE
Definition: intermcu_ap.h:40
API to get/set the generic vehicle states.
float ctrl_module_demo_pr_ff_gain
#define RADIO_PITCH
Definition: intermcu_ap.h:42
void guidance_v_module_init(void)
General stabilization interface for rotorcrafts.
void guidance_v_module_enter(void)
#define RADIO_YAW
Definition: intermcu_ap.h:43
int32_t stabilization_cmd[COMMANDS_NB]
Stabilization commands.
Definition: stabilization.c:32
example empty controller
int32_t p
in rad/s with INT32_RATE_FRAC
float ctrl_module_demo_y_d_gain
void ctrl_module_init(void)
int32_t q
in rad/s with INT32_RATE_FRAC