Skip to content

fix(simulation): clamp simulated FIFO accel/gyro samples to int16#27927

Open
Bartok9 wants to merge 1 commit into
PX4:mainfrom
Bartok9:salvage/sim-fifo-int16-clamp-27864
Open

fix(simulation): clamp simulated FIFO accel/gyro samples to int16#27927
Bartok9 wants to merge 1 commit into
PX4:mainfrom
Bartok9:salvage/sim-fifo-int16-clamp-27864

Conversation

@Bartok9

@Bartok9 Bartok9 commented Jul 16, 2026

Copy link
Copy Markdown
Contributor

Summary

Salvage of draft CONFLICTING #27864 by @farhangnaderi. Clamp simulated FIFO accel/gyro samples with math::constrainFloatToInt16 so float→int16 saturates instead of wrapping (inverted gyro at high rates).

Motivation

#27864 useful but CONFLICTING after SimulatorMavlink FIFO refactor. Rebased on main with stock math helper.

Related

Fixes #23469. Salvages #27864 (credit @farhangnaderi).

Verification

Simulation HIL FIFO id==0 only; no flight safety path changes. AI-assisted rebase; human-reviewed.

Co-authored-by: Farhang Naderi farhangnaderi@users.noreply.github.com

salvage of PX4#27864 (credit @farhangnaderi). Prevents float-to-int16 wrap in
SimulatorMavlink FIFO path so high-rate sim no longer inverts gyro/accel.

Uses math::constrainFloatToInt16 for stock PX4 style.

Fixes PX4#23469.

Co-authored-by: Farhang Naderi <farhangnaderi@users.noreply.github.com>
AI-assisted; human-reviewed.
@github-actions github-actions Bot added the scope:simulation SITL, Gazebo, jmavsim, lockstep, or simulated sensors. label Jul 16, 2026
@Bartok9 Bartok9 changed the title salvage: fix(simulation): clamp FIFO accel/gyro samples to int16 (credit @farhangnaderi #27864) fix(simulation): clamp FIFO accel/gyro samples to int16 (salvage, credit @farhangnaderi #27864) Jul 16, 2026
@github-actions github-actions Bot added the kind:bug Something is broken or behaving incorrectly. label Jul 16, 2026
@Bartok9 Bartok9 changed the title fix(simulation): clamp FIFO accel/gyro samples to int16 (salvage, credit @farhangnaderi #27864) fix(simulation): clamp simulated FIFO accel/gyro samples to int16 Jul 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:bug Something is broken or behaving incorrectly. scope:simulation SITL, Gazebo, jmavsim, lockstep, or simulated sensors.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Simulated gyro sensor data gets inverted at fast rates

1 participant