Skip to content

Commit

Permalink
FixedWingPositionControl: compensate minimum sink rate for weight and…
Browse files Browse the repository at this point in the history
… density

Signed-off-by: RomanBapst <[email protected]>
  • Loading branch information
RomanBapst committed Sep 6, 2023
1 parent f847586 commit d6a770a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/modules/fw_pos_control/FixedwingPositionControl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,21 @@ FixedwingPositionControl::init()
return true;
}

float FixedwingPositionControl::getMaximumClimbRate()
float FixedwingPositionControl::getWeightRatio()
{

float weight_factor = 1.0f;

if (_param_weight_base.get() > 0.0f && _param_weight_gross.get() > 0.0f) {
weight_factor = math::constrain(_param_weight_base.get() / _param_weight_gross.get(), MIN_WEIGHT_RATIO,
weight_factor = math::constrain(_param_weight_gross.get() / _param_weight_base.get(), MIN_WEIGHT_RATIO,
MAX_WEIGHT_RATIO);
}

return weight_factor;
}

float FixedwingPositionControl::getMaximumClimbRate()
{
float climbrate_max = _param_fw_t_clmb_max.get();

const float density_min = _param_density_min.get();
Expand All @@ -116,7 +121,12 @@ float FixedwingPositionControl::getMaximumClimbRate()
climbrate_max = _param_fw_t_clmb_max.get() + density_gradient * delta_rho;
}

return climbrate_max * weight_factor;
return climbrate_max / getWeightRatio();
}

float FixedwingPositionControl::getMinimumSinkRate()
{
return _param_fw_t_sink_min.get() * sqrtf(getWeightRatio() * CONSTANTS_AIR_DENSITY_SEA_LEVEL_15C / _air_density);
}

int
Expand Down
17 changes: 17 additions & 0 deletions src/modules/fw_pos_control/FixedwingPositionControl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,24 @@ class FixedwingPositionControl final : public ModuleBase<FixedwingPositionContro
*/
float get_terrain_altitude_takeoff(float takeoff_alt);

/**
* @brief Return the maximum climb rate achievable under the current conditions.
* @return Maximum climbrate.
*/
float getMaximumClimbRate();

/**
* @brief Return the minimum sink rate achievable under the current conditions.
* @return Minimum sink rate.
*/
float getMinimumSinkRate();

/**
* @brief Return the ratio of actual vehicle weight to vehicle base weight.
* @return Weight ratio.
*/
float getWeightRatio();

/**
* @brief Maps the manual control setpoint (pilot sticks) to height rate commands
*
Expand Down

0 comments on commit d6a770a

Please sign in to comment.