Fix simulated gimbal behavior with zero velocity (#25217)

* fix simulated gimbal behavior with zero velocity

* check for PX4_ISFINITE before checking for magnitude
This commit is contained in:
William Freidank 2025-07-21 16:59:55 -04:00 committed by GitHub
parent 8dd14d9aaa
commit 13122c29c0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -240,6 +240,11 @@ float GZGimbal::computeJointSetpoint(const float att_stp, const float rate_stp,
{
if (PX4_ISFINITE(rate_stp)) {
if (math::abs_t(rate_stp) < FLT_EPSILON) {
// Handle zero velocity by sending the last target angle
return last_stp;
}
const float rate_diff = dt * rate_stp;
const float stp_from_rate = last_stp + rate_diff;