From 56d67c6f6c8f19d5362936257ed4e6a76513c0dc Mon Sep 17 00:00:00 2001 From: Lorenz Meier Date: Mon, 9 Nov 2015 09:31:43 +0100 Subject: [PATCH] Tools: Support injecting param meta, do not generate code for these --- Tools/parameters_injected.xml | 146 ++++++++++++++++++++++++++++++++++ Tools/px4params/xmlout.py | 6 +- Tools/px_generate_params.py | 5 +- Tools/px_process_params.py | 8 +- 4 files changed, 161 insertions(+), 4 deletions(-) create mode 100644 Tools/parameters_injected.xml diff --git a/Tools/parameters_injected.xml b/Tools/parameters_injected.xml new file mode 100644 index 0000000000..a5b6bc0883 --- /dev/null +++ b/Tools/parameters_injected.xml @@ -0,0 +1,146 @@ + + + 3 + + + Speed controller bandwidth + Speed controller bandwidth, in Hz. Higher values result in faster speed and current rise times, but may result in overshoot and higher current consumption. For fixed-wing aircraft, this value should be less than 50 Hz; for multirotors, values up to 100 Hz may provide improvements in responsiveness. + Hertz + 10 + 250 + + + Reverse direction + Motor spin direction as detected during initial enumeration. Use 0 or 1 to reverse direction. + 0 + 1 + + + Speed (RPM) controller gain + Speed (RPM) controller gain. Determines controller + aggressiveness; units are amp-seconds per radian. Systems with + higher rotational inertia (large props) will need gain increased; + systems with low rotational inertia (small props) may need gain + decreased. Higher values result in faster response, but may result + in oscillation and excessive overshoot. Lower values result in a + slower, smoother response. + amp-seconds per radian + 3 + 0.00 + 1.00 + + + Idle speed (e Hz) + Idle speed (e Hz) + Hertz + 3 + 0.0 + 100.0 + + + Spin-up rate (e Hz/s) + Spin-up rate (e Hz/s) + Hz/s + + 5 + 1000 + + + Index of this ESC in throttle command messages. + Index of this ESC in throttle command messages. + Index + + 0 + 15 + + + Extended status ID + Extended status ID + + + 1 + 1023 + + + Extended status interval (µs) + Extended status interval (µs) + µs + + 0 + 1000000 + + + ESC status interval (µs) + ESC status interval (µs) + µs + + 1000000 + + + Motor current limit in amps + Motor current limit in amps. This determines the maximum + current controller setpoint, as well as the maximum allowable + current setpoint slew rate. This value should generally be set to + the continuous current rating listed in the motor’s specification + sheet, or set equal to the motor’s specified continuous power + divided by the motor voltage limit. + Amps + 3 + 1 + 80 + + + Motor Kv in RPM per volt + Motor Kv in RPM per volt. This can be taken from the motor’s + specification sheet; accuracy will help control performance but + some deviation from the specified value is acceptable. + RPM/v + 0 + 0 + 100 + + + READ ONLY: Motor inductance in henries. + READ ONLY: Motor inductance in henries. This is measured on start-up. + henries + 3 + + + Number of motor poles. + Number of motor poles. Used to convert mechanical speeds to + electrical speeds. This number should be taken from the motor’s + specification sheet. + Poles + + 2 + 40 + + + READ ONLY: Motor resistance in ohms + READ ONLY: Motor resistance in ohms. This is measured on start-up. When + tuning a new motor, check that this value is approximately equal + to the value shown in the motor’s specification sheet. + Ohms + 3 + + + Acceleration limit (V) + Acceleration limit (V) + Volts + 3 + 0.01 + 1.00 + + + Motor voltage limit in volts + Motor voltage limit in volts. The current controller’s + commanded voltage will never exceed this value. Note that this may + safely be above the nominal voltage of the motor; to determine the + actual motor voltage limit, divide the motor’s rated power by the + motor current limit. + Volts + 3 + 0 + + + \ No newline at end of file diff --git a/Tools/px4params/xmlout.py b/Tools/px4params/xmlout.py index b072ab79f8..b37cdb0627 100644 --- a/Tools/px4params/xmlout.py +++ b/Tools/px4params/xmlout.py @@ -18,10 +18,14 @@ def indent(elem, level=0): class XMLOutput(): - def __init__(self, groups, board): + def __init__(self, groups, board, inject_xml_file_name): xml_parameters = ET.Element("parameters") xml_version = ET.SubElement(xml_parameters, "version") xml_version.text = "3" + importtree = ET.parse(inject_xml_file_name) + injectgroups = importtree.getroot().findall("group") + for igroup in injectgroups: + xml_parameters.append(igroup) last_param_name = "" board_specific_param_set = False for group in groups: diff --git a/Tools/px_generate_params.py b/Tools/px_generate_params.py index 3df124f523..f1877987ad 100755 --- a/Tools/px_generate_params.py +++ b/Tools/px_generate_params.py @@ -29,7 +29,7 @@ start_name = "" end_name = "" for group in root: - if group.tag == "group": + if group.tag == "group" and "no_code_generation" not in group.attrib: header += """ /***************************************************************** * %s @@ -62,7 +62,8 @@ struct px4_parameters_t px4_parameters = { """ i=0 for group in root: - if group.tag == "group": + if group.tag == "group" and "no_code_generation" not in group.attrib: + src += """ /***************************************************************** * %s diff --git a/Tools/px_process_params.py b/Tools/px_process_params.py index c2024dc726..3a11fc5c50 100644 --- a/Tools/px_process_params.py +++ b/Tools/px_process_params.py @@ -65,6 +65,12 @@ def main(): metavar="FILENAME", help="Create XML file" " (default FILENAME: parameters.xml)") + parser.add_argument("-i", "--inject-xml", + nargs='?', + const="../Tools/parameters_injected.xml", + metavar="FILENAME", + help="Inject additional param XML file" + " (default FILENAME: ../Tools/parameters_injected.xml)") parser.add_argument("-b", "--board", nargs='?', const="", @@ -124,7 +130,7 @@ def main(): # Output to XML file if args.xml: print("Creating XML file " + args.xml) - out = xmlout.XMLOutput(param_groups, args.board) + out = xmlout.XMLOutput(param_groups, args.board, args.inject_xml) out.Save(args.xml) # Output to DokuWiki tables