This repo holds a small example cmake project for a simple vehicle simulation (SVS). It uses a simple model, controller, and python script to graph the simulation in "real-time". This project is meant as an example project to run tools like IKOS wit (https://github.com/NASA-SW-VnV/ikos).
There are three different ways to compile and run the code for SVS
Run the following commands to build simple-vehicle-sim using a bash script
-
bash quick_build
-
./build/svs
Use-h
for optionsExample command:
python visualize/visualize_sim.py
This must be started first to start the tcp server if the-a
option forsvs
is used (see below).In another console:
./build/svs --kp 1.0 -v -m 1000 -a --speed 15.0 --dt 0.05 -p 1
Here are the commands to build simple-vehicle-sim using make
cd make_primary
make clean
make
3.1 (optional) in a seperate terminal runpython visualize/visualizes_sim.py
- './bin/main -a -m 10000 --kp 1.1 -p 1`
Another example of running the main program is:
./bin/main --kp 1.0 -v -m 10000 --speed 15.0 --dt 0.1 -p 1 -a
Run the following commands to build simple-vehicle-sim using cmake
cd simple-vehilce-sim
mkdir build
cd build
cmake ..
make
5.1 (optional) in a seperate terminal runpython visualize/visualizes_sim.py
./svs --kp 1.0 -v -m 1000 -a --speed 5.0 --dt 0.05
To use IKOS for static analysis:
- build svs-sim using the steps above
- run
bash run_ikos.sh
- run
report.sh
cd make_primary
make clean
ikos-scan make
- When prompted to "Analyze bin/main? [Y/n]", type "Y"
- You should see output like this:
# Time stats:
ikos-analyzer: 0.149 sec
ikos-pp : 0.020 sec
# Summary:
Total number of checks : 980
Total number of unreachable checks : 14
Total number of safe checks : 870
Total number of definite unsafe checks: 0
Total number of warnings : 96
- Try
ikos-report bin/main.db
- Try
ikos-view bin/main.db
- Try using
ikos-scan-extract <file_name>.o
. This should generate a<file_name>.bc
. - Try analyzing a program with a specific entry point. IKOS needs an entry point (main). If you have a library in the form of
<file_name>.o
already, you can specify your own main as an entry point:
ikos <file_name>.bc -e=<your_main_file>
[In-the-works]:
sudo apt-get install cbmc
- Run
bash run_cbmc.sh
[In-the-works]:
sudo snap install klee
- You may need to run
alias ktest-tool=/snap/klee/10/usr/local/bin/ktest-tool
or add it to youre ~/.bashrc file at the bottom (up to you). This lets you call ktest-tool anywhere
cd KT_<module_name>
make clean
make
klee linked_<module_name>.bc
ktest-tool klee-last/test<some_number>.ketst
$ ktest-tool klee-last/test000001.ktest
ktest file : 'klee-last/test000001.ktest'
args : ['linked_model.bc']
num objects: 3
object 0: name: 'dt'
object 0: size: 4
object 0: data: b'\x00\x00\x00\x00'
object 0: hex : 0x00000000
object 0: int : 0
object 0: uint: 0
object 0: text: ....
object 1: name: 'speed'
object 1: size: 4
object 1: data: b'\x00\x00\x00\x00'
object 1: hex : 0x00000000
object 1: int : 0
object 1: uint: 0
object 1: text: ....
object 2: name: 'rudder_cmd'
object 2: size: 4
object 2: data: b'\x00\x00\x00\x00'
object 2: hex : 0x00000000
object 2: int : 0
object 2: uint: 0
object 2: text: ....
sudo apt isntall opam
opam init
eval $(opam env)
opam install frama-c
eval $(opam env)
frama-c -cpp-command "gcc -C -E -I ./modules -I ./modules/common" main.c