Skip to content

Commit

Permalink
[scheduling] harmonize efficiency scheduling modules (#3182)
Browse files Browse the repository at this point in the history
- harmonize name
- make a 'generic' module with basic linear scheduling
- old ctrl_effectiveness_scheduling was very specific to cyfoam, so
  renamed
- add falcon scheduler, related airframe will come later
  • Loading branch information
gautierhattenberger committed Nov 25, 2023
1 parent 44a3abb commit 68ddea1
Show file tree
Hide file tree
Showing 17 changed files with 465 additions and 140 deletions.
2 changes: 1 addition & 1 deletion conf/airframes/ENAC/cyfoam.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<define name="RADIO_KILL_SWITCH" value="RADIO_GAIN1"/>
</module>

<module name="ctrl_effectiveness_scheduling">
<module name="eff_scheduling_cyfoam">
<define name="SQUARED_ROLL_EFF" value="0.0018"/>
<define name="PITCH_EFF_AT_60" value="4.0"/>
<define name="YAW_EFF_AT_60" value="8.0"/>
Expand Down
2 changes: 1 addition & 1 deletion conf/airframes/tudelft/cyfoam.xml
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@
<define name="RADIO_KILL_SWITCH" value="5"/>
</module>

<module name="ctrl_effectiveness_scheduling">
<module name="eff_scheduling_cyfoam">
<define name="SQUARED_ROLL_EFF" value="0.0018"/>
<define name="PITCH_EFF_AT_60" value="4.0"/>
<define name="YAW_EFF_AT_60" value="8.0"/>
Expand Down
2 changes: 1 addition & 1 deletion conf/airframes/tudelft/rot_wing_25kg.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@

<module name="stabilization" type="rate_indi"/>

<module name="ctrl_eff_sched_rot_wing"/>
<module name="eff_scheduling_rot_wing"/>

<module name="guidance" type="indi_hybrid_quadplane"/>
<module name="nav" type="hybrid">
Expand Down
2 changes: 1 addition & 1 deletion conf/airframes/tudelft/rot_wing_v3b.xml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@
<define name="WLS_N_V" value="5"/>
</module>

<module name="ctrl_eff_sched_rot_wing"/>
<module name="eff_scheduling_rot_wing"/>

<module name="guidance" type="indi_hybrid_quadplane"/>
<module name="nav" type="hybrid">
Expand Down
22 changes: 0 additions & 22 deletions conf/modules/ctrl_effectiveness_scheduling.xml

This file was deleted.

24 changes: 24 additions & 0 deletions conf/modules/eff_scheduling_cyfoam.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE module SYSTEM "module.dtd">

<module name="eff_scheduling_cyfoam" dir="ctrl">
<doc>
<description>
Interpolation of control effectiveness matrix for Cyfoam tailsitter.

The configuration of Cyfoam is a tailsitter with 2 propellers
blowing a wing with 2 flaps. A minimum amont of thrust is thus
required to have enough control on moments, especially pitch moment.

Two scheduling functions are available, controlled by the flag
INDI_FUNCTIONS_RC_CHANNEL, which indicates the RC channel to be used.
</description>
</doc>
<header>
<file name="eff_scheduling_cyfoam.h"/>
</header>
<init fun="eff_scheduling_cyfoam_init()"/>
<periodic fun="eff_scheduling_cyfoam_periodic()" freq="20"/>
<makefile>
<file name="eff_scheduling_cyfoam.c"/>
</makefile>
</module>
24 changes: 24 additions & 0 deletions conf/modules/eff_scheduling_falcon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="eff_scheduling_falcon" dir="ctrl">
<doc>
<description>
Interpolation of control effectivenss matrix of the Falcon hybride plane

The configuation of Falcon is a tailsitter with 4 propellers mounted as a
regular quadcopter and a wing in the middle with 2 ailevons. The ailevons
are only used for roll and pitch with sufficient forward speed. This module
is in charge of disabling them at low speed / high angle of attack when
they have no more efficiency.
</description>
</doc>

<header>
<file name="eff_scheduling_falcon.h"/>
</header>
<init fun="eff_scheduling_falcon_init()"/>
<periodic fun="eff_scheduling_falcon_periodic()" freq="20.0"/>
<periodic fun="eff_scheduling_falcon_report()" freq="0.5" autorun="FALSE"/> <!-- TRUE FALSE-->
<makefile target="ap|nps" firmware="rotorcraft" >
<file name="eff_scheduling_falcon.c"/>
</makefile>
</module>
24 changes: 24 additions & 0 deletions conf/modules/eff_scheduling_generic.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE module SYSTEM "module.dtd">

<module name="eff_scheduling_generic" dir="ctrl">
<doc>
<description>
Interpolation of control effectivenss matrix.
This is necessary if the vehicle has different operating points,
with significantly different control effectivenss.
Interpolation is linear between two points, usually hover and
forward conditions.

If instead using online adaptation is an option, be sure to
not use this module at the same time!
</description>
</doc>
<header>
<file name="eff_scheduling_generic.h"/>
</header>
<init fun="eff_scheduling_generic_init()"/>
<periodic fun="eff_scheduling_generic_periodic()" freq="20"/>
<makefile>
<file name="eff_scheduling_generic.c"/>
</makefile>
</module>
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<!DOCTYPE module SYSTEM "module.dtd">
<module name="ctrl_eff_sched_rot_wing" dir="ctrl">
<module name="eff_scheduling_rot_wing" dir="ctrl">
<doc>
<description>The control effectiveness scheduler for the rotating wing quadplane drone type
<description>T
he control effectiveness scheduler for the rotating wing quadplane drone type
- it requires a servo called ROTATION_MECH
</description>
<section name="ROT_WING" prefix="ROT_WING_EFF_SCHED_">
Expand All @@ -18,12 +19,12 @@
</section>
</doc>
<header>
<file name="ctrl_eff_sched_rot_wing.h"/>
<file name="eff_scheduling_rot_wing.h"/>
</header>
<init fun="ctrl_eff_sched_rot_wing_init()"/>
<periodic fun="ctrl_eff_sched_rot_wing_periodic()" freq="10.0"/>
<init fun="eff_scheduling_rot_wing_init()"/>
<periodic fun="eff_scheduling_rot_wing_periodic()" freq="10.0"/>
<makefile>
<file name="ctrl_eff_sched_rot_wing.c"/>
<file name="eff_scheduling_rot_wing.c"/>
<test>
<define name="ACTUATORS_NB" value="10"/>
<define name="SERVO_ROTATION_MECH" value="8"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
* along with paparazzi; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*/

/** @file modules/ctrl/ctrl_effectiveness_scheduling.c
* Module that interpolates gainsets in flight based on the transition percentage
*/

#include "modules/ctrl/ctrl_effectiveness_scheduling.h"
#include "modules/ctrl/eff_scheduling_cyfoam.h"
#include "firmwares/rotorcraft/stabilization/stabilization_indi.h"
#include "firmwares/rotorcraft/guidance/guidance_h.h"
#include "generated/airframe.h"
Expand All @@ -38,18 +37,23 @@
#error "You need to define an RC channel to switch between simple and advanced scheduling"
#endif

static float g1g2_forward[INDI_OUTPUTS][INDI_NUM_ACT] = {FWD_G1_ROLL,
FWD_G1_PITCH, FWD_G1_YAW, FWD_G1_THRUST
};
static float g1g2_forward[INDI_OUTPUTS][INDI_NUM_ACT] = {
FWD_G1_ROLL,
FWD_G1_PITCH,
FWD_G1_YAW,
FWD_G1_THRUST
};

static float g1g2_hover[INDI_OUTPUTS][INDI_NUM_ACT] = {STABILIZATION_INDI_G1_ROLL,
STABILIZATION_INDI_G1_PITCH, STABILIZATION_INDI_G1_YAW, STABILIZATION_INDI_G1_THRUST
};
static float g1g2_hover[INDI_OUTPUTS][INDI_NUM_ACT] = {
STABILIZATION_INDI_G1_ROLL,
STABILIZATION_INDI_G1_PITCH,
STABILIZATION_INDI_G1_YAW,
STABILIZATION_INDI_G1_THRUST
};

static float g2_both[INDI_NUM_ACT] = STABILIZATION_INDI_G2; //scaled by INDI_G_SCALING

//Get the specified gains in the gainlibrary
void ctrl_eff_scheduling_init(void)
void eff_scheduling_cyfoam_init(void)
{
//sum of G1 and G2
int8_t i;
Expand All @@ -67,31 +71,7 @@ void ctrl_eff_scheduling_init(void)
}
}

