diff options
author | Lorenz Meier <lorenz@px4.io> | 2015-01-06 12:09:44 +0100 |
---|---|---|
committer | Lorenz Meier <lorenz@px4.io> | 2015-01-06 12:09:44 +0100 |
commit | 4a3145f0edaaad570e6e0a86fd4d44e6c988afbb (patch) | |
tree | bf59f889b9e7cffac33b52f70b2dae2c6fc61c15 /src/modules | |
parent | 88d7c4e44798fb86d960b2fe2204213e62e6b660 (diff) | |
parent | a42febc993ae4492e0f43002a5f30f02a0e02fa7 (diff) | |
download | px4-firmware-4a3145f0edaaad570e6e0a86fd4d44e6c988afbb.tar.gz px4-firmware-4a3145f0edaaad570e6e0a86fd4d44e6c988afbb.tar.bz2 px4-firmware-4a3145f0edaaad570e6e0a86fd4d44e6c988afbb.zip |
Merge pull request #1594 from PX4/multitablespython3
Multitables script fixes
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/systemlib/mixer/multi_tables.mk | 7 | ||||
-rwxr-xr-x | src/modules/systemlib/mixer/multi_tables.py (renamed from src/modules/systemlib/mixer/multi_tables) | 59 |
2 files changed, 34 insertions, 32 deletions
diff --git a/src/modules/systemlib/mixer/multi_tables.mk b/src/modules/systemlib/mixer/multi_tables.mk index 6429961cc..c537c83a4 100644 --- a/src/modules/systemlib/mixer/multi_tables.mk +++ b/src/modules/systemlib/mixer/multi_tables.mk @@ -33,11 +33,10 @@ SELF_DIR := $(dir $(lastword $(MAKEFILE_LIST))) +MULTI_TABLES := $(SELF_DIR)multi_tables.py # Add explicit dependency, as implicit one doesn't work often. $(SELF_DIR)mixer_multirotor.cpp : $(SELF_DIR)mixer_multirotor.generated.h -$(SELF_DIR)mixer_multirotor.generated.h : $(SELF_DIR)multi_tables - $(SELF_DIR)multi_tables > $(SELF_DIR)mixer_multirotor.generated.h - $(SELF_DIR)multi_tables -
\ No newline at end of file +$(SELF_DIR)mixer_multirotor.generated.h : $(MULTI_TABLES) + $(Q) $(PYTHON) $(MULTI_TABLES) > $(SELF_DIR)mixer_multirotor.generated.h diff --git a/src/modules/systemlib/mixer/multi_tables b/src/modules/systemlib/mixer/multi_tables.py index a9edb357b..21c0affd9 100755 --- a/src/modules/systemlib/mixer/multi_tables +++ b/src/modules/systemlib/mixer/multi_tables.py @@ -36,15 +36,18 @@ # Generate multirotor mixer scale tables compatible with the ArduCopter layout # +# for python2.7 compatibility +from __future__ import print_function + import math -print "/*" -print "* This file is automatically generated by multi_tables - do not edit." -print "*/" -print "" -print "#ifndef _MIXER_MULTI_TABLES" -print "#define _MIXER_MULTI_TABLES" -print "" +print("/*") +print("* This file is automatically generated by multi_tables - do not edit.") +print("*/") +print("") +print("#ifndef _MIXER_MULTI_TABLES") +print("#define _MIXER_MULTI_TABLES") +print("") def rcos(angleInRadians): return math.cos(math.radians(angleInRadians)) @@ -146,7 +149,7 @@ twin_engine = [ ] def variableName(variable): - for variableName, value in list(globals().iteritems()): + for variableName, value in list(globals().items()): if value is variable: return variableName @@ -154,44 +157,44 @@ tables = [quad_x, quad_plus, quad_v, quad_wide, hex_x, hex_plus, hex_cox, octa_x def printEnum(): - print "enum class MultirotorGeometry : MultirotorGeometryUnderlyingType {" + print("enum class MultirotorGeometry : MultirotorGeometryUnderlyingType {") for table in tables: - print "\t{},".format(variableName(table).upper()) + print("\t{},".format(variableName(table).upper())) - print "\n\tMAX_GEOMETRY" - print "}; // enum class MultirotorGeometry\n" + print("\n\tMAX_GEOMETRY") + print("}; // enum class MultirotorGeometry\n") def printScaleTables(): for table in tables: - print "const MultirotorMixer::Rotor _config_{}[] = {{".format(variableName(table)) + print("const MultirotorMixer::Rotor _config_{}[] = {{".format(variableName(table))) for (angle, yawScale) in table: rollScale = rcos(angle + 90) pitchScale = rcos(angle) - print "\t{{ {:9f}, {:9f}, {:9f} }},".format(rollScale, pitchScale, yawScale) - print "};\n" - + print("\t{{ {:9f}, {:9f}, {:9f} }},".format(rollScale, pitchScale, yawScale)) + print("};\n") + def printScaleTablesIndex(): - print "const MultirotorMixer::Rotor *_config_index[] = {" + print("const MultirotorMixer::Rotor *_config_index[] = {") for table in tables: - print "\t&_config_{}[0],".format(variableName(table)) - print "};\n" + print("\t&_config_{}[0],".format(variableName(table))) + print("};\n") def printScaleTablesCounts(): - print "const unsigned _config_rotor_count[] = {" + print("const unsigned _config_rotor_count[] = {") for table in tables: - print "\t{}, /* {} */".format(len(table), variableName(table)) - print "};\n" - - + print("\t{}, /* {} */".format(len(table), variableName(table))) + print("};\n") + + printEnum() -print "namespace {" +print("namespace {") printScaleTables() printScaleTablesIndex() printScaleTablesCounts() -print "} // anonymous namespace\n" -print "#endif /* _MIXER_MULTI_TABLES */" -print "" +print("} // anonymous namespace\n") +print("#endif /* _MIXER_MULTI_TABLES */") +print("") |