Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
eff_scheduling_generic.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2017 Ewoud Smeur <ewoud_smeur@msn.com>
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 "generated/airframe.h"
29 #include "state.h"
31 
32 #if STABILIZATION_INDI_ALLOCATION_PSEUDO_INVERSE
33 #error "You need to use WLS control allocation for this module"
34 #endif
35 
36 #ifndef INDI_FUNCTIONS_RC_CHANNEL
37 #error "You need to define an RC channel to switch between simple and advanced scheduling"
38 #endif
39 
40 #ifdef FWD_G1
41 static float g1g2_forward[INDI_OUTPUTS][INDI_NUM_ACT] = FWD_G1;
42 #else
43 static float g1g2_forward[INDI_OUTPUTS][INDI_NUM_ACT] = {
44  FWD_G1_ROLL,
45  FWD_G1_PITCH,
46  FWD_G1_YAW,
47  FWD_G1_THRUST
48 };
49 #endif
50 
51 #ifdef STABILIZATION_INDI_G1
52 static float g1g2_hover[INDI_OUTPUTS][INDI_NUM_ACT] = STABILIZATION_INDI_G1;
53 #else
54 static float g1g2_hover[INDI_OUTPUTS][INDI_NUM_ACT] = {
55  STABILIZATION_INDI_G1_ROLL,
56  STABILIZATION_INDI_G1_PITCH,
57  STABILIZATION_INDI_G1_YAW,
58  STABILIZATION_INDI_G1_THRUST
59 };
60 #endif
61 
62 static float g2_both[INDI_NUM_ACT] = STABILIZATION_INDI_G2; //scaled by INDI_G_SCALING
63 
65 {
66  //sum of G1 and G2
67  int8_t i;
68  int8_t j;
69  for (i = 0; i < INDI_OUTPUTS; i++) {
70  for (j = 0; j < INDI_NUM_ACT; j++) {
71  if (i != 2) {
72  g1g2_hover[i][j] = g1g2_hover[i][j] / INDI_G_SCALING;
74  } else {
75  g1g2_forward[i][j] = (g1g2_forward[i][j] + g2_both[j]) / INDI_G_SCALING;
76  g1g2_hover[i][j] = (g1g2_hover[i][j] + g2_both[j]) / INDI_G_SCALING;
77  }
78  }
79  }
80 }
81 
83 {
84  // Go from transition percentage to ratio
86  int8_t i;
87  int8_t j;
88  for (i = 0; i < INDI_OUTPUTS; i++) {
89  for (j = 0; j < INDI_NUM_ACT; j++) {
90  g1g2[i][j] = g1g2_hover[i][j] * (1.0 - ratio) + g1g2_forward[i][j] * ratio;
91  }
92  }
93 }
94 
static float g1g2_hover[INDI_OUTPUTS][INDI_NUM_ACT]
static float g2_both[INDI_NUM_ACT]
void eff_scheduling_generic_periodic(void)
Periodic function that interpolates between gain sets depending on the scheduling variable.
void eff_scheduling_generic_init(void)
Initialises periodic loop;.
static float g1g2_forward[INDI_OUTPUTS][INDI_NUM_ACT]
#define INT32_PERCENTAGE_FRAC
#define FLOAT_OF_BFP(_vbfp, _frac)
Generic interface for radio control modules.
int32_t transition_percentage
Definition: guidance_h.c:52
Horizontal guidance for rotorcrafts.
float g1g2[INDI_OUTPUTS][INDI_NUM_ACT]
#define INDI_G_SCALING
API to get/set the generic vehicle states.
signed char int8_t
Typedef defining 8 bit char type.
Definition: vl53l1_types.h:103