void ctrl_eff_scheduling_periodic(void)
{
if(radio_control.values[INDI_FUNCTIONS_RC_CHANNEL] > 0) {
ctrl_eff_scheduling_periodic_b();
} else {
ctrl_eff_scheduling_periodic_a();
}

#ifdef INDI_THRUST_ON_PITCH_EFF
//State prioritization {W Roll, W pitch, W yaw, TOTAL THRUST}
if(radio_control.values[INDI_FUNCTIONS_RC_CHANNEL] > 0 && (actuator_state_filt_vect[0] < -7000) && (actuator_state_filt_vect[1] > 7000)) {
Bwls[1][2] = INDI_THRUST_ON_PITCH_EFF/INDI_G_SCALING;
Bwls[1][3] = INDI_THRUST_ON_PITCH_EFF/INDI_G_SCALING;
} else if(radio_control.values[INDI_FUNCTIONS_RC_CHANNEL] > 0 && (actuator_state_filt_vect[0] > 7000) && (actuator_state_filt_vect[1] < -7000)) {
Bwls[1][2] = -INDI_THRUST_ON_PITCH_EFF/INDI_G_SCALING;
Bwls[1][3] = -INDI_THRUST_ON_PITCH_EFF/INDI_G_SCALING;
} else {
Bwls[1][2] = 0.0;
Bwls[1][3] = 0.0;
}
#endif

}

