257 changes: 167 additions & 90 deletions conf/airframes/tudelft/nederdrone4.xml

Large diffs are not rendered by default.

371 changes: 0 additions & 371 deletions conf/airframes/tudelft/nederdrone5.xml

This file was deleted.

12 changes: 8 additions & 4 deletions conf/airframes/tudelft/nederdrone6.xml
Expand Up @@ -63,7 +63,6 @@
</target>

<target name="nps" board="pc">
<!-- <module name="eff_scheduling_nederdrone_dummy"/> -->
<module name="radio_control" type="datalink"/>
<module name="fdm" type="jsbsim"/>

Expand All @@ -78,10 +77,13 @@
<define name="RADIO_KILL_SWITCH" value="0"/>
</target>

<module name="eff_scheduling_nederdrone"/>
<module name="eff_scheduling_nederdrone">
<!-- Trims -->
<define name="INDI_SCHEDULING_TRIM_ELEVATOR" value="0"/>
</module>

<module name="telemetry" type="transparent">
<configure name="MODEM_BAUD" value="B115200"/>
<configure name="MODEM_BAUD" value="B460800"/>
</module>

<module name="approach_moving_target">
Expand Down Expand Up @@ -138,9 +140,11 @@
<define name="GUIDANCE_INDI_SPEED_GAIN" value="0.5"/>
<define name="GUIDANCE_INDI_POS_GAINZ" value="0.3"/>
<define name="GUIDANCE_INDI_SPEED_GAINZ" value="0.5"/>
<define name="GUIDANCE_INDI_PITCH_LIFT_EFF" value="0.12"/>
<define name="GUIDANCE_INDI_PITCH_EFF_SCALING" value="1.0"/>
<define name="GUIDANCE_H_REF_MAX_SPEED" value="18.0"/> <!--not used-->
<define name="GUIDANCE_INDI_MAX_AIRSPEED" value="17.0"/>
<define name="GUIDANCE_HEADING_IS_FREE" value="FALSE"/> <!--heading can not be set by navigation-->
<define name="GUIDANCE_INDI_HEADING_BANK_GAIN" value="5"/>
<!--define name="GUIDANCE_INDI_SPECIFIC_FORCE_GAIN" value="-943.0"/>
<define name="GUIDANCE_INDI_SPECIFIC_FORCE_GAIN_45" value="-500.0"/>
Expand Down Expand Up @@ -337,9 +341,9 @@
<define name="FILT_CUTOFF" value="1.5"/>
<define name="FILT_CUTOFF_RDOT" value="0.5"/>
<define name="ESTIMATION_FILT_CUTOFF" value="5.0"/>
<define name="FILT_CUTOFF_R" value="4."/>
<define name="FILT_CUTOFF_P" value="20."/>
<define name="FILT_CUTOFF_Q" value="20."/>
<define name="FILT_CUTOFF_R" value="4."/>
<!-- first order actuator dynamics -->
<!--define name="ACT_DYN" value="{0.009, 0.009, 0.009, 0.009, 0.05, 0.05, 0.05, 0.05}"/-->
<define name="ACT_DYN" value="{0.028, 0.028, 0.028, 0.028, 0.05, 0.05, 0.05, 0.05}"/>
Expand Down
10 changes: 8 additions & 2 deletions conf/airframes/tudelft/nederdrone7.xml
Expand Up @@ -35,6 +35,7 @@
<module name="airspeed" type="ms45xx_i2c">
<define name="USE_I2C4"/>
<define name="MS45XX_I2C_DEV" value="i2c4"/>
<define name="I2C4_CLOCK_SPEED" value="100000"/>
</module>
<!--module name="airspeed" type="uavcan"/-->

Expand Down Expand Up @@ -77,10 +78,13 @@
<define name="RADIO_KILL_SWITCH" value="0"/>
</target>

<module name="eff_scheduling_nederdrone"/>
<module name="eff_scheduling_nederdrone">
<!-- Trims -->
<define name="INDI_SCHEDULING_TRIM_ELEVATOR" value="0"/>
</module>

