Files
PX4-Autopilot/Tools/migrate_param_file.py
T
Ahmet Burak Tektas 06036f2163 feat(tools): add a script to convert v1.17 parameter files for v1.18 (#29363)
* feat(tools): add a script to convert v1.17 parameter files for v1.18

param_translation.cpp converts renamed parameters only when PX4 upgrades
the parameters stored on the vehicle. QGroundControl loads a .params
file parameter by parameter, so values saved under old names are
ignored, and RC*_REV saved as -1.000000 load as 0 into the now integer
parameters. The script applies the same conversions to the file.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: A.Burak Tektas <15087318+Abtektas@users.noreply.github.com>

* fix(tools): keep the v1.18 heater sensor default in converted files

A v1.17 vehicle does not store SENS_TEMP_ID at its default of 0, so the
upgrade never converts it and HEATER1_SENS_ID keeps its v1.18 default,
the board's sensor or auto-select. The script wrote -1 instead, which
disables the heater on boards that v1.18 heats by default.

Also list EKF2_REQ_PDOP, which v1.18 raises to 4 on fixed-wing, log
integer values without an exponent, end a copied line that has no
newline before the parameters follow it, and say what the translation
test catches.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: A.Burak Tektas <15087318+Abtektas@users.noreply.github.com>

* docs(releases): link the v1.17 parameter file script in 1.18 notes

Item 13 tells users to check a parameter file saved on v1.17 by hand.
Point them to Tools/migrate_param_file.py, which converts such a file.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: A.Burak Tektas <15087318+Abtektas@users.noreply.github.com>

* fix(tools): convert the v1.17 auxiliary global position parameters

param_translation.cpp moves EKF2_AGP_CTRL, _MODE, _DELAY, _NOISE and
_GATE to the first source set, EKF2_AGP0_*, and sets EKF2_AGP0_ID to 1
when EKF2_AGP_CTRL is set. The script listed them as removed, so a
converted file came out with aux global position fusion disabled.

Convert them the same way. QGroundControl lists EKF2_AGP0_* only once
EKF2_AGP0_ID is set and the vehicle reboots, so the script and item 13
of the 1.18 notes say to load the file again after a reboot.
EKF2_AGP_NOISE at 0.9 is listed as a v1.17 default (1.0 in v1.18).

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: A.Burak Tektas <15087318+Abtektas@users.noreply.github.com>

* fix(tools): replace the v1.17 RoboClaw output defaults

The RoboClaw outputs moved from 0 to 256 with stop at 128 to 0 to 254
with stop at 127. A saved file holds the v1.17 defaults, and the script
kept them: RBCLW_DIS 128 drives the motors forward at speed 1 while
disarmed, and RBCLW_MAX 256 is above the v1.18 maximum of 254.

At their v1.17 defaults RBCLW_DIS, _MIN and _MAX now get the v1.18
default, as after an upgrade of the parameters stored on the vehicle,
since the firmware does not store defaults. Other RBCLW_DIS, _MIN, _MAX
and _FAIL values are kept and listed for a check.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: A.Burak Tektas <15087318+Abtektas@users.noreply.github.com>

* fix(tools): drop the reload after a reboot for EKF2_AGP0_*

QGroundControl sends the rows of a .params file that the vehicle does not
list as new parameters, since the file holds their types, and PX4
accepts PARAM_SET for any parameter in its table. So EKF2_AGP0_* are set
on the first load, and the note to load the file again after a reboot
is wrong. Only a Mission Planner file, which has no types, cannot send
them.

Remove the note from the script and from item 13 of the 1.18 notes.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: A.Burak Tektas <15087318+Abtektas@users.noreply.github.com>

* fix(tools): list the X25-EVO core heater and other components

- CORE_IMU_TEMP, _FF, _I, _P and CORE_TEMP_ID of the CUAV X25-EVO core
  heater are gone in v1.18 without a translation, the board now uses
  HEATER2_*. They passed through unlisted; list them as removed with
  the HEATER2_* parameter to set.
- rc.boat_defaults still sets NAV_ACC_RAD 2, so the note that v1.18 uses
  10 applies to multicopters only.
- A vehicle with MAV_COMP_ID other than 1 saves its parameters under
  that component, so the script converted nothing and said nothing.
  Warn when the file has no parameters of component 1.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: A.Burak Tektas <15087318+Abtektas@users.noreply.github.com>

* fix(tools): list board defaults changed on Skynode and i.MX RT

A saved v1.17 file holds the v1.17 board defaults, and v1.18 changed
some of them:
- On Skynode the fmu-v5x defaults set EKF2_MULTI_IMU 0 and
  SENS_IMU_MODE 1, since it is too loaded for the three EKF instances of
  the STM32F7 defaults (3 and 0).
- The i.MX RT defaults match fmu-v6x: EKF2_MULTI_IMU 3, SENS_IMU_MODE 0,
  IMU_GYRO_FFT_EN 1 and UAVCAN_ENABLE 2, where v1.17 used 0, 1, 0 and 0.

List these values as v1.17 defaults with the boards they apply to. One
parameter can change differently on each set of boards.

Airframes 4016, 4020 and 24001 still set NAV_ACC_RAD 2 in v1.18, so name
them in the multicopter note.

Assisted-by: Claude:claude-opus-5-5
Signed-off-by: A.Burak Tektas <15087318+Abtektas@users.noreply.github.com>

---------

Signed-off-by: A.Burak Tektas <15087318+Abtektas@users.noreply.github.com>
2026-11-06 10:44:27 -07:00

387 lines
16 KiB
Python
Executable File

#!/usr/bin/env python3
############################################################################
#
# Copyright (c) 2026 PX4 Development Team. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the
# distribution.
# 3. Neither the name PX4 nor the names of its contributors may be
# used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
"""Convert a parameter file saved on PX4 v1.17 for loading on v1.18.
param_translation.cpp converts renamed parameters only when PX4 upgrades
the parameters stored on the vehicle. Loading a .params file in
QGroundControl sets each parameter by name, so values saved under old
names are ignored. This script applies the same conversions to a
QGroundControl .params file, writes RC*_REV as integers (QGroundControl
loads a saved -1.000000 into the now integer parameter as 0), and drops
the parameters v1.18 no longer has, listing each one on stderr.
A saved file also holds the v1.17 defaults. Values still at a v1.17
default that v1.18 changed are kept and listed, so they can be reviewed.
The RoboClaw output defaults, whose scale changed, get the v1.18 default,
as after an upgrade of the parameters stored on the vehicle.
Check the converted file before loading it.
Examples:
Tools/migrate_param_file.py saved.params converted.params
"""
import argparse
import struct
import sys
AUTOPILOT_COMPONENT = 1
MAV_PARAM_TYPE_INT32 = 6
MAV_PARAM_TYPE_REAL32 = 9
# Conversions of param_translation.cpp from v1.17 to v1.18.
# old name: (kind, new name(s), argument)
CONVERSIONS = {
'EKF2_GPS_POS_X': ('rename', 'SENS_GPS0_OFFX', None),
'EKF2_GPS_POS_Y': ('rename', 'SENS_GPS0_OFFY', None),
'EKF2_GPS_POS_Z': ('rename', 'SENS_GPS0_OFFZ', None),
'EKF2_GPS_DELAY': ('copy_int',
('SENS_GPS0_DELAY', 'SENS_GPS1_DELAY'), None),
'MNT_RANGE_PITCH': ('half_range',
('MNT_MAX_PITCH', 'MNT_MIN_PITCH'), None),
'MOT_POLE_COUNT': ('copy_int',
tuple(f'DSHOT_MOT_POL{i}' for i in range(1, 13)),
None),
# only "disabled" is converted
'COM_RC_OVERRIDE': ('if_zero_set', 'MAN_OVERRIDE_SPD', -1.0),
'SENS_IMU_TEMP': ('rename', 'HEATER1_TEMP', None),
'SENS_IMU_TEMP_FF': ('rename', 'HEATER1_TEMP_FF', None),
'SENS_IMU_TEMP_I': ('rename', 'HEATER1_TEMP_I', None),
'SENS_IMU_TEMP_P': ('rename', 'HEATER1_TEMP_P', None),
# SENS_TEMP_ID 0 is the v1.17 default, which the vehicle does not store,
# so the upgrade leaves HEATER1_SENS_ID at its v1.18 default (the file
# cannot show a 0 stored over a board default, which becomes -1)
'SENS_TEMP_ID': ('if_nonzero_rename_int', 'HEATER1_SENS_ID', None),
# landing nudging is bit 1 of MPC_AUTO_NUDGING (v1.18 default 0)
'MPC_LAND_RC_HELP': ('if_nonzero_set_bit', 'MPC_AUTO_NUDGING', 1),
# the first source slot only fuses messages with id EKF2_AGP0_ID, which
# is set to 1 (the id v1.17 sources arrive with) when fusion was enabled
'EKF2_AGP_CTRL': ('rename_if_nonzero_set',
('EKF2_AGP0_CTRL', 'EKF2_AGP0_ID'), 1),
'EKF2_AGP_MODE': ('rename', 'EKF2_AGP0_MODE', None),
'EKF2_AGP_DELAY': ('rename', 'EKF2_AGP0_DELAY', None),
'EKF2_AGP_NOISE': ('rename', 'EKF2_AGP0_NOISE', None),
'EKF2_AGP_GATE': ('rename', 'EKF2_AGP0_GATE', None),
}
# Types of the parameters the conversions write
NEW_TYPES = {
'SENS_GPS0_OFFX': MAV_PARAM_TYPE_REAL32,
'SENS_GPS0_OFFY': MAV_PARAM_TYPE_REAL32,
'SENS_GPS0_OFFZ': MAV_PARAM_TYPE_REAL32,
'SENS_GPS0_DELAY': MAV_PARAM_TYPE_INT32,
'SENS_GPS1_DELAY': MAV_PARAM_TYPE_INT32,
'MNT_MAX_PITCH': MAV_PARAM_TYPE_REAL32,
'MNT_MIN_PITCH': MAV_PARAM_TYPE_REAL32,
**{f'DSHOT_MOT_POL{i}': MAV_PARAM_TYPE_INT32 for i in range(1, 13)},
'MAN_OVERRIDE_SPD': MAV_PARAM_TYPE_REAL32,
'HEATER1_TEMP': MAV_PARAM_TYPE_REAL32,
'HEATER1_TEMP_FF': MAV_PARAM_TYPE_REAL32,
'HEATER1_TEMP_I': MAV_PARAM_TYPE_REAL32,
'HEATER1_TEMP_P': MAV_PARAM_TYPE_REAL32,
'HEATER1_SENS_ID': MAV_PARAM_TYPE_INT32,
'MPC_AUTO_NUDGING': MAV_PARAM_TYPE_INT32,
'EKF2_AGP0_CTRL': MAV_PARAM_TYPE_INT32,
'EKF2_AGP0_ID': MAV_PARAM_TYPE_INT32,
'EKF2_AGP0_MODE': MAV_PARAM_TYPE_INT32,
'EKF2_AGP0_DELAY': MAV_PARAM_TYPE_REAL32,
'EKF2_AGP0_NOISE': MAV_PARAM_TYPE_REAL32,
'EKF2_AGP0_GATE': MAV_PARAM_TYPE_REAL32,
}
# RC*_REV changed from float to int32
REVERSE_PARAMS = {f'RC{i}_REV' for i in range(1, 19)}
_SEE_LIGHTS = 'see UAVCAN_LGT_MODE, UAVCAN_LGT_NUM, UAVCAN_LGT_IDn/FNn'
# Parameters removed in v1.18 without a conversion: name: hint
REMOVED = {
'ASPD_BETA_GATE': '', 'ASPD_BETA_NOISE': '', 'ASPD_SCALE_NSD': '',
'ASPD_TAS_GATE': '',
'BAT1_I_CHANNEL': '', 'BAT2_I_CHANNEL': '', 'BAT_ADC_CHANNEL': '',
'COM_ARM_SDCARD': '', 'COM_DISARM_MAN': '', 'COM_FLT_PROFILE': '',
'COM_HLDL_REG_T': '', 'COM_IMB_PROP_ACT': 'see FD_IMB_PROP_THR',
'COM_KILL_DISARM': '', 'COM_LKDOWN_TKO': '', 'COM_MOT_TEST_EN': '',
'COM_OBC_LOSS_T': '', 'COM_RC_ARM_HYST': '',
'COM_RC_STICK_OV': 'see MAN_OVERRIDE_SPD (stick speed in 1/s)',
'COM_TAKEOFF_ACT': '',
# CUAV X25-EVO core heater, now the second heater instance
'CORE_IMU_TEMP': 'see HEATER2_TEMP',
'CORE_IMU_TEMP_FF': 'see HEATER2_TEMP_FF',
'CORE_IMU_TEMP_I': 'see HEATER2_TEMP_I',
'CORE_IMU_TEMP_P': 'see HEATER2_TEMP_P',
'CORE_TEMP_ID': 'see HEATER2_SENS_ID',
'DSHOT_BIDIR_EN': 'choose BDShot in PWM_MAIN_TIMn / PWM_AUX_TIMn',
'FD_ACT_MOT_C2T': 'see MOTFAIL_C2T and MOTFAIL_OFF',
'FD_ACT_MOT_THR': '',
'FD_ACT_MOT_TOUT': 'see MOTFAIL_TIME (in s)',
'FD_ESCS_EN': 'see FD_ACT_EN',
'FW_AT_START': '', 'FW_T_SPD_DEV_STD': '', 'FW_T_SPD_PRC_STD': '',
'FW_T_SPD_STD': '', 'GF_PREDICT': '', 'INA226_CONFIG': '',
'LNDMC_TRIG_TIME': '', 'MC_AT_START': '',
'MNT_OFF_PITCH': 'use the output trim',
'MNT_OFF_ROLL': 'use the output trim',
'MNT_OFF_YAW': 'use the output trim',
'MPC_USE_HTE': '', 'SIM_ARSPD_FAIL': '',
'SIM_BAT_ENABLE': 'see SIM_BAT_DRAIN',
'UAVCAN_LGT_ANTCL': _SEE_LIGHTS, 'UAVCAN_LGT_LAND': _SEE_LIGHTS,
'UAVCAN_LGT_NAV': _SEE_LIGHTS, 'UAVCAN_LGT_STROB': _SEE_LIGHTS,
}
# Defaults changed in v1.18: name: (v1.17 default, v1.18 default)
# A converted parameter is listed under its v1.17 name.
DEFAULT_CHANGES = {
'EKF2_AGP_NOISE': (0.9, 1.0),
'FD_ACT_EN': (1, 0),
'FW_T_HRATE_FF': (0.3, 0.5),
'MPC_LAND_RADIUS': (1000.0, -1.0),
'SENS_MAG_AUTOCAL': (1, 0),
'VT_LND_PITCH_MIN': (-5.0, 0.0),
'VT_PITCH_MIN': (-5.0, 0.0),
# set by the v1.18 fixed-wing defaults, still 2.5 for other vehicles
'EKF2_REQ_PDOP': (2.5, 4.0),
# set by the v1.17 multicopter defaults, no longer in v1.18 (boats and
# airframes 4016, 4020 and 24001 keep 2)
'NAV_ACC_RAD': (2.0, 10.0),
}
# Defaults that v1.18 changed for some vehicles only
DEFAULT_CHANGE_SCOPES = {
'EKF2_REQ_PDOP': 'on fixed-wing',
'NAV_ACC_RAD': ('on multicopter, except airframes 4016, 4020 and 24001,'
' which keep 2'),
}
_SKYNODE = 'on Skynode'
_IMXRT = 'on i.MX RT boards (fmu-v6xrt, mr-tropic, tropic-community)'
# Defaults that the v1.18 board or chip defaults changed on some boards:
# name: [(v1.17 default, v1.18 default, scope)]
BOARD_DEFAULT_CHANGES = {
# Skynode (fmu-v5x) runs a single EKF in v1.18 instead of the three of
# the STM32F7 defaults. The i.MX RT defaults now match fmu-v6x.
'EKF2_MULTI_IMU': [(3, 0, _SKYNODE), (0, 3, _IMXRT)],
'SENS_IMU_MODE': [(0, 1, _SKYNODE), (1, 0, _IMXRT)],
'IMU_GYRO_FFT_EN': [(0, 1, _IMXRT)],
'UAVCAN_ENABLE': [(0, 2, _IMXRT)],
}
# RoboClaw outputs: 0 to 256 with stop at 128 in v1.17, 0 to 254 with stop
# at 127 in v1.18. In v1.18 the v1.17 defaults are out of range or one
# step off (DIS 128 drives forward while disarmed), so they are replaced:
# name: (v1.17 default, v1.18 default)
REPLACED_DEFAULTS = {
'RBCLW_DIS1': (128, 127), 'RBCLW_DIS2': (128, 127),
'RBCLW_MAX1': (256, 254), 'RBCLW_MAX2': (256, 254),
'RBCLW_MIN1': (1, 0), 'RBCLW_MIN2': (1, 0),
}
_RBCLW_SCALE = ('RoboClaw outputs use 0 to 254 with stop at 127 in v1.18'
' (v1.17: 0 to 256, stop at 128)')
# Parameters whose other values need a check: name: (value to skip, note)
SCALE_CHECKS = {
**{name: (None, _RBCLW_SCALE) for name in REPLACED_DEFAULTS},
'RBCLW_FAIL1': (-1, _RBCLW_SCALE), 'RBCLW_FAIL2': (-1, _RBCLW_SCALE),
}
def float32(value):
return struct.unpack('<f', struct.pack('<f', value))[0]
def show(value):
"""Format a value for the log, integers without an exponent."""
if float(value).is_integer():
return str(int(value))
return f'{value:g}'
def format_value(value, mav_type):
"""Format a value the way QGroundControl saves it."""
if mav_type == MAV_PARAM_TYPE_REAL32:
return f'{float32(value):.18f}'
return str(int(value))
def convert(name, value, current):
"""Return [(name, value)] for an old parameter, as PX4 converts it.
current: values already in the file, for MPC_AUTO_NUDGING.
"""
kind, new, arg = CONVERSIONS[name]
if kind == 'rename':
return [(new, value)]
if kind == 'copy_int':
return [(n, int(value)) for n in new]
if kind == 'half_range':
if value <= 0:
return []
half = float32(value) * 0.5
return [(new[0], half), (new[1], -half)]
if kind == 'if_zero_set':
return [(new, arg)] if value == 0 else []
if kind == 'if_nonzero_rename_int':
return [(new, int(value))] if value != 0 else []
if kind == 'rename_if_nonzero_set':
return [(new[0], value)] + ([(new[1], arg)] if value != 0 else [])
if kind == 'if_nonzero_set_bit':
if value == 0:
return []
return [(new, int(current.get(new, 0)) | (1 << arg))]
raise ValueError(kind)
def log_old_default(name, value, log):
"""List a value still at a v1.17 default that v1.18 changed."""
if name in DEFAULT_CHANGES:
old, new = DEFAULT_CHANGES[name]
if value == float32(old):
scope = DEFAULT_CHANGE_SCOPES.get(name)
log(f'default: {name} {show(value)} is a v1.17 default,'
f' v1.18 uses {show(new)}'
+ (f' {scope}' if scope else ''))
for old, new, scope in BOARD_DEFAULT_CHANGES.get(name, []):
if value == float32(old):
log(f'default: {name} {show(value)} is a v1.17 default,'
f' v1.18 uses {show(new)} {scope}')
def migrate(lines, log):
"""Convert the lines of a .params file and return the new lines."""
rows = []
for line in lines:
fields = line.rstrip('\r\n').split('\t')
try:
int(fields[1])
float(fields[3])
assert len(fields) == 5
except (AssertionError, IndexError, ValueError):
if line.strip() and not line.startswith('#'):
log(f'copied unchanged, not in the QGroundControl format:'
f' {line.strip()}')
# parameters follow these lines in the output
rows.append(line if line.endswith('\n') else line + '\n')
continue
rows.append(fields)
params = [r for r in rows if isinstance(r, list)
and r[1] == str(AUTOPILOT_COMPONENT)]
if not params and any(isinstance(r, list) for r in rows):
log(f'warning: no parameters of component {AUTOPILOT_COMPONENT},'
f' nothing converted: only an autopilot with MAV_COMP_ID'
f' {AUTOPILOT_COMPONENT} is supported')
current = {r[2]: float(r[3]) for r in params}
vehicle = params[0][0] if params else '1'
new_values = {}
out = []
for row in rows:
if not isinstance(row, list) or row[1] != str(AUTOPILOT_COMPONENT):
out.append(row)
continue
name = row[2]
value = float32(float(row[3]))
if name in CONVERSIONS:
writes = convert(name, value, {**current, **new_values})
for new_name, new_value in writes:
new_values[new_name] = new_value
done = ', '.join(f'{n} {show(v)}' for n, v in writes)
log(f'converted: {name} {show(value)} ->'
f' {done or "nothing to set"}')
log_old_default(name, value, log)
elif name in REMOVED:
hint = f': {REMOVED[name]}' if REMOVED[name] else ''
log(f'removed: {name} {show(value)}{hint}')
elif (name in REPLACED_DEFAULTS
and value == REPLACED_DEFAULTS[name][0]):
old, new = REPLACED_DEFAULTS[name]
log(f'replaced: {name} {show(old)} -> {show(new)},'
f' the v1.17 default by the v1.18 default')
out.append([row[0], row[1], name,
format_value(new, int(row[4])), row[4]])
elif name in REVERSE_PARAMS and row[4] != str(MAV_PARAM_TYPE_INT32):
reverse = -1 if value < 0 else 1
if reverse < 0:
log(f'reversed: {name} written as the integer -1')
out.append([row[0], row[1], name, str(reverse),
str(MAV_PARAM_TYPE_INT32)])
else:
log_old_default(name, value, log)
if name in SCALE_CHECKS and value != SCALE_CHECKS[name][0]:
log(f'check: {name} {show(value)}: {SCALE_CHECKS[name][1]}')
out.append(row)
# A converted value replaces the file's own value of that parameter
out = [r for r in out if not (isinstance(r, list)
and r[1] == str(AUTOPILOT_COMPONENT)
and r[2] in new_values)]
for name, value in new_values.items():
out.append([vehicle, str(AUTOPILOT_COMPONENT), name,
format_value(value, NEW_TYPES[name]),
str(NEW_TYPES[name])])
header = [r for r in out if not isinstance(r, list)]
body = sorted((r for r in out if isinstance(r, list)),
key=lambda r: (int(r[1]), r[2]))
return header + ['\t'.join(r) + '\n' for r in body]
def main():
parser = argparse.ArgumentParser(
description=__doc__, formatter_class=argparse.RawTextHelpFormatter)
parser.add_argument('input', help='.params file saved on PX4 v1.17')
parser.add_argument('output', help='converted .params file to write')
args = parser.parse_args()
with open(args.input, encoding='utf-8') as f:
lines = f.readlines()
version = next((line.split(':', 1)[1].strip() for line in lines
if line.startswith('# Version:')), None)
if version is not None and not version.startswith('1.17'):
print(f'warning: the file was saved on PX4 {version}, not v1.17',
file=sys.stderr)
converted = migrate(lines, lambda message: print(message, file=sys.stderr))
with open(args.output, 'w', encoding='utf-8') as f:
f.writelines(converted)
if __name__ == '__main__':
main()