Using Machine Learning and Simulation to predict the traversability of a given terrain by a simple robot
- V-REP (v. 3.3.0 min)
- python (v. 2.7 required)
- openCV(v. 2.4.12_2 required)
- MatLab(v. r2015b min)
Open V-REP, modify the main script with the following two lines:
local f = loadfile('YOUR_PATH/BachelorProject/scripts/main.lua')
return f()
Now import an heightfield, File -> Import -> heightfield. You can import a custom one or either a one generated by gen_heightmaps.m. If you want to generate a collection of terrains, just:
$ cd scripts/
$ /Applications/<MATLAB_VERSION>/bin/matlab -nodisplay -nojvm -nosplash -nodesktop -r gen_heightmaps
Save the scene in the default scenes/ folder.
To Launch the simulations
$ cd scripts/
$ ./run_simulations [-n <n_simulations>] -s <scene_filename> [-t <max_sim_time_in_ms] [-d <goal_distance>] [-v <robot_velocity>] -o <csv_filename>
Then
$ cd ..
Now you should have a structure like this:
BachelorProject
│ README.md
│ requirements.txt
│
└───docs
│ Just txt and pdfs files
│
└───scenes
│ │ img1.ttt (sample scene)
│
└───models
│ │ offroad.ttm
│
└───data
│ │
| └───csv
│ │ │ csv_filename.csv
│ │
│ └───heightmaps (if generated)
| │ bunch of images
│
└───scripts
|
└───classifier
│ │ gen_dataset.py
│ │ plot_heatmap.py
│ │ plot_roc.py
│ │ test.py
│ │ train.py
│
└───controller
│ │ class.lua
│ │ point.lua
│ │ robot.lua
│
│ gen_heightmaps.m
│ main.lua
│ run_simulations.sh
Install openCV latest version,
$ brew tap homebrew/science
$ brew install opencv
... and python required modules
$ pip install -r requirements.txt
$ cd scripts/classifier
$ generate_dataset.py -c <csv_filename> -i <heightmap_filename> -o <segments_filename> -d <dataset_filename>
$ python train.py -t <dataset_filename> -o <brain_filename>
You can test the accuracy of predictions made by the classifier by running
$ python test.py -t <brain_filename> -e <testing_dataset_filename> -c <cross_validation_method>
You can even plot some charts, like the ROC_curve
$ python plot_roc.py -t <trained_model> -e <testing_dataset> -c <cross_validation_method>
or heatmaps of the traversability of the analyzed terrain area (in a specified direction)
$ plot_heatmap.py -i <input_image> -t <trained_model> -d <distance> -v <direction>