<module name="telemetry" type="transparent">
<configure name="MODEM_BAUD" value="B115200"/>
<configure name="MODEM_BAUD" value="B460800"/>
</module>

<module name="approach_moving_target">
Expand Down Expand Up @@ -137,9 +141,11 @@
<define name="GUIDANCE_INDI_SPEED_GAIN" value="0.5"/>
<define name="GUIDANCE_INDI_POS_GAINZ" value="0.3"/>
<define name="GUIDANCE_INDI_SPEED_GAINZ" value="0.5"/>
<define name="GUIDANCE_INDI_PITCH_LIFT_EFF" value="0.12"/>
<define name="GUIDANCE_INDI_PITCH_EFF_SCALING" value="1.0"/>
<define name="GUIDANCE_H_REF_MAX_SPEED" value="18.0"/> <!--not used-->
<define name="GUIDANCE_INDI_MAX_AIRSPEED" value="17.0"/>
<define name="GUIDANCE_HEADING_IS_FREE" value="FALSE"/> <!--heading can not be set by navigation-->
<define name="GUIDANCE_INDI_HEADING_BANK_GAIN" value="5"/>
<!--define name="GUIDANCE_INDI_SPECIFIC_FORCE_GAIN" value="-943.0"/>
<define name="GUIDANCE_INDI_SPECIFIC_FORCE_GAIN_45" value="-500.0"/>
Expand Down
21 changes: 14 additions & 7 deletions conf/airframes/tudelft/nederdrone8.xml
Expand Up @@ -23,7 +23,7 @@
</module>

<!-- Forward FuelCell data back to the GCS -->
<!--module name="generic_uart_sensor"/-->
<module name="generic_uart_sensor"/>

<!-- Logger -->
<module name="tlsf"/>
Expand All @@ -35,6 +35,7 @@
<module name="airspeed" type="ms45xx_i2c">
<define name="USE_I2C4"/>
<define name="MS45XX_I2C_DEV" value="i2c4"/>
<define name="I2C4_CLOCK_SPEED" value="100000"/>
</module>
<!--module name="airspeed" type="uavcan"/-->

Expand Down Expand Up @@ -77,17 +78,23 @@
<define name="RADIO_KILL_SWITCH" value="0"/>
</target>

<module name="eff_scheduling_nederdrone"/>
<module name="eff_scheduling_nederdrone">
<!-- Trims -->
<define name="INDI_SCHEDULING_TRIM_ELEVATOR" value="1100"/>
<define name="INDI_SCHEDULING_PREF_FLAPS_FACTOR" value="1.0"/>
</module>

<module name="telemetry" type="transparent">
<configure name="MODEM_BAUD" value="B115200"/>
<configure name="MODEM_BAUD" value="B460800"/>
</module>

<module name="approach_moving_target">
<define name="AMT_ERR_SLOWDOWN_GAIN" value="0.25"/>
</module>

<module name="ins" type="ekf2" />
<module name="ins" type="ekf2">
<define name="USE_INS_NAV_INIT" value="FALSE"/>
</module>

<module name="actuators" type="uavcan">
<configure name="UAVCAN_USE_CAN1" value="TRUE"/>
Expand Down Expand Up @@ -137,9 +144,11 @@
<define name="GUIDANCE_INDI_SPEED_GAIN" value="0.5"/>
<define name="GUIDANCE_INDI_POS_GAINZ" value="0.3"/>
<define name="GUIDANCE_INDI_SPEED_GAINZ" value="0.5"/>
<define name="GUIDANCE_INDI_PITCH_LIFT_EFF" value="0.12"/>
<define name="GUIDANCE_INDI_PITCH_EFF_SCALING" value="1.0"/>
<define name="GUIDANCE_H_REF_MAX_SPEED" value="18.0"/> <!--not used-->
<define name="GUIDANCE_INDI_MAX_AIRSPEED" value="17.0"/>
<define name="GUIDANCE_HEADING_IS_FREE" value="FALSE"/> <!--heading can not be set by navigation-->
<define name="GUIDANCE_INDI_HEADING_BANK_GAIN" value="5"/>
<!--define name="GUIDANCE_INDI_SPECIFIC_FORCE_GAIN" value="-943.0"/>
<define name="GUIDANCE_INDI_SPECIFIC_FORCE_GAIN_45" value="-500.0"/>
Expand Down Expand Up @@ -344,13 +353,11 @@
<define name="ACT_DYN" value="{0.028, 0.028, 0.028, 0.028, 0.05, 0.05, 0.05, 0.05}"/>
<define name="ACT_RATE_LIMIT" value="{9600, 9600, 9600, 9600, 170, 170, 170, 170}"/>
<define name="ACT_IS_SERVO" value="{0, 0, 0, 0, 1, 1, 1, 1}"/>
<define name="WLS_WU" value="{1.,1.,1.,1.,1.,1.,1.,1.}"/>

