Skip to content

Commit 13122c2

Browse files
authored
Fix simulated gimbal behavior with zero velocity (#25217)
* fix simulated gimbal behavior with zero velocity * check for PX4_ISFINITE before checking for magnitude
1 parent 8dd14d9 commit 13122c2

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

src/modules/simulation/gz_bridge/GZGimbal.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,11 @@ float GZGimbal::computeJointSetpoint(const float att_stp, const float rate_stp,
240240
{
241241

242242
if (PX4_ISFINITE(rate_stp)) {
243+
if (math::abs_t(rate_stp) < FLT_EPSILON) {
244+
// Handle zero velocity by sending the last target angle
245+
return last_stp;
246+
}
247+
243248
const float rate_diff = dt * rate_stp;
244249
const float stp_from_rate = last_stp + rate_diff;
245250

0 commit comments

Comments
 (0)