I worked on the project through a virtual environment with virtualenvwrapper
and I highly recommend to do so as well. However, whether or not you are in a
virtual environment, the installation proceeds as follows:
-
For downloading and installing the source code of the project:
$ cd <directory you want to install to> $ git clone https://github.com/QDucasse/fdia_simulation $ python setup.py install
-
For downloading and installing the source code of the project in a new virtual environment:
Download of the source code & Creation of the virtual environment
$ cd <directory you want to install to> $ git clone https://github.com/QDucasse/fdia_simulation $ cd fdia_simulation $ mkvirtualenv -a . -r requirements.txt VIRTUALENV_NAME
Launch of the environment & installation of the project
$ workon VIRTUALENV_NAME $ pip install -e .
Launch of the basic GUI
$ python fdia_simulation/app.py
Note that the GUI does not contain all the features of the project but allows you getting familiar with the components and interactions between them.
Quick presentation of the different modules of the project:
- Models: Dynamic systems models.
- Anomaly detectors: Detectors of wrong values coming from the sensors.
- Filters: State estimators with different models/combinations.
- Attackers: Controllers of a sensor modifying its outputed values.
- Benchmarks: Wrapper of the module through a simplified interface.
- Helpers: Plotting and file writer tools.
The examples folder provides a handfull of situations made possible by this project as well as a benchmark template if you want to try the different functionalities with some guidelines.
NOTE: more information can be obtained through the README.md
of each module and
therefore simply by clicking on those modules.
This project uses five main libraries:
NumPy
as the array/numerical handlerSciPy
as the handler for matrix operationsMatplotlib
as the plot handlerFilterPy
as the starting point of filter design/state estimationSymPy
as a Jacobian matrix finder using symbolic calculus
If installed as specified above, the requirements are stated in the requirements.txt
file
and therefore automatically installed.
However, you can install each of them separately with the command:
$ pip install <library>
NOTE: This project was created with Python 3.7.3 and no backward compatibility is ensured.
We will first need to import the essential components from the different packages:
models
from which we will extract our track and radarfilters
where from which we will extract our system estimatorbenchmarks
from which we will extract the high-level benchmark object.
from fdia_simulation.models import Radar, Track
from fdia_simulation.filters import RadarFilterCA
from fdia_simulation.benchmarks import Benchmark
Then, we need to create and link those components
## Trajectory Generation
trajectory = Track()
states = trajectory.gen_takeoff() # Takeoff trajectory here
x0,y0,z0 = trajectory.initial_position()
# Initial position that will be passed to the filter
## Radar Creation
radar = Radar(x=0,y=500)
## Estimator Creation
radar_filter_ca = RadarFilterCA(dim_x = 9, dim_z = 3, q = 3070.,
x0 = x0, y0 = y0, z0 = z0, radar = radar)
# Here, the model chosen for the filter is CA (Constant Acceleration)
Now that all our elements are instanciated, we need to run the cycle described above. This operation is made by the benchmark object through a process of:
- Data generation from the Track/Radar
- Processing of the filter's Predict/Update cycles over the generated measurements
- Addition of the Attacker's input in order to modify (part of) the incoming measurements
- Computation of a Performance criteria
- Plotting of the trajectory, performance and model probabilities (in case of IMM)
## Benchmark Creation
benchmark_ca = Benchmark(radars = radar, radar_filter = radar_filter_ca,states = states)
benchmark_ca.launch_benchmark(with_nees = True)
- State generation for different trajectories (take off, landing, ...)
- Measurements generation by radars from system states
- Anomaly detection on simple systems
- Anomaly detection in the ATC simulation
- 4 filter models (CA, CV, CT and TA) for one radar
- 4 filter models for multiple radars
- 4 filter models for multiple radars with different data rates
- IMM Estimator for one radar working in all cases
- Attacker model for the three cases
- Two attacker types (brute force and inducted drift) for the three cases
- Benchmark wrapper for the three cases
- Performance indicator for one and two radars with the same data rate
- Performance indicator for radars with different data rates
- Process noise finder for one given model in the three cases
- Process noise finder for an IMM in the three cases
- Unit tests for all components
- Documentation via docstrings/READMEs
- Installation guide
All 570~ tests are written to work with nose
and/or pytest
. Just type pytest
or
nosetests
as a command line in the project. Every test file can still be launched
by executing the testfile itself.
$ python fdia_simulation/tests/chosentest.py
$ pytest
$ nosetests
The tests are not robust as they verify the integrity of the data generated but not its quality. What that means is that even if the result of a filter might be considered bad as the estimation is not correct, his behavior is correct. Testing the reaction of a bad designed filtered on a very demanding trajectory is not the point of the project. However, many examples allow you to try and test the results of many different combinations and that is how the filter should be designed.
I used Roger Labbe Jr. "Kalman and Bayesian Filters in Python" as a starting point and not only did it showed me the FilterPy library but it also made me discover Bar Shalom "Estimation with Application to Tracking and Navigation" providing an in-depth take on the subject with several examples.