mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-08-01 20:27:57 +08:00
fix(vtol): prevent divide-by-zero in tiltrotor transition weight (#27437)
fix-divide-by-zero-in-mc_roll_weight Co-authored-by: Drone-Lab <151698793+drone-lab@users.noreply.github.com>
This commit is contained in:
@@ -251,17 +251,23 @@ void Tiltrotor::update_transition_state()
|
||||
_mc_roll_weight = 1.0f;
|
||||
_mc_yaw_weight = 1.0f;
|
||||
|
||||
if (PX4_ISFINITE(_attc->get_calibrated_airspeed()) &&
|
||||
const float airspeed_trans_blend_margin = getTransitionAirspeed() - getBlendAirspeed();
|
||||
|
||||
if (airspeed_trans_blend_margin > FLT_EPSILON &&
|
||||
PX4_ISFINITE(_attc->get_calibrated_airspeed()) &&
|
||||
_attc->get_calibrated_airspeed() >= getBlendAirspeed()) {
|
||||
_mc_roll_weight = 1.0f - (_attc->get_calibrated_airspeed() - getBlendAirspeed()) /
|
||||
(getTransitionAirspeed() - getBlendAirspeed());
|
||||
airspeed_trans_blend_margin;
|
||||
}
|
||||
|
||||
// without airspeed do timed weight changes
|
||||
const float time_trans_open_loop_margin = getOpenLoopFrontTransitionTime() - getMinimumFrontTransitionTime();
|
||||
|
||||
if ((!PX4_ISFINITE(_attc->get_calibrated_airspeed())) &&
|
||||
time_trans_open_loop_margin > FLT_EPSILON &&
|
||||
_time_since_trans_start > getMinimumFrontTransitionTime()) {
|
||||
_mc_roll_weight = 1.0f - (_time_since_trans_start - getMinimumFrontTransitionTime()) /
|
||||
(getOpenLoopFrontTransitionTime() - getMinimumFrontTransitionTime());
|
||||
time_trans_open_loop_margin;
|
||||
}
|
||||
|
||||
// add minimum throttle for front transition
|
||||
|
||||
Reference in New Issue
Block a user