mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 10:26:52 +08:00
Mixers: raise exception when geom file is incomplete
pylint format
This commit is contained in:
committed by
Beat Küng
parent
cb8d951a7e
commit
d46c37be79
@@ -13,7 +13,7 @@ Cm = 0.05
|
|||||||
|
|
||||||
[[rotors]]
|
[[rotors]]
|
||||||
name = "front_right"
|
name = "front_right"
|
||||||
position = [0.707107, 0.707107, 0.0]
|
position = [0.707107, 0.707107]#, 0.0]
|
||||||
direction = "CCW"
|
direction = "CCW"
|
||||||
|
|
||||||
[[rotors]]
|
[[rotors]]
|
||||||
|
|||||||
@@ -68,8 +68,6 @@ def parse_geom_toml(filename):
|
|||||||
Parses toml geometry file and returns a dictionary with curated list of rotors
|
Parses toml geometry file and returns a dictionary with curated list of rotors
|
||||||
'''
|
'''
|
||||||
|
|
||||||
import toml
|
|
||||||
|
|
||||||
# Load toml file
|
# Load toml file
|
||||||
d = toml.load(filename)
|
d = toml.load(filename)
|
||||||
|
|
||||||
@@ -79,6 +77,16 @@ def parse_geom_toml(filename):
|
|||||||
else:
|
else:
|
||||||
default = {}
|
default = {}
|
||||||
|
|
||||||
|
# Check info section
|
||||||
|
if 'info' not in d:
|
||||||
|
raise AttributeError('{}: Error, missing info section'.format(filename))
|
||||||
|
|
||||||
|
# Check info section
|
||||||
|
for field in ['name', 'key', 'description']:
|
||||||
|
if field not in d['info']:
|
||||||
|
raise AttributeError('{}: Error, unspecified info field "{}"'.format(filename, field))
|
||||||
|
|
||||||
|
|
||||||
# Convert rotors
|
# Convert rotors
|
||||||
rotor_list = []
|
rotor_list = []
|
||||||
if 'rotors' in d:
|
if 'rotors' in d:
|
||||||
@@ -89,13 +97,21 @@ def parse_geom_toml(filename):
|
|||||||
if field in default:
|
if field in default:
|
||||||
r[field] = default[field]
|
r[field] = default[field]
|
||||||
else:
|
else:
|
||||||
print(filename + ': Error, unspecified field ' + field + ' for rotor ' + r['name'])
|
raise AttributeError('{}: Error, unspecified field "{}" for rotor "{}"'
|
||||||
|
.format(filename, field, r['name']))
|
||||||
|
|
||||||
# Check fields
|
# Check direction field
|
||||||
r['direction'] = r['direction'].upper()
|
r['direction'] = r['direction'].upper()
|
||||||
if r['direction'] not in ['CW', 'CCW']:
|
if r['direction'] not in ['CW', 'CCW']:
|
||||||
print(filename + ': Error, invalid direction value "' + r['direction'] + '" for rotor ' + r['name'])
|
raise AttributeError('{}: Error, invalid direction value "{}" for rotor "{}"'
|
||||||
|
.format(filename, r['direction'], r['name']))
|
||||||
|
|
||||||
|
# Check vector3 fields
|
||||||
|
for field in ['position', 'axis']:
|
||||||
|
if len(r[field]) != 3:
|
||||||
|
raise AttributeError('{}: Error, field "{}" for rotor "{}"'
|
||||||
|
.format(filename, field, r['name']) +
|
||||||
|
' must be an array of length 3')
|
||||||
|
|
||||||
# Add rotor to list
|
# Add rotor to list
|
||||||
rotor_list.append(r)
|
rotor_list.append(r)
|
||||||
|
|||||||
Reference in New Issue
Block a user