Paparazzi UAS  v5.15_devel-230-gc96ce27
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
ctrl_effectiveness_scheduling.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, write to
18  * the Free Software Foundation, 59 Temple Place - Suite 330,
19  * Boston, MA 02111-1307, USA.
20  */
21 
29 #include "generated/airframe.h"
30 #include "state.h"
32 
33 #if STABILIZATION_INDI_ALLOCATION_PSEUDO_INVERSE
34 #error "You need to use WLS control allocation for this module"
35 #endif
36 
37 
38 static float g1g2_forward[INDI_OUTPUTS][INDI_NUM_ACT] = {FWD_G1_ROLL,
39  FWD_G1_PITCH, FWD_G1_YAW, FWD_G1_THRUST
40  };
41 
42 static float g1g2_hover[INDI_OUTPUTS][INDI_NUM_ACT] = {STABILIZATION_INDI_G1_ROLL,
43  STABILIZATION_INDI_G1_PITCH, STABILIZATION_INDI_G1_YAW, STABILIZATION_INDI_G1_THRUST
44  };
45 
46 static float g2_both[INDI_NUM_ACT] = STABILIZATION_INDI_G2; //scaled by INDI_G_SCALING
47 
48 //Get the specified gains in the gainlibrary
50 {
51  //sum of G1 and G2
52  int8_t i;
53  int8_t j;
54  for (i = 0; i < INDI_OUTPUTS; i++) {
55  for (j = 0; j < INDI_NUM_ACT; j++) {
56  if (i != 2) {
57  g1g2_hover[i][j] = g1g2_hover[i][j] / INDI_G_SCALING;
59  } else {
60  g1g2_forward[i][j] = (g1g2_forward[i][j] + g2_both[j]) / INDI_G_SCALING;
61  g1g2_hover[i][j] = (g1g2_hover[i][j] + g2_both[j]) / INDI_G_SCALING;
62  }
63  }
64  }
65 }
66 
68 {
69  // Go from transition percentage to ratio
71 
72  int8_t i;
73  int8_t j;
74  for (i = 0; i < INDI_OUTPUTS; i++) {
75  for (j = 0; j < INDI_NUM_ACT; j++) {
76  g1g2[i][j] = (g1g2_hover[i][j] * (1.0 - ratio) + g1g2_forward[i][j] * ratio);
77  }
78  }
79 }
int32_t transition_percentage
Definition: guidance_h.c:82
float g1g2[INDI_OUTPUTS][INDI_NUM_ACT]
static float g1g2_hover[INDI_OUTPUTS][INDI_NUM_ACT]
#define INT32_PERCENTAGE_FRAC
#define FLOAT_OF_BFP(_vbfp, _frac)
static float g2_both[INDI_NUM_ACT]
#define INDI_G_SCALING
static float g1g2_forward[INDI_OUTPUTS][INDI_NUM_ACT]
API to get/set the generic vehicle states.
void ctrl_eff_scheduling_init(void)
Initialises periodic loop;.
Horizontal guidance for rotorcrafts.
signed char int8_t
Definition: types.h:15
void ctrl_eff_scheduling_periodic(void)
Periodic function that interpolates between gain sets depending on the scheduling variable...