mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-04-14 10:07:39 +08:00
Mixers: use key list to select multirotor mixer
This commit is contained in:
parent
aa789f5e8a
commit
4991ab5362
@ -100,7 +100,7 @@ MultirotorMixer::~MultirotorMixer()
|
||||
MultirotorMixer *
|
||||
MultirotorMixer::from_text(Mixer::ControlCallback control_cb, uintptr_t cb_handle, const char *buf, unsigned &buflen)
|
||||
{
|
||||
MultirotorGeometry geometry;
|
||||
MultirotorGeometry geometry = MultirotorGeometry::MAX_GEOMETRY;
|
||||
char geomname[8];
|
||||
int s[4];
|
||||
int used;
|
||||
@ -129,61 +129,15 @@ MultirotorMixer::from_text(Mixer::ControlCallback control_cb, uintptr_t cb_handl
|
||||
|
||||
debug("remaining in buf: %d, first char: %c", buflen, buf[0]);
|
||||
|
||||
if (!strcmp(geomname, "4+")) {
|
||||
geometry = MultirotorGeometry::QUAD_PLUS;
|
||||
for (MultirotorGeometryUnderlyingType i = 0; i < (MultirotorGeometryUnderlyingType)MultirotorGeometry::MAX_GEOMETRY;
|
||||
i++) {
|
||||
if (!strcmp(geomname, _config_key[i])) {
|
||||
geometry = (MultirotorGeometry)i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (!strcmp(geomname, "4x")) {
|
||||
geometry = MultirotorGeometry::QUAD_X;
|
||||
|
||||
} else if (!strcmp(geomname, "4h")) {
|
||||
geometry = MultirotorGeometry::QUAD_H;
|
||||
|
||||
} else if (!strcmp(geomname, "4v")) {
|
||||
geometry = MultirotorGeometry::QUAD_V;
|
||||
|
||||
} else if (!strcmp(geomname, "4w")) {
|
||||
geometry = MultirotorGeometry::QUAD_WIDE;
|
||||
|
||||
} else if (!strcmp(geomname, "4s")) {
|
||||
geometry = MultirotorGeometry::QUAD_S250AQ;
|
||||
|
||||
} else if (!strcmp(geomname, "4dc")) {
|
||||
geometry = MultirotorGeometry::QUAD_DEADCAT;
|
||||
|
||||
} else if (!strcmp(geomname, "6+")) {
|
||||
geometry = MultirotorGeometry::HEX_PLUS;
|
||||
|
||||
} else if (!strcmp(geomname, "6x")) {
|
||||
geometry = MultirotorGeometry::HEX_X;
|
||||
|
||||
} else if (!strcmp(geomname, "6c")) {
|
||||
geometry = MultirotorGeometry::HEX_COX;
|
||||
|
||||
} else if (!strcmp(geomname, "6t")) {
|
||||
geometry = MultirotorGeometry::HEX_T;
|
||||
|
||||
} else if (!strcmp(geomname, "8+")) {
|
||||
geometry = MultirotorGeometry::OCTA_PLUS;
|
||||
|
||||
} else if (!strcmp(geomname, "8x")) {
|
||||
geometry = MultirotorGeometry::OCTA_X;
|
||||
|
||||
} else if (!strcmp(geomname, "8c")) {
|
||||
geometry = MultirotorGeometry::OCTA_COX;
|
||||
|
||||
} else if (!strcmp(geomname, "6m")) {
|
||||
geometry = MultirotorGeometry::DODECA_TOP_COX;
|
||||
|
||||
} else if (!strcmp(geomname, "6a")) {
|
||||
geometry = MultirotorGeometry::DODECA_BOTTOM_COX;
|
||||
|
||||
} else if (!strcmp(geomname, "2-")) {
|
||||
geometry = MultirotorGeometry::TWIN_ENGINE;
|
||||
|
||||
} else if (!strcmp(geomname, "3y")) {
|
||||
geometry = MultirotorGeometry::TRI_Y;
|
||||
|
||||
} else {
|
||||
if (geometry == MultirotorGeometry::MAX_GEOMETRY) {
|
||||
debug("unrecognised geometry '%s'", geomname);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@ -201,7 +201,7 @@ dodeca_top_cox = [
|
||||
[ -30, CW],
|
||||
[ 150, CCW],
|
||||
[ 30, CCW],
|
||||
[-150, CW],
|
||||
[-150, CW],
|
||||
]
|
||||
|
||||
dodeca_bottom_cox = [
|
||||
@ -213,7 +213,16 @@ dodeca_bottom_cox = [
|
||||
[-150, CCW],
|
||||
]
|
||||
|
||||
tables = [quad_x, quad_h, quad_plus, quad_v, quad_wide, quad_s250aq, quad_deadcat, hex_x, hex_plus, hex_cox, hex_t, octa_x, octa_plus, octa_cox, octa_cox_wide, twin_engine, tri_y, dodeca_top_cox, dodeca_bottom_cox]
|
||||
tables = [quad_x, quad_h, quad_plus, quad_v, quad_wide, quad_s250aq, quad_deadcat,
|
||||
hex_x, hex_plus, hex_cox, hex_t,
|
||||
octa_x, octa_plus, octa_cox, octa_cox_wide,
|
||||
twin_engine, tri_y,
|
||||
dodeca_top_cox, dodeca_bottom_cox]
|
||||
keys = ["4x", "4h", "4+", "4v", "4w", "4s", "4dc",
|
||||
"6x", "6+", "6c", "6t",
|
||||
"8x", "8+", "8c", "8cw",
|
||||
"2-", "3y",
|
||||
"6m", "6a"]
|
||||
|
||||
def variableName(variable):
|
||||
for variableName, value in list(globals().items()):
|
||||
@ -256,7 +265,11 @@ def printScaleTablesCounts():
|
||||
print("\t{}, /* {} */".format(len(table), variableName(table)))
|
||||
print("};\n")
|
||||
|
||||
|
||||
def printScaleTablesKeys():
|
||||
print("const char* _config_key[] = {")
|
||||
for key, table in zip(keys, tables):
|
||||
print("\t\"{}\",\t/* {} */".format(key, variableName(table)))
|
||||
print("};\n")
|
||||
|
||||
printEnum()
|
||||
|
||||
@ -264,6 +277,7 @@ print("namespace {")
|
||||
printScaleTables()
|
||||
printScaleTablesIndex()
|
||||
printScaleTablesCounts()
|
||||
printScaleTablesKeys()
|
||||
|
||||
print("} // anonymous namespace\n")
|
||||
print("#endif /* _MIXER_MULTI_TABLES */")
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user