mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-22 12:47:35 +08:00
Mixers: Use geometry filename as mixer name
This commit is contained in:
committed by
Beat Küng
parent
d43b33b1c4
commit
76447b0f4e
@@ -33,7 +33,7 @@
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||
|
||||
set(geom_files
|
||||
set(geometry_files
|
||||
quad_x.toml
|
||||
quad_h.toml
|
||||
quad_plus.toml
|
||||
@@ -56,34 +56,34 @@ set(geom_files
|
||||
dodeca_bottom_cox.toml
|
||||
)
|
||||
|
||||
set(geom_list)
|
||||
foreach(geom_file ${geom_files})
|
||||
list(APPEND geom_list ${CMAKE_CURRENT_SOURCE_DIR}/geoms/${geom_file})
|
||||
set(geometries_list)
|
||||
foreach(geom_file ${geometry_files})
|
||||
list(APPEND geometries_list ${CMAKE_CURRENT_SOURCE_DIR}/geometries/${geom_file})
|
||||
endforeach()
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mixer_multirotor.generated.h
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/geoms/tools/px_generate_mixers.py -f ${geom_list} -o ${CMAKE_CURRENT_BINARY_DIR}/mixer_multirotor.generated.h
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/geoms/tools/px_generate_mixers.py ${geom_list}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/geometries/tools/px_generate_mixers.py -f ${geometries_list} -o ${CMAKE_CURRENT_BINARY_DIR}/mixer_multirotor.generated.h
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/geometries/tools/px_generate_mixers.py ${geometries_list}
|
||||
)
|
||||
add_custom_target(mixer_gen
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/mixer_multirotor.generated.h
|
||||
DEPENDS ${geom_list})
|
||||
DEPENDS ${geometries_list})
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mixer_multirotor_normalized.generated.h
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/geoms/tools/px_generate_mixers.py --normalize -f ${geom_list} -o ${CMAKE_CURRENT_BINARY_DIR}/mixer_multirotor_normalized.generated.h
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/geoms/tools/px_generate_mixers.py ${geom_list}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/geometries/tools/px_generate_mixers.py --normalize -f ${geometries_list} -o ${CMAKE_CURRENT_BINARY_DIR}/mixer_multirotor_normalized.generated.h
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/geometries/tools/px_generate_mixers.py ${geometries_list}
|
||||
)
|
||||
add_custom_target(mixer_gen_norm
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/mixer_multirotor_normalized.generated.h
|
||||
DEPENDS ${geom_list})
|
||||
DEPENDS ${geometries_list})
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mixer_multirotor_6dof.generated.h
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/geoms/tools/px_generate_mixers.py --sixdof -f ${geom_list} -o ${CMAKE_CURRENT_BINARY_DIR}/mixer_multirotor_6dof.generated.h
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/geoms/tools/px_generate_mixers.py ${geom_list}
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/geometries/tools/px_generate_mixers.py --sixdof -f ${geometries_list} -o ${CMAKE_CURRENT_BINARY_DIR}/mixer_multirotor_6dof.generated.h
|
||||
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/geometries/tools/px_generate_mixers.py ${geometries_list}
|
||||
)
|
||||
add_custom_target(mixer_gen_6dof
|
||||
DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/mixer_multirotor_6dof.generated.h
|
||||
DEPENDS ${geom_list})
|
||||
DEPENDS ${geometries_list})
|
||||
|
||||
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mixer_multirotor_legacy.generated.h
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/multi_tables.py > ${CMAKE_CURRENT_BINARY_DIR}/mixer_multirotor_legacy.generated.h
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Generic Dodecacopter in X coax configuration, bottom half
|
||||
|
||||
[info]
|
||||
name = "dodeca_bottom_cox"
|
||||
key = "6a"
|
||||
description = "Generic Dodecacopter in X coax configuration, bottom half"
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Generic Dodecacopter in X coax configuration, top half
|
||||
|
||||
[info]
|
||||
name = "dodeca_top_cox"
|
||||
key = "6m"
|
||||
description = "Generic Dodecacopter in X coax configuration, top half"
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Generic Hexacopter in coaxial configuration
|
||||
|
||||
[info]
|
||||
name = "hex_cox"
|
||||
key = "6c"
|
||||
description = "Generic Hexacopter in coaxial configuration"
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Generic Hexacopter in + configuration
|
||||
|
||||
[info]
|
||||
name = "hex_plus"
|
||||
key = "6+"
|
||||
description = "Generic Hexacopter in + configuration"
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Generic Hexacopter in T configuration
|
||||
|
||||
[info]
|
||||
name = "hex_t"
|
||||
key = "6t"
|
||||
description = "Generic Hexacopter in T configuration"
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Generic Hexacopter in X configuration
|
||||
|
||||
[info]
|
||||
name = "hex_x"
|
||||
key = "6x"
|
||||
description = "Generic Hexacopter in X configuration"
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Generic Octacopter in coax configuration
|
||||
|
||||
[info]
|
||||
name = "octa_cox"
|
||||
key = "8c"
|
||||
description = "GenericOctacopter in coax configuration"
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Generic Octacopter in wide coax configuration
|
||||
|
||||
[info]
|
||||
name = "octa_cox_wide"
|
||||
key = "8cw"
|
||||
description = "Generic Octacopter in wide coax configuration"
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Generic Octacopter in + configuration
|
||||
|
||||
[info]
|
||||
name = "octa_plus"
|
||||
key = "8+"
|
||||
description = "Generic Octacopter in + configuration"
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Generic Octacopter in X configuration
|
||||
|
||||
[info]
|
||||
name = "octa_x"
|
||||
key = "8x"
|
||||
description = "Generic Octacopter in X configuration"
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
# Same geometry as quad_wide, except CG is located at intersection of rear arms, so front motors are more loaded.
|
||||
|
||||
[info]
|
||||
name = "quad_deadcat"
|
||||
key = "4dc"
|
||||
description = "SK450 DeadCat Quadcopter, CG at intersection of rear arms"
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Generic Quadcopter in H configuration
|
||||
|
||||
[info]
|
||||
name = "quad_h"
|
||||
key = "4h"
|
||||
description = "Generic Quadcopter in H configuration"
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Generic Quadcopter in + configuration
|
||||
|
||||
[info]
|
||||
name = "quad_plus"
|
||||
key = "4+"
|
||||
description = "Generic Quadcopter in + configuration"
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Quadcopter in Y configuration with rear props tilted at 45 degrees
|
||||
|
||||
[info]
|
||||
name = "quad_vtail"
|
||||
key = "4vt"
|
||||
description = "Quadcopter in Y configuration with rear props tilted at 45 degrees"
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Generic Quadcopter in wide configuration
|
||||
|
||||
[info]
|
||||
name = "quad_wide"
|
||||
key = "4w"
|
||||
description = "Quadcopter in wide configuration. Same geometry as SK450 Deadcat except the CG is moved backward to load all motors equally"
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Generic Quadcopter in X configuration
|
||||
|
||||
[info]
|
||||
name = "quad_x"
|
||||
key = "4x"
|
||||
description = "Generic Quadcopter in X configuration"
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
# with added pusher motor in the back
|
||||
|
||||
[info]
|
||||
name = "quad_x_pusher"
|
||||
key = "4x1p"
|
||||
description = "Quadcopter in X configuration, with added pusher motor in the back"
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Quadcopter in Y configuration with coax rear props
|
||||
|
||||
[info]
|
||||
name = "quad_y"
|
||||
key = "4y"
|
||||
description = "Quadcopter in Y configuration with coax rear props"
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ def parse_geometry_toml(filename):
|
||||
'''
|
||||
Parses toml geometry file and returns a dictionary with curated list of rotors
|
||||
'''
|
||||
import os
|
||||
|
||||
# Load toml file
|
||||
d = toml.load(filename)
|
||||
@@ -82,10 +83,12 @@ def parse_geometry_toml(filename):
|
||||
raise AttributeError('{}: Error, missing info section'.format(filename))
|
||||
|
||||
# Check info section
|
||||
for field in ['name', 'key', 'description']:
|
||||
for field in ['key', 'description']:
|
||||
if field not in d['info']:
|
||||
raise AttributeError('{}: Error, unspecified info field "{}"'.format(filename, field))
|
||||
|
||||
# Use filename as mixer name
|
||||
d['info']['name'] = os.path.basename(filename).split('.')[0].lower()
|
||||
|
||||
# Convert rotors
|
||||
rotor_list = []
|
||||
@@ -234,7 +237,9 @@ def generate_mixer_multirotor_header(geometries_list, use_normalized_mix=False,
|
||||
# Print enum
|
||||
buf.write(u"enum class MultirotorGeometry : MultirotorGeometryUnderlyingType {\n")
|
||||
for i, geometry in enumerate(geometries_list):
|
||||
buf.write(u"\t{} = {},\n".format(geometry['info']['name'].upper(), i))
|
||||
buf.write(u"\t{},{}// {} (text key {})\n".format(
|
||||
geometry['info']['name'].upper(), ' ' * (max(0, 30 - len(geometry['info']['name']))),
|
||||
geometry['info']['description'], geometry['info']['key']))
|
||||
buf.write(u"\n\tMAX_GEOMETRY\n")
|
||||
buf.write(u"}; // enum class MultirotorGeometry\n\n")
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Tri Y
|
||||
|
||||
[info]
|
||||
name = "tri_y"
|
||||
key = "3y"
|
||||
description = "Tri Y"
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
# Twin engine
|
||||
|
||||
[info]
|
||||
name = "twin_engine"
|
||||
key = "2-"
|
||||
description = "Twin engine"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user