Skip to content

generator/C: clamp asin argument in mavlink_dcm_to_euler#1208

Open
g-ampo wants to merge 1 commit into
ArduPilot:masterfrom
g-ampo:fix/2389-clamp-asin-pitch
Open

generator/C: clamp asin argument in mavlink_dcm_to_euler#1208
g-ampo wants to merge 1 commit into
ArduPilot:masterfrom
g-ampo:fix/2389-clamp-asin-pitch

Conversation

@g-ampo

@g-ampo g-ampo commented Apr 25, 2026

Copy link
Copy Markdown

Closes mavlink/mavlink#2389.

asin(-dcm[2][0]) returns NaN when FP rounding pushes the argument outside [-1, 1]. Clamps the argument in both v1.0 and v2.0 helpers, matching the existing clamp in pymavlink/quaternion.py.

@g-ampo

g-ampo commented Apr 27, 2026

Copy link
Copy Markdown
Author

@peterbarker @tridge could you review this when you have a moment? It resolves the NaN pitch bug reported in mavlink/mavlink#2389

cc @DonLakeFlyer - A fix for your issue is ready for testing here.

FP rounding in mavlink_quaternion_to_dcm can push dcm[2][0] outside
[-1, 1], making asin return NaN. Mirrors the clamp in
pymavlink/quaternion.py.

Refs: mavlink/mavlink#2389
@g-ampo g-ampo force-pushed the fix/2389-clamp-asin-pitch branch from 269d694 to 71179f9 Compare May 25, 2026 17:41
@g-ampo g-ampo requested a review from tridge May 25, 2026 17:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mavlink_quaternion_to_euler returning nan for pitch value

2 participants