|
|
|
@ -36,15 +36,18 @@
@@ -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 = [
@@ -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
@@ -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("") |