Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
treyra committed Jul 29, 2024
0 parents commit e6ed869
Show file tree
Hide file tree
Showing 89 changed files with 18,501 additions and 0 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/pylint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Pylint

on: [push]

jobs:
build:
runs-on: ubuntu-20.04
strategy:
matrix:
python-version: ["3.8"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v3
with:
python-version: ${{ matrix.python-version }}
#Current changes from default are: camelCase (preference), line length 100 -> 200 (wide monitors and preference),
#Regex to make variable names 3-40 characters, gives hint
#Removed i,j,k,ex,Run,_ as good names. Added dt and ax, as they are widely used and universal in python.
#import-error disabled (since running on github we assume the user will set up their environment)
#too-many-arguments disabled for now (consider refactoring later to have more compact parameter passing, currently think it is fine)
#Same with too-many-function-args
#too-many-locals disabled for now (consider refactoring later along with less arguments, as the lead to each other. Currently think it is fine)
#ignored-argument-names used as a hack for dummy arguments for now.
- name: Install dependencies and configure
run: |
python -m pip install --upgrade pip
pip install pylint
pylint --generate-rcfile > ~/.pylintrc
sed -i 's/snake_case/camelCase/g' ~/.pylintrc
sed -i 's/max-line-length=100/max-line-length=200/g' ~/.pylintrc
sed -i 's/good-names-rgxs=/good-names-rgxs=[a-z_][a-z0-9_]{2,40}/g' ~/.pylintrc
sed -i 's/include-naming-hint=no/include-naming-hint=yes/g' ~/.pylintrc
sed -i 's/good-names=i,/good-names=dt,ax,iii,/g' ~/.pylintrc
sed -i 's/ j,/ jjj,/g' ~/.pylintrc
sed -i 's/ k,/ kkk,/g' ~/.pylintrc
sed -i 's/ ex,/ exx,/g' ~/.pylintrc
sed -i 's/ Run,/ run,/g' ~/.pylintrc
sed -i 's/ _/ iii/g' ~/.pylintrc
sed -i 's/ j,/ jjj,/g' ~/.pylintrc
sed -i 's/bad-names=/bad-names=i,j,k,/g' ~/.pylintrc
sed -i 's/disable=/disable=import-error,too-many-arguments,too-many-function-args,too-many-locals,duplicate-code,/g' ~/.pylintrc
sed -i 's/ignored-argument-names=_.*|^ignored_|^unused_/ignored-argument-names=_.*|^ignored_|^unused_|dummy/g' ~/.pylintrc
- name: Analyzing the code with pylint
run: |
pylint $(git ls-files '*.py')
38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
SavedData/*
*/SavedData/*

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
installNoiseTesting.sh
*.swp
failurePy/utility/CalibrationData/*
*checkpoint.ipynb
failurePy/utility/test.ipynb
failurePy/visualization/.ipynb_checkpoints/FTC Paper Visualization-checkpoint.ipynb

failurePy/visualization/*.pdf
failurePy.egg-info/*
dFailurePy.egg-info/*
.config/config.yml
.config/hosts.yml
failurePy/.DS_Store
failurePy/.config/config.yml
failurePy/.config/hosts.yml
SavedData/*
*/SavedData/*

# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
installNoiseTesting.sh
*.swp
failurePy/utility/CalibrationData/*
*checkpoint.ipynb
failurePy/utility/test.ipynb
failurePy/visualization/.ipynb_checkpoints/FTC Paper Visualization-checkpoint.ipynb

failurePy/visualization/*.pdf
failurePy.egg-info/*
dFailurePy.egg-info/*
*.DS_Store
28 changes: 28 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Python: Pipeline",
"type": "python",
"request": "launch",
"program": "failurePy/pipeline.py",
"justMyCode": false,
//"cwd": "failurePy",
"args": [
//"--configFilePath",
"./failurePy/config/safetyNonLinearModelTest4.yaml"
]
}
//{
// "name": "Python: Remove Tree Data",
// "type": "python",
// "request": "launch",
// "program": "utility/savedTreeRemover.py",
// "justMyCode": false,
// "cwd": "failurePy"
//}
]
}
19 changes: 19 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"python.analysis.diagnosticSeverityOverrides": { //Disable rerportMissingImports, as VS Code seems to miss local imports (and because using VS code in windows and conda env in WSL seems to be cause missed imports too)
"reportMissingImports": "none",
"reportMissingModuleSource": "none",
"todohighlight.keywords": [
"DEBUG:",
],
},
"cSpell.words": [
"argnames",
"edgecolor",
"fejekf",
"fejkalman",
"fontsize""horizontalalignment",
"Labbe",
"pcov"
],
"python.REPL.enableREPLSmartSend": false
}
5 changes: 5 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Copyright 2024 James Ragan.

The data and code here are for personal and educational use only and provided without warranty; written permission from the authors is required for further use. Please cite our work when the article is published.

FilterPy library adapted under MIT license, copyright 2014-2018 Roger R Labbe Jr. Full license in readme.md located here http://github.com/rlabbe/filterpy
Empty file added failurePy/__init__.py
Empty file.
115 changes: 115 additions & 0 deletions failurePy/config/binaryFaultModelExample.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
#Example showing our binary fault model under an averse fault like the simulations shown in our paper.
#Initiate experiment by running "python pipeline.py ./config/binaryFaultModelExample.yaml" in the failurePy directory
nSimulationsPerTree: #This is a list of simulation levels to run
- 200

nTrialsPerPoint: 1 #How many times to repeat each experiment configuration

dim: 3
linear: False
spacecraftMass: 1
spacecraftMoment: 4
sigmaW:
- 0.2
- 0.2
- 0.01
sigmaV: .4
discretization: .125
dt: 1

numWheels: 2
providedFailure: #1 indicates nominal, 0 indicates failure
- 1
- 1
- 1
- 1
- 1
- 1
- 0
- 0
- 1
- 1
- 1
- 1
- 1
- 1
- 1
- 1

maxNumActions: 20
rngKeysOffset: 0
actionRNGSeed: 0 # Actions are selected randomly, but same for every trial

#Not letting simulation break early to enforce safety over full experiment
diagnosisThreshold: 1.1
nMaxComponentFailures: 3

initialState:
- 0
- 0
- 0 #Giving 10 time steps until collision
- -1
- 0
- 0
- 0
- 0

nExperimentSteps: 15 #Didn't see any noticeable changes with more time steps, so less to run faster

solverFList:
- sFEAST
#- cbf #Baseline methods, to use, note "nSimulationsPerTree" must be 1
#- greedy
#- scp

estimator: marginalizedFilter
physicalStateSubEstimator: ekf #Required sub filter if using marginal filter
reward: squareSumFailureBeliefReward

safetyMethod: safetyConstrainedReward
safetyFunctionEvaluation: chebyshev
allowableFailureChance: .10
safetyFunction: worstCase
safetyConstraints: #Should be nested list, constraint, and parameters
- - circularObstacleConstraint
- - 10 #Radius (Currently obstacle + s/c radius)
- - 0 #center x
- -20 #center y
#- - circularSafeZoneConstraint
# - - 30 #Radius (Currently safe zone - s/c radius)
# - - 0 #center x
# - 0 #center y
#Square constraint, normal matrix, offset
- - linearSafeZoneConstraint #Of form Ax - b < 0, need all to be satisfied. Here is is a 60x60 rect around origin
- - - - 1 #First row of A matrix, should be external normals
- 0
- - -1 #next row of A matrix
- 0
- - 0
- 1
- - 0
- -1
- - 25 #First offset
- 25
- 25
- 25

saveDirectoryPath: binaryExample
clobber: True #Overwrites data when true!

nMaxPossibleFailures: 40

#Plotting config
plottingExtent: 30
resolution: 100

generalFaultFlag: False

particleResampleType: gaussian
particleResampleCheck: never
particleInitializationFunction: biasedRandomRedundant #Biased to 1/2 chance to be nominal, biases repeated x5

saveTreeFlag: True #Visualizes the tree search, but this must be disabled when running more than one trial, as it produces a lot of data

multiprocessingFlag: False #To enable multiprocessing (useful when running any trials per point), type a number to represent how many CPU cores should NOT be used by failurePy. Note this can have undefined behavior if more cores are provided than trials are run
discountFactor: 1
91 changes: 91 additions & 0 deletions failurePy/config/figure5/binaryAdverseCrashCourse.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
nSimulationsPerTree:
- 0
#- 20
- 80
- 200
- 600
#- 1000
- 2000
nTrialsPerPoint: 1
dim: 3
linear: false
spacecraftMass: 1
spacecraftMoment: 4
sigmaW:
- 0.2
- 0.2
- 0.01
sigmaV: 0.4
discretization: 0.125
dt: 1
nExperimentSteps: 15
saveTrajectory: true
providedFailure:
- 1
- 1
- 1
- 1
- 1
- 1
- 0
- 0
- 1
- 1
- 1
- 1
- 1
- 1
- 1
- 1
maxNumActions: 20
rngKeysOffset: 0
actionRNGSeed: 0
diagnosisThreshold: 1.9
nMaxComponentFailures: 3
initialState:
- 0
- 0
- 0
- -1
- 0
- 0
- 0
- 0
solverFList:
- SFEAST
estimator: marginalizedFilter
physicalStateSubEstimator: ekf
reward: squareSumFailureBeliefReward
safetyMethod: safetyConstrainedReward
penalty: 0
safetyFunctionEvaluation: chebyshev
allowableFailureChance: 0.1
safetyFunction: worstCase
safetyConstraints:
- - circularObstacleConstraint
- - 10
- - 0
- -20
- - linearSafeZoneConstraint
- - - - 1
- 0
- - -1
- 0
- - 0
- 1
- - 0
- -1
- - 25
- 25
- 25
- 25
saveDirectoryPath: figure5/binaryAdverseCrashCourse
clobber: false
nMaxPossibleFailures: 40
saveTreeFlag: false
multiprocessingFlag: 10
plottingExtent: 30
resolution: 400
hardwareEmulationFlag: false
filterDivergenceHandlingMethod: acceptDiagnosisBeforeNan
discountFactor: 1
Loading

0 comments on commit e6ed869

Please sign in to comment.