Paparazzi UAS  v5.18.0_stable
Paparazzi is a free software Unmanned Aircraft System.
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 }
radio_control.h
ctrl_module_demo_struct::rc_z
int rc_z
Definition: ctrl_module_innerloop_demo.c:35
ctrl_module_demo_y_ff_gain
float ctrl_module_demo_y_ff_gain
Definition: ctrl_module_innerloop_demo.c:42
RADIO_ROLL
#define RADIO_ROLL
Definition: intermcu_ap.h:41
guidance_v_module_init
void guidance_v_module_init(void)
Definition: ctrl_module_innerloop_demo.c:105
guidance_h_module_run
void guidance_h_module_run(bool in_flight)
Definition: ctrl_module_innerloop_demo.c:99
guidance_v_module_enter
void guidance_v_module_enter(void)
Definition: ctrl_module_innerloop_demo.c:111
Int32Rates::q
int32_t q
in rad/s with INT32_RATE_FRAC
Definition: pprz_algebra_int.h:181
guidance_h_module_read_rc
void guidance_h_module_read_rc(void)
Definition: ctrl_module_innerloop_demo.c:90
ctrl_module_run
void ctrl_module_run(bool in_flight)
Definition: ctrl_module_innerloop_demo.c:57
UNUSED
uint8_t last_wp UNUSED
Definition: navigation.c:96
stateGetBodyRates_i
static struct Int32Rates * stateGetBodyRates_i(void)
Get vehicle body angular rate (int).
Definition: state.h:1191
ctrl_module_demo_struct
Definition: ctrl_module_innerloop_demo.c:32
ctrl_module_demo_struct::rc_y
int rc_y
Definition: ctrl_module_innerloop_demo.c:34
Int32Rates::p
int32_t p
in rad/s with INT32_RATE_FRAC
Definition: pprz_algebra_int.h:180
ctrl_module_init
void ctrl_module_init(void)
Definition: ctrl_module_innerloop_demo.c:48
ctrl_module_demo_pr_d_gain
float ctrl_module_demo_pr_d_gain
Definition: ctrl_module_innerloop_demo.c:41
ctrl_module_demo_struct::rc_x
int rc_x
Definition: ctrl_module_innerloop_demo.c:33
RADIO_THROTTLE
#define RADIO_THROTTLE
Definition: intermcu_ap.h:40
ctrl_module_innerloop_demo.h
example empty controller
guidance_v_module_run
void guidance_v_module_run(UNUSED bool in_flight)
Definition: ctrl_module_innerloop_demo.c:116
ctrl_module_demo_pr_ff_gain
float ctrl_module_demo_pr_ff_gain
Definition: ctrl_module_innerloop_demo.c:40
stabilization_cmd
int32_t stabilization_cmd[COMMANDS_NB]
Stabilization commands.
Definition: stabilization.c:32
RADIO_YAW
#define RADIO_YAW
Definition: intermcu_ap.h:43
guidance_h_module_enter
void guidance_h_module_enter(void)
Definition: ctrl_module_innerloop_demo.c:85
ctrl_module_demo_y_d_gain
float ctrl_module_demo_y_d_gain
Definition: ctrl_module_innerloop_demo.c:43
guidance_h_module_init
void guidance_h_module_init(void)
Definition: ctrl_module_innerloop_demo.c:80
stabilization.h
state.h
RADIO_PITCH
#define RADIO_PITCH
Definition: intermcu_ap.h:42
Int32Rates::r
int32_t r
in rad/s with INT32_RATE_FRAC
Definition: pprz_algebra_int.h:182
ctrl_module_demo_struct::rc_t
int rc_t
Definition: ctrl_module_innerloop_demo.c:36
ctrl_module_demo
struct ctrl_module_demo_struct ctrl_module_demo
radio_control
struct RadioControl radio_control
Definition: radio_control.c:30
RadioControl::values
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
Definition: radio_control.h:69