<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Platform-Specific PX4 Bug - Incorrect Evaluation of NaN]]></title><description><![CDATA[<p dir="auto">Hardware - VOXL2<br />
Software version - up to SDK 1.4.0</p>
<p dir="auto">I identified what could be a significant bug when attempting to implement offboard control via acceleration setpoints in px4 on voxl2.  See this post for complete details:</p>
<p dir="auto"></p><div class="card col-md-9 col-lg-6 position-relative link-preview p-0">



<a href="https://discuss.px4.io/t/ros2-offboard-transitioning-from-position-to-acceleration-setpoints/44552/2" title="ROS2 Offboard - Transitioning from Position to Acceleration Setpoints">
<img src="https://discuss.px4.io/uploads/default/original/2X/8/8e57a75c46cb1671adfbeafd161616d7a26a0e01.jpeg" class="card-img-top not-responsive" style="max-height:15rem" alt="Link Preview Image" />
</a>



<div class="card-body">
<h5 class="card-title">
<a class="text-decoration-none" href="https://discuss.px4.io/t/ros2-offboard-transitioning-from-position-to-acceleration-setpoints/44552/2">
ROS2 Offboard - Transitioning from Position to Acceleration Setpoints
</a>
</h5>
<p class="card-text line-clamp-3">Hello. 
I’m implementing a ROS2 offboard control package to fly a dev drone running PX4 (v1.14).  I have it set up so that I publish offboard_control_mode messages with the position flag set true and publish trajectory_s…</p>
</div>
<a href="https://discuss.px4.io/t/ros2-offboard-transitioning-from-position-to-acceleration-setpoints/44552/2" class="card-footer text-body-secondary small d-flex gap-2 align-items-center lh-2">



<img src="https://discuss.px4.io/uploads/default/optimized/3X/7/9/794d5770bb17c3874a76d5762197c22566e4d91d_2_32x32.png" alt="favicon" class="not-responsive overflow-hiddden" style="max-width:21px;max-height:21px" />





<p class="d-inline-block text-truncate mb-0">Dronecode Forum | Open Source Drone Development <span class="text-secondary">(discuss.px4.io)</span></p>
</a>
</div><p></p>
<p dir="auto">TLDR: acceleration control doesn't work because a constrain function in the MC position control code incorrectly clamps a value of NaN for vz (set in trajectory_setpoint.vz field from an external controller) to the downward velocity limit.  This only occurs on VOXL2, not in px4_sitl built from the same firmware but running on my laptop.</p>
<p dir="auto">I resolved the issue by wrapping the specific constrain function in a call to PX4_ISFINITE which just calls __builtin_isfinite(), but this raises the question of why is NaN being evaluated incorrectly within the constrain function and could checks on NaN be failing silently elsewhere in the control stack and causing other hard to track issues.</p>
<p dir="auto">IDK if this is being caused by a compiler flag set specifically for voxl2, it's inherent to the QRB5165 hardware, or if this issue would apply to all ARM devices.  Can someone take a look and provide some feedback?</p>
]]></description><link>https://forum.modalai.com/topic/5320/platform-specific-px4-bug-incorrect-evaluation-of-nan</link><generator>RSS for Node</generator><lastBuildDate>Wed, 15 Jul 2026 22:01:29 GMT</lastBuildDate><atom:link href="https://forum.modalai.com/topic/5320.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 15 Jul 2026 16:08:33 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Platform-Specific PX4 Bug - Incorrect Evaluation of NaN on Wed, 15 Jul 2026 19:23:34 GMT]]></title><description><![CDATA[<p dir="auto">This is the commit that I'm planning to propagate: <a href="https://github.com/modalai/px4-firmware/commit/c4fd40afc9f0c79a83a633023013f11b1185cf23" rel="nofollow ugc">https://github.com/modalai/px4-firmware/commit/c4fd40afc9f0c79a83a633023013f11b1185cf23</a></p>
]]></description><link>https://forum.modalai.com/post/26386</link><guid isPermaLink="true">https://forum.modalai.com/post/26386</guid><dc:creator><![CDATA[Eric Katzfey]]></dc:creator><pubDate>Wed, 15 Jul 2026 19:23:34 GMT</pubDate></item><item><title><![CDATA[Reply to Platform-Specific PX4 Bug - Incorrect Evaluation of NaN on Wed, 15 Jul 2026 18:41:18 GMT]]></title><description><![CDATA[<p dir="auto">So, unfortunately, it does look like a compiler issue. Fixing the math::constrain function with an explicit NaN check is probably the most reasonable thing to do in the short term.</p>
]]></description><link>https://forum.modalai.com/post/26385</link><guid isPermaLink="true">https://forum.modalai.com/post/26385</guid><dc:creator><![CDATA[Eric Katzfey]]></dc:creator><pubDate>Wed, 15 Jul 2026 18:41:18 GMT</pubDate></item><item><title><![CDATA[Reply to Platform-Specific PX4 Bug - Incorrect Evaluation of NaN on Wed, 15 Jul 2026 18:39:39 GMT]]></title><description><![CDATA[<p dir="auto">This is from the analysis done by Codex:</p>
<pre><code>  For the original ternary helper:

  return (value &lt; lower_bound) ? lower_bound : ((value &gt; upper_bound) ? upper_bound : value);

  Hexagon codegen emits:

  p0 = sfcmp.uo(r2,r0)        // unordered check: lower vs value
  p1 = sfcmp.gt(r2,r0)        // lower &gt; value
  r0 = sfmin(r0,r3)           // r0 = min(value, upper)
  p0 = and(p1,!p0)
  if (p0) r0 = lower
  jumpr r31

  The key instruction is:

  r0 = sfmin(r0,r3)

  where r0 is the input value and r3 is 1.0f.

  On this DSP, sfmin(NaN, 1.0f) returns 1.0f, so the upper-bound half of the clamp converts NaN into the
  upper bound. That matches:

  nan_math original_pattern=3f800000

  So the heart of the issue is now very specific: the compiler lowers the upper clamp branch into sfmin, and
  the Hexagon sfmin NaN behavior does not match the C++ comparison/ternary behavior PX4 expects.

</code></pre>
]]></description><link>https://forum.modalai.com/post/26384</link><guid isPermaLink="true">https://forum.modalai.com/post/26384</guid><dc:creator><![CDATA[Eric Katzfey]]></dc:creator><pubDate>Wed, 15 Jul 2026 18:39:39 GMT</pubDate></item><item><title><![CDATA[Reply to Platform-Specific PX4 Bug - Incorrect Evaluation of NaN on Wed, 15 Jul 2026 18:32:48 GMT]]></title><description><![CDATA[<p dir="auto">I can replicate the math::constrain issue you are seeing so looking at the best way to resolve that.</p>
]]></description><link>https://forum.modalai.com/post/26383</link><guid isPermaLink="true">https://forum.modalai.com/post/26383</guid><dc:creator><![CDATA[Eric Katzfey]]></dc:creator><pubDate>Wed, 15 Jul 2026 18:32:48 GMT</pubDate></item><item><title><![CDATA[Reply to Platform-Specific PX4 Bug - Incorrect Evaluation of NaN on Wed, 15 Jul 2026 17:57:01 GMT]]></title><description><![CDATA[<p dir="auto">Can you provide a PX4 log of the scenario from a flight with VOXL2 and a log of the same (similar) scenario from SITL?</p>
]]></description><link>https://forum.modalai.com/post/26382</link><guid isPermaLink="true">https://forum.modalai.com/post/26382</guid><dc:creator><![CDATA[Eric Katzfey]]></dc:creator><pubDate>Wed, 15 Jul 2026 17:57:01 GMT</pubDate></item></channel></rss>