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:
Nathaniel-hl
2026-06-05 20:39:34 +08:00
committed by GitHub
parent bf1e2278a7
commit 2ff2d174c0

View File

@@ -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