<!-- Adaptive Learning Rate -->
<define name="USE_ADAPTIVE" value="FALSE"/>
<define name="ADAPTIVE_MU" value="0.0001"/>

<!-- Trims -->
<define name="TRIM_ELEVATOR" value="1800"/>
</section>

<section name="GUIDANCE_V" prefix="GUIDANCE_V_">
Expand Down
6 changes: 3 additions & 3 deletions conf/flight_plans/tudelft/nederdrone_terschelling.xml
Expand Up @@ -66,12 +66,13 @@
<set value="FALSE" var="force_forward"/>
<call_once fun="NavResurrect()"/>
<call_once fun="nav_set_heading_current()"/>
<attitude pitch="-60" roll="0" throttle="0" until="stage_time>1" vmode="throttle"/>
<attitude pitch="-45" roll="0" throttle="0" until="stage_time>1" vmode="throttle"/>
</block>
<block name="TakeoffLow" strip_button="Takeoff" strip_icon="takeoff.png">
<exception cond="GetPosHeight() @GT 18.0" deroute="Takeoff"/>
<call_once fun="nav_set_heading_current()"/>
<attitude pitch="-40." roll="0" throttle="0.8" vmode="throttle"/>
<call_once fun="autopilot_set_in_flight(true)"/>
<attitude pitch="-45." roll="0" throttle="0.8" vmode="throttle"/>
</block>
<block name="Takeoff" strip_button="Takeoff" strip_icon="takeoff.png">
<exception cond="GetPosHeight() @GT 40.0" deroute="Standby"/>
Expand All @@ -89,7 +90,6 @@
</block>
<block name="go_p2">
<set value="TRUE" var="force_forward"/>
<call_once fun="nav_set_heading_deg(90)"/>
<go wp="p2"/>
<deroute block="stay_p1"/>
</block>
Expand Down
11 changes: 6 additions & 5 deletions conf/flight_plans/tudelft/nederdrone_troia.xml
Expand Up @@ -9,6 +9,7 @@
<waypoint lat="38.474472222222225" lon="-8.871222222222222" name="HOME"/>
<waypoint lat="38.476515" lon="-8.868380" name="CLIMB"/>
<waypoint lat="38.476331" lon="-8.869787" name="STDBY"/>
<waypoint lat="38.476331" lon="-8.865787" name="CIRCLE"/>
<waypoint lat="38.476940" lon="-8.867501" name="p1"/>
<waypoint lat="38.481886" lon="-8.856215" name="p2"/>
<!-- <waypoint lat="38.478809" lon="-8.851799" name="p3"/> -->
Expand Down Expand Up @@ -136,12 +137,13 @@
<set value="FALSE" var="force_forward"/>
<call_once fun="NavResurrect()"/>
<call_once fun="nav_set_heading_current()"/>
<attitude pitch="-50" roll="0" throttle="0.8" until="stage_time>0" vmode="throttle"/>
<attitude pitch="-45" roll="0" throttle="0.0" until="stage_time>1" vmode="throttle"/>
</block>
<block name="TakeoffLow">
<exception cond="GetPosHeight() @GT 18.0" deroute="Takeoff"/>
<call_once fun="autopilot_set_in_flight(true)"/>
<call_once fun="nav_set_heading_current()"/>
<attitude pitch="-45." roll="0" throttle="0.9" vmode="throttle"/>
<attitude pitch="-45." roll="0" throttle="0.8" vmode="throttle"/>
</block>
<block name="Takeoff">
<exception cond="GetPosHeight() @GT 70.0" deroute="GO NORTH"/>
Expand Down Expand Up @@ -178,7 +180,6 @@
</block>
<block name="go_p2">
<set value="TRUE" var="force_forward"/>
<call_once fun="nav_set_heading_deg(90)"/>
<go wp="p2"/>
<deroute block="stay_p1"/>
</block>
Expand All @@ -192,9 +193,9 @@
<exception cond="GpsFixValid()" deroute="GO NORTH"/>
<attitude pitch="0" roll="0" climb="-1.0" vmode="climb"/>
</block>
<block name="Oval">
<block name="Circle">
<set value="TRUE" var="force_forward"/>
<oval p1="p1" p2="p2" radius="nav.radius"/>
<circle radius="nav.radius" wp="CIRCLE"/>
</block>
<block name="land here">
<set value="FALSE" var="force_forward"/>
Expand Down
8 changes: 4 additions & 4 deletions conf/flight_plans/tudelft/nederdrone_valkenburg.xml
Expand Up @@ -63,14 +63,15 @@
<call_once fun="NavKillThrottle()"/>
<attitude pitch="0" roll="0" throttle="0" until="FALSE" vmode="throttle"/>
</block>
<block name="Start Engine">
<block name="Start Engine" strip_button="Takeoff" strip_icon="takeoff.png">
<set value="FALSE" var="force_forward"/>
<call_once fun="NavResurrect()"/>
<call_once fun="nav_set_heading_current()"/>
<attitude pitch="-65" roll="0" throttle="0" until="stage_time>1" vmode="throttle"/>
<attitude pitch="-45" roll="0" throttle="0.0" until="stage_time>1" vmode="throttle"/>
</block>
<block name="TakeoffLow" strip_button="Takeoff" strip_icon="takeoff.png">
<block name="TakeoffLow">
<exception cond="GetPosHeight() @GT 18.0" deroute="Takeoff"/>
<call_once fun="autopilot_set_in_flight(true)"/>
<call_once fun="nav_set_heading_current()"/>
<attitude pitch="-45." roll="0" throttle="0.8" vmode="throttle"/>
</block>
Expand Down Expand Up @@ -106,7 +107,6 @@
</block>
<block name="go_p2">
<set value="TRUE" var="force_forward"/>
<call_once fun="nav_set_heading_deg(90)"/>
<go wp="p2"/>
<deroute block="stay_p1"/>
</block>
Expand Down
3 changes: 3 additions & 0 deletions conf/modules/eff_scheduling_nederdrone.xml
Expand Up @@ -15,9 +15,12 @@ not use this module at the same time!</description>
<dl_setting shortname="tip_prop_upper_pitch" var="sched_tip_prop_upper_pitch_limit_deg" min="-90" step="1" max="0"/>
<dl_setting shortname="sched_ratio_tip_props" var="sched_ratio_tip_props" min="0" step="0.1" max="1"/>
<dl_setting shortname="thrust_eff_scaling" var="thrust_eff_scaling" min="0.6" step="0.01" max="1.4"/>
<dl_setting shortname="back_thrust_scale" var="backwing_thrust_eff_scaling" min="0.6" step="0.01" max="1.4"/>
<dl_setting shortname="back_pitch_scale" var="backwing_pitch_eff_scaling" min="0.5" step="0.01" max="1.5"/>
<dl_setting shortname="all_act_fwd_sched" var="all_act_fwd_sched" min="0" step="1" max="1" values="OFF|ON"/>
<dl_setting shortname="trim_elevator" var="trim_elevator" min="-5000" step="1" max="5000"/>
<dl_setting shortname="trim_flaps" var="trim_flaps" min="-5000" step="1" max="5000"/>
<dl_setting shortname="pref_flaps_factor" var="pref_flaps_factor" min="0.1" step="0.1" max="100"/>
</dl_settings>
</dl_settings>
</settings>
Expand Down
32 changes: 32 additions & 0 deletions sw/airborne/modules/ctrl/eff_scheduling_nederdrone.c
Expand Up @@ -56,11 +56,19 @@ not use this module at the same time!
float trim_elevator = INDI_SCHEDULING_TRIM_ELEVATOR;
float trim_flaps = INDI_SCHEDULING_TRIM_FLAPS;