void ctrl_eff_scheduling_periodic_a(void)
static void eff_scheduling_periodic_a(void)
{
// Go from transition percentage to ratio
float ratio = FLOAT_OF_BFP(transition_percentage, INT32_PERCENTAGE_FRAC) / 100;
Expand All @@ -105,7 +85,7 @@ void ctrl_eff_scheduling_periodic_a(void)
}
}

void ctrl_eff_scheduling_periodic_b(void)
static void eff_scheduling_periodic_b(void)
{
float airspeed = stateGetAirspeed_f();
struct FloatEulers eulers_zxy;
Expand Down Expand Up @@ -149,3 +129,26 @@ void ctrl_eff_scheduling_periodic_b(void)

}

void eff_scheduling_cyfoam_periodic(void)
{
if (radio_control.values[INDI_FUNCTIONS_RC_CHANNEL] > 0) {
eff_scheduling_periodic_b();
} else {
eff_scheduling_periodic_a();
}

#ifdef INDI_THRUST_ON_PITCH_EFF
//State prioritization {W Roll, W pitch, W yaw, TOTAL THRUST}
if(radio_control.values[INDI_FUNCTIONS_RC_CHANNEL] > 0 && (actuator_state_filt_vect[0] < -7000) && (actuator_state_filt_vect[1] > 7000)) {
Bwls[1][2] = INDI_THRUST_ON_PITCH_EFF/INDI_G_SCALING;
Bwls[1][3] = INDI_THRUST_ON_PITCH_EFF/INDI_G_SCALING;
} else if(radio_control.values[INDI_FUNCTIONS_RC_CHANNEL] > 0 && (actuator_state_filt_vect[0] > 7000) && (actuator_state_filt_vect[1] < -7000)) {
Bwls[1][2] = -INDI_THRUST_ON_PITCH_EFF/INDI_G_SCALING;
Bwls[1][3] = -INDI_THRUST_ON_PITCH_EFF/INDI_G_SCALING;
} else {
Bwls[1][2] = 0.0;
Bwls[1][3] = 0.0;
}
#endif
}

39 changes: 39 additions & 0 deletions sw/airborne/modules/ctrl/eff_scheduling_cyfoam.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (C) Gautier Hattenberger <gautier.hattenberger@enac.fr>
*
* This file is part of paparazzi.
*
* paparazzi is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* paparazzi is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with paparazzi; see the file COPYING. If not, see
* <http://www.gnu.org/licenses/>.
*/

/**
* @file modules/ctrl/eff_scheduling_cyfoam.h
*/

#ifndef EFF_SCHEDULING_CYFOAM_H
#define EFF_SCHEDULING_CYFOAM_H

/**
* Initialises periodic loop;
*/
extern void eff_scheduling_cyfoam_init(void);

/**
* Periodic function that interpolates between gain sets depending on the scheduling variable.
*/
extern void eff_scheduling_cyfoam_periodic(void);

#endif /* EFF_SCHEDULING_CYFOAM_H */

0 comments on commit 68ddea1

Please sign in to comment.