29 #include "generated/airframe.h"
33 #if STABILIZATION_INDI_ALLOCATION_PSEUDO_INVERSE
34 #error "You need to use WLS control allocation for this module"
37 #ifndef INDI_FUNCTIONS_RC_CHANNEL
38 #error "You need to define an RC channel to switch between simple and advanced scheduling"
41 static float g1g2_forward[INDI_OUTPUTS][INDI_NUM_ACT] = {FWD_G1_ROLL,
42 FWD_G1_PITCH, FWD_G1_YAW, FWD_G1_THRUST
45 static float g1g2_hover[INDI_OUTPUTS][INDI_NUM_ACT] = {STABILIZATION_INDI_G1_ROLL,
46 STABILIZATION_INDI_G1_PITCH, STABILIZATION_INDI_G1_YAW, STABILIZATION_INDI_G1_THRUST
49 static float g2_both[INDI_NUM_ACT] = STABILIZATION_INDI_G2;
57 for (i = 0; i < INDI_OUTPUTS; i++) {
58 for (j = 0; j < INDI_NUM_ACT; j++) {
78 #ifdef INDI_THRUST_ON_PITCH_EFF
101 for (i = 0; i < INDI_OUTPUTS; i++) {
102 for (j = 0; j < INDI_NUM_ACT; j++) {
115 Bound(pitch_interp, -60.0, -30.0);
116 float ratio = (pitch_interp + 30.0)/(-30.);
119 g1g2[1][0] =
g1g2_hover[1][0]*(1-ratio) + -PITCH_EFF_AT_60/1000*ratio;
120 g1g2[1][1] =
g1g2_hover[1][1]*(1-ratio) + PITCH_EFF_AT_60/1000*ratio;
122 g1g2[2][0] =
g1g2_hover[2][0]*(1-ratio) + -YAW_EFF_AT_60/1000*ratio;
123 g1g2[2][1] =
g1g2_hover[2][1]*(1-ratio) + -YAW_EFF_AT_60/1000*ratio;
126 Bound(airspeed, 0.0, 30.0);
127 float airspeed2 = airspeed*airspeed;
129 float pitch_eff = CE_PITCH_A + CE_PITCH_B*airspeed2;
130 g1g2[1][0] = -pitch_eff/1000;
131 g1g2[1][1] = pitch_eff/1000;
133 float yaw_eff = CE_YAW_A + CE_YAW_B*airspeed2;
134 g1g2[2][0] = -yaw_eff/1000;
135 g1g2[2][1] = -yaw_eff/1000;
140 Bound(
g1g2[0][2], -30.0/1000, -2.0/1000);
141 Bound(
g1g2[0][3], 2.0/1000, 30.0/1000);
144 if(airspeed > 12.0) {
static float g1g2_hover[INDI_OUTPUTS][INDI_NUM_ACT]
static float g2_both[INDI_NUM_ACT]
void ctrl_eff_scheduling_periodic_b(void)
void ctrl_eff_scheduling_periodic_a(void)
void ctrl_eff_scheduling_periodic(void)
Periodic function that interpolates between gain sets depending on the scheduling variable.
static float g1g2_forward[INDI_OUTPUTS][INDI_NUM_ACT]
void ctrl_eff_scheduling_init(void)
Initialises periodic loop;.
void float_eulers_of_quat_zxy(struct FloatEulers *e, struct FloatQuat *q)
euler rotation 'ZXY' This rotation order is useful if you need 90 deg pitch
#define INT32_PERCENTAGE_FRAC
#define FLOAT_OF_BFP(_vbfp, _frac)
static struct FloatQuat * stateGetNedToBodyQuat_f(void)
Get vehicle body attitude quaternion (float).
static float stateGetAirspeed_f(void)
Get airspeed (float).
struct FloatEulers eulers_zxy
state eulers in zxy order
struct RadioControl radio_control
Generic interface for radio control modules.
pprz_t values[RADIO_CONTROL_NB_CHANNEL]
int32_t transition_percentage
Horizontal guidance for rotorcrafts.
float * Bwls[INDI_OUTPUTS]
struct Indi_gains indi_gains
float g1g2[INDI_OUTPUTS][INDI_NUM_ACT]
float actuator_state_filt_vect[INDI_NUM_ACT]
API to get/set the generic vehicle states.
signed char int8_t
Typedef defining 8 bit char type.