// Factor that changes cost of the flaps and motors if v>15.0 m/s
// Higher factor means prefer using the flaps
float pref_flaps_factor = INDI_SCHEDULING_PREF_FLAPS_FACTOR;

float indi_Wu_original[INDI_NUM_ACT] = STABILIZATION_INDI_WLS_WU;

bool all_act_fwd_sched = false;

int32_t use_scheduling = 1;

float thrust_eff_scaling = 1.0;
float backwing_thrust_eff_scaling = 1.0;
float backwing_pitch_eff_scaling = 1.0;

static float g_forward[4][INDI_NUM_ACT] = {STABILIZATION_INDI_G1_ROLL_FWD, STABILIZATION_INDI_G1_PITCH_FWD, STABILIZATION_INDI_G1_YAW_FWD, STABILIZATION_INDI_G1_THRUST_FWD};

Expand Down Expand Up @@ -163,6 +171,10 @@ void schdule_control_effectiveness(void) {
} else {
g1g2[1][i] = g_hover[1][i] * (1.0 - pitch_ratio) + g_forward[1][i] * pitch_ratio * airspeed_pitch_eff * airspeed_pitch_eff / (16.0*16.0);
}
// With this factor the pitch effectiveness of the back wing can be scaled
if( (i ==2) || (i==3)) {
g1g2[1][i] *= backwing_pitch_eff_scaling;
}
//Yaw
g1g2[2][i] = g_hover[2][i] * (1.0 - ratio) + g_forward[2][i] * ratio;

