mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
Merge remote-tracking branch 'upstream/multitablespython3' into dev_ros
This commit is contained in:
commit
94b9251a69
@ -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
|
||||
|
||||
$(SELF_DIR)mixer_multirotor.generated.h : $(MULTI_TABLES)
|
||||
$(Q) $(PYTHON) $(MULTI_TABLES) > $(SELF_DIR)mixer_multirotor.generated.h
|
||||
|
||||
@ -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("")
|
||||
Loading…
x
Reference in New Issue
Block a user