Tools: param_parse.py: add a map for vehicle name to a true-name to be used in code

Where true-name is something like "Rover" and the normal name remains
the directory name (e.g. "APMrover2")
This commit is contained in:
Peter Barker 2017-09-25 10:23:47 +10:00 committed by Jacob Walser
parent f65c2c7d07
commit 629622b6c7
2 changed files with 12 additions and 3 deletions

View File

@ -5,7 +5,9 @@ class Parameter(object):
class Vehicle(object):
def __init__(self, name, path):
def __init__(self, name, path, truename=None):
if truename is not None:
self.truename = truename
self.name = name
self.path = path
self.params = []

View File

@ -56,10 +56,17 @@ def error(str_to_print):
error_count += 1
print(str_to_print)
truename_map = {
"APMrover2": "Rover",
"ArduSub": "Sub",
"ArduCopter": "Copter",
"ArduPlane": "Plane",
"AntennaTracker": "Tracker",
}
for vehicle_path in vehicle_paths:
name = os.path.basename(os.path.dirname(vehicle_path))
path = os.path.normpath(os.path.dirname(vehicle_path))
vehicles.append(Vehicle(name, path))
vehicles.append(Vehicle(name, path, truename_map[name]))
debug('Found vehicle type %s' % name)
if len(vehicles) > 1:
@ -154,7 +161,7 @@ def process_library(vehicle, library, pathprefix=None):
for field in fields:
only_for_vehicles = field[1].split(",")
# print("vehicle=%s field[1]=%s only_for_vehicles=%s\n" % (vehicle.name,field[1], str(only_for_vehicles)))
if vehicle.name not in only_for_vehicles:
if vehicle.truename not in only_for_vehicles:
continue;
if field[0] in known_param_fields:
setattr(p, field[0], field[2])