Expand Down Expand Up @@ -192,6 +204,10 @@ void schdule_control_effectiveness(void) {
// Thrust
g1g2[3][i] = g_hover[3][i] * (1.0 - ratio_spec_force) + g_forward[3][i] * ratio_spec_force;
g1g2[3][i] *= thrust_eff_scaling;
// With this factor the thrust effectiveness of the back wing can be scaled
if( (i ==2) || (i==3)) {
g1g2[3][i] *= backwing_thrust_eff_scaling;
}
}

bool low_airspeed = stateGetAirspeed_f() < INDI_SCHEDULING_LOW_AIRSPEED;
Expand All @@ -206,4 +222,20 @@ void schdule_control_effectiveness(void) {
sched_ratio_tip_props = pitch_offset / pitch_range_deg;
}
Bound(sched_ratio_tip_props, 0.0, 1.0);

// Blance the cost of using motors and aerodynamic surfaces
if(airspeed > 15.0) {
uint8_t i;
for (i = 0; i < 4; i++) {
indi_Wu[i] = indi_Wu_original[i]*pref_flaps_factor;
}
for (i = 4; i < 8; i++) {
indi_Wu[i] = indi_Wu_original[i]/pref_flaps_factor;
}
} else {
uint8_t i;
for (i = 0; i < 8; i++) {
indi_Wu[i] = indi_Wu_original[i];
}
}
}
4 changes: 4 additions & 0 deletions sw/airborne/modules/ctrl/eff_scheduling_nederdrone.h
Expand Up @@ -46,6 +46,8 @@ extern float sched_tip_prop_lower_pitch_limit_deg;
extern bool sched_tip_props_always_on;
// Setting to scale the thrust effectiveness
extern float thrust_eff_scaling;
extern float backwing_thrust_eff_scaling;
extern float backwing_pitch_eff_scaling;

// Schedule all forward actuators with airspeed instead of only the flaps
extern bool all_act_fwd_sched;
Expand All @@ -54,4 +56,6 @@ extern bool all_act_fwd_sched;
extern float trim_elevator;
extern float trim_flaps;

extern float pref_flaps_factor;

#endif // EFF_SCHEDULING_NEDERDRONE_H