Skip to content

Commit

Permalink
Tools: add SITL defaults processor
Browse files Browse the repository at this point in the history
Also added default files for Volanti

SW-241
  • Loading branch information
robertlong13 committed Jun 25, 2024
1 parent 6c7f953 commit a515db1
Show file tree
Hide file tree
Showing 3 changed files with 181 additions and 0 deletions.
52 changes: 52 additions & 0 deletions Tools/Carbonix_scripts/process_sitl_defaults.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
'''
Build SITL default parameter files for use with SITL launcher
'''

import os
import re
import fnmatch
import argparse


def main():
parser = argparse.ArgumentParser(description='Build SITL default parameter files')
parser.add_argument('input_file', help='Input file to process')
parser.add_argument('output_file', help='Output file to write to')
args = parser.parse_args()

defaults = process_defaults(args.input_file)
with open(args.output_file, "w") as f:
f.write("\n".join(defaults))


def process_defaults(file, depth=0):
if depth > 10:
raise Exception("Too many levels of @include")

param_list = []
with open(file, "r") as f:
lines = f.read().splitlines()
for line in lines:
if line.startswith("@include"):
rel_path = line.split(maxsplit=1)[1]
path = os.path.join(os.path.dirname(file), rel_path)
param_list.extend(
process_defaults(path, depth + 1)
)
continue

if line.startswith("@delete"):
pattern = line.split(maxsplit=1)[1]
for i in range(len(param_list)):
param_name = re.split(r"[\s,]+", param_list[i])[0]
if fnmatch.fnmatch(param_name, pattern):
param_list[i] = "#deleted " + param_list[i]
line = "#" + line

param_list.append(line)

return param_list


if __name__ == "__main__":
main()
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
# Carbonix Volanti Headless Parameters
@include ../../CubeOrange-Volanti/defaults.parm
ARSPD_OFFSET,2013
ARSPD_TYPE,2
ARSPD2_OFFSET,2013
ARSPD2_PIN,2
ARSPD2_TYPE,2
@delete BATT*_PIN
BATT2_AMP_PERVLT,12.75
BATT2_MONITOR,4
BATT2_VOLT_MULT,40.4
BATT3_AMP_PERVLT,12.75
BATT3_MONITOR,4
BATT3_VOLT_MULT,40.4
GPS_TYPE,1
GPS_TYPE2,1
@delete INS_*
INS_ACC2OFFS_X,0.001
INS_ACC2OFFS_Y,0.001
INS_ACC2OFFS_Z,0.001
INS_ACC2SCAL_X,1.001
INS_ACC2SCAL_Y,1.001
INS_ACC2SCAL_Z,1.001
INS_ACCOFFS_X,0.001
INS_ACCOFFS_Y,0.001
INS_ACCOFFS_Z,0.001
INS_ACCSCAL_X,1.001
INS_ACCSCAL_Y,1.001
INS_ACCSCAL_Z,1.001
INS_GYR_CAL,0 # taken from quadplane autotest parameters, just in case
NAVL1_PERIOD,14
@delete PTCH_RATE_*
PTCH_RATE_FF,1.407055
PTCH_RATE_I,0.2125
PTCH_RATE_IMAX,0.888889
PTCH_RATE_P,0.309954
@delete PTCH2SRV_*
@delete Q_A_*
Q_A_ACCEL_P_MAX,30000
Q_A_ACCEL_R_MAX,30000
Q_A_ACCEL_Y_MAX,4500
Q_A_RAT_PIT_D,0.002
Q_A_RAT_PIT_P,0.15
Q_A_RAT_RLL_D,0.002
Q_A_RAT_RLL_P,0.15
Q_A_RATE_P_MAX,60
Q_A_RATE_R_MAX,60
Q_A_RATE_Y_MAX,12
Q_A_SLEW_YAW,1500
@delete Q_M_*
@delete Q_P_*
@delete RLL_RATE_*
RLL_RATE_FF,0.552741
RLL_RATE_I,0.2125
RLL_RATE_IMAX,0.888889
RLL_RATE_P,0.141009
RNGFND1_PIN,0
RNGFND1_SCALING,40
RNGFND1_TYPE,1
@delete SERVO*
SERVO3_MAX,2000
SERVO3_MIN,1000
SERVO3_TRIM,1000
SIM_ARSPD_RATIO,1.6
SIM_ARSPD2_RATIO,1.6
SIM_BATT_CAP_AH,29.33
SIM_GPS_POS_X,-0.12
SIM_GPS_POS_Y,-0.17
SIM_GPS_POS_Z,-0.06
SIM_GPS2_DISABLE,0
SIM_GPS2_POS_X,-0.12
SIM_GPS2_POS_Y,0.17
SIM_GPS2_POS_Z,-0.06
SIM_IMU_POS_X,-0.21
SIM_IMU_POS_Z,-0.03
SIM_MAG1_DEVID,70403
SIM_MAG2_DEVID,72963
SIM_PLD_LAT,43.17443
SIM_PLD_LON,-71.78664
SIM_SONAR_POS_X,-0.12
SIM_SONAR_POS_Z,0.05
SIM_SONAR_SCALE,40
@delete YAW2SRV_*
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Carbonix Volanti RealFlight Parameters
@include ../../CubeOrange-Volanti/defaults.parm
# SITL-specific parameters
AHRS_EKF_TYPE,3
ARSPD_OFFSET,2013
ARSPD_TYPE,2
ARSPD2_OFFSET,2013
ARSPD2_PIN,2
ARSPD2_TYPE,2
BATT_OPTIONS,0 # Disable reporting sag corrected voltage, because it already is (due to RF bug)
BATT2_AMP_PERVLT,8.5
BATT2_CURR_PIN,12
BATT2_MONITOR,4
BATT2_VOLT_MULT,10.1
BATT2_VOLT_PIN,13
BATT3_AMP_PERVLT,8.5
BATT3_CURR_PIN,12
BATT3_MONITOR,4
BATT3_VOLT_MULT,10.1
BATT3_VOLT_PIN,13
BATT4_MONITOR,0
GPS_TYPE,1
GPS_TYPE2,1
@delete INS_*
RNGFND1_PIN,0
RNGFND1_SCALING,40
RNGFND1_TYPE,1
SERVO7_FUNCTION,21 # RealFlight model uses old servo numbering
SIM_ARSPD_RATIO,1.6
SIM_ARSPD2_RATIO,1.6
SIM_GPS_POS_X,-0.12
SIM_GPS_POS_Y,-0.17
SIM_GPS_POS_Z,-0.06
SIM_GPS2_DISABLE,0
SIM_GPS2_POS_X,-0.12
SIM_GPS2_POS_Y,0.17
SIM_GPS2_POS_Z,-0.06
SIM_IMU_POS_X,-0.21
SIM_IMU_POS_Z,-0.03
SIM_MAG1_DEVID,70403
SIM_MAG2_DEVID,72963
SIM_PLD_LAT,43.17443
SIM_PLD_LON,-71.78664
SIM_SONAR_POS_X,-0.12
SIM_SONAR_POS_Z,0.05
SIM_SONAR_SCALE,40

0 comments on commit a515db1

Please sign in to comment.