diff --git a/src/modules/fw_pos_control_l1/FixedwingPositionControl.cpp b/src/modules/fw_pos_control_l1/FixedwingPositionControl.cpp index cd5cafcbf0..498929e357 100644 --- a/src/modules/fw_pos_control_l1/FixedwingPositionControl.cpp +++ b/src/modules/fw_pos_control_l1/FixedwingPositionControl.cpp @@ -75,6 +75,7 @@ FixedwingPositionControl::FixedwingPositionControl() : _parameter_handles.land_thrust_lim_alt_relative = param_find("FW_LND_TLALT"); _parameter_handles.land_heading_hold_horizontal_distance = param_find("FW_LND_HHDIST"); _parameter_handles.land_use_terrain_estimate = param_find("FW_LND_USETER"); + _parameter_handles.land_early_config_change = param_find("FW_LND_EARLYCFG"); _parameter_handles.land_airspeed_scale = param_find("FW_LND_AIRSPD_SC"); _parameter_handles.land_throtTC_scale = param_find("FW_LND_THRTC_SC"); @@ -148,6 +149,7 @@ FixedwingPositionControl::parameters_update() param_get(_parameter_handles.land_flare_pitch_min_deg, &(_parameters.land_flare_pitch_min_deg)); param_get(_parameter_handles.land_flare_pitch_max_deg, &(_parameters.land_flare_pitch_max_deg)); param_get(_parameter_handles.land_use_terrain_estimate, &(_parameters.land_use_terrain_estimate)); + param_get(_parameter_handles.land_early_config_change, &(_parameters.land_early_config_change)); param_get(_parameter_handles.land_airspeed_scale, &(_parameters.land_airspeed_scale)); param_get(_parameter_handles.land_throtTC_scale, &(_parameters.land_throtTC_scale)); @@ -847,7 +849,8 @@ FixedwingPositionControl::control_position(const Vector2f &curr_pos, const Vecto float alt_sp = pos_sp_curr.alt; - if (pos_sp_next.type == position_setpoint_s::SETPOINT_TYPE_LAND && pos_sp_next.valid && _l1_control.circle_mode()) { + if (pos_sp_next.type == position_setpoint_s::SETPOINT_TYPE_LAND && pos_sp_next.valid + && _l1_control.circle_mode() && _parameters.land_early_config_change == 1) { // We're in a loiter directly before a landing WP. Enable our landing configuration (flaps, // landing airspeed and potentially tighter throttle control) already such that we don't // have to do this switch (which can cause significant altitude errors) close to the ground. diff --git a/src/modules/fw_pos_control_l1/FixedwingPositionControl.hpp b/src/modules/fw_pos_control_l1/FixedwingPositionControl.hpp index 584007876e..9cd2b8c749 100644 --- a/src/modules/fw_pos_control_l1/FixedwingPositionControl.hpp +++ b/src/modules/fw_pos_control_l1/FixedwingPositionControl.hpp @@ -294,6 +294,7 @@ private: float land_flare_pitch_min_deg; float land_flare_pitch_max_deg; int32_t land_use_terrain_estimate; + int32_t land_early_config_change; float land_airspeed_scale; float land_throtTC_scale; @@ -358,6 +359,7 @@ private: param_t land_flare_pitch_min_deg; param_t land_flare_pitch_max_deg; param_t land_use_terrain_estimate; + param_t land_early_config_change; param_t land_airspeed_scale; param_t land_throtTC_scale; diff --git a/src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c b/src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c index ce8215ba93..f426d8f6f1 100644 --- a/src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c +++ b/src/modules/fw_pos_control_l1/fw_pos_control_l1_params.c @@ -328,6 +328,23 @@ PARAM_DEFINE_FLOAT(FW_LND_HHDIST, 15.0f); */ PARAM_DEFINE_INT32(FW_LND_USETER, 0); +/** + * Early landing configuration deployment + * + * When set to 0/disabled, the landing configuration (flaps, landing airspeed, etc.) is only activated + * on the final approach to landing. When set to 1/enabled, it is already activated when entering the + * final loiter-down (loiter-to-alt) WP before the landing approach. This shifts the (often large) + * altitude and airspeed errors caused by the configuration change away from the ground such that + * these are not so critical. It also gives the controller enough time to adapt to the new + * configuration such that the landing approach starts with a cleaner initial state. + * + * @value 0 Disable early land configuration deployment + * @value 1 Enable early land configuration deployment + * + * @group FW L1 Control + */ +PARAM_DEFINE_INT32(FW_LND_EARLYCFG, 1); + /** * Flare, minimum pitch * @@ -386,7 +403,7 @@ PARAM_DEFINE_FLOAT(FW_LND_AIRSPD_SC, 1.3f); * @min 0.2 * @max 1.0 * @increment 0.1 - * @group FW TECS + * @group FW L1 Control */ PARAM_DEFINE_FLOAT(FW_LND_THRTC_SC, 1.0f);