ArduPilot / MissionPlanner

Mission Planner Ground Control Station for ArduPilot (c# .net)
http://ardupilot.org/planner/
GNU General Public License v3.0
1.75k stars 2.38k forks source link

Log Browser: distinguish between NaN and QuietNan #2642

Open rmackay9 opened 3 years ago

rmackay9 commented 3 years ago

Although I'm not a huge fan of the behaviour, AP logs a "Quiet NaN" in cases where it does not have a value. The current example I'm looking at is Copter's CTUN.DSAlt field which is the "Desired Sonar Altitude" used for surface tracking.

I'm investigating a surface tracking failure and I can't tell if the NaN shown in this field is a result of a calculation error or the expected "Quiet NaN".

MAVProxy apparently displays "QNaN" for quiet NaN allowing them to be distinguished fro the calculation error NaNs and @peterbarker provided this code snippet:

 if isinstance(val, float) and math.isnan(val):
                # quiet nans have more non-zero values:
                noisy_nan = "\x7f\xf8\x00\x00\x00\x00\x00\x00"
                if struct.pack(">d", val) != noisy_nan:
                    val = "qnan"
            ret += "%s : %s, " % (c, val)

I'll provide a sample log file to @meee1 directly.

peterbarker commented 3 years ago

Sample log is here: https://github.com/ArduPilot/ardupilot/tree/master/libraries/AP_Logger/examples/AP_Logger_AllTypes

The NANS message contains both nan and qnan values. ("b" meaning "bad" on the field name, I believe)