Skip to content

Parameter export silently corrupts values smaller than 1e-6 due to .6f truncation #1400

@yashhzd

Description

@yashhzd

Bug Description

format_params() in data_model_par_dict.py (lines 258, 260, 268, 270) uses .6f (6 decimal places) to format parameter values. This silently truncates any value smaller than 1e-6 to "0":

>>> format(0.0000001, '.6f').rstrip('0').rstrip('.')
'0'        # value LOST

>>> format(0.0000005, '.6f').rstrip('0').rstrip('.')
'0'        # value LOST

>>> format(0.000001, '.6f').rstrip('0').rstrip('.')
'0.000001' # OK

ArduPilot firmware parameters are IEEE 754 single-precision floats that can hold values down to ~1.2e-38. A save→load cycle silently corrupts any parameter whose value is less than 1e-6.

Steps to Reproduce

  1. Set a parameter to a value like 0.0000001 (1e-7)
  2. Export parameters via MissionPlanner or MAVProxy format
  3. Reload the exported file
  4. The parameter value is now 0data loss

Expected Behavior

Small but nonzero parameter values should survive a save→load round-trip without silent data loss.

Proposed Fix

Change .6f.10f in both the MissionPlanner and MAVProxy format paths of _format_params().

.10f with .rstrip('0').rstrip('.') preserves all float32 significant digits (~7–8 decimal digits) while staying in decimal notation (no scientific notation that might break external tools).

# Before fix: silent data loss
format(0.0000001, '.6f').rstrip('0').rstrip('.')   # → "0"

# After fix: value preserved
format(0.0000001, '.10f').rstrip('0').rstrip('.')  # → "0.0000001"

Affected Code

  • ardupilot_methodic_configurator/data_model_par_dict.py — lines 258, 260, 268, 270 in _format_params()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions