peveloper / bachelor-project

The bachelor project repository

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using Machine Learning and Simulation to predict the traversability of a given terrain by a simple robot

Requirements

Scene Setup

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.

Simulation

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   

Classification

Setup

Install openCV latest version,

$ brew tap homebrew/science
$ brew install opencv

... and python required modules

$ pip install -r requirements.txt

Dataset Generation

$ cd scripts/classifier
$ generate_dataset.py -c <csv_filename> -i <heightmap_filename> -o <segments_filename> -d <dataset_filename>

Training

$ python train.py -t <dataset_filename> -o <brain_filename>

Testing and Evaluation

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>

About

The bachelor project repository


Languages

Language:Lua 49.3%Language:Python 41.5%Language:Shell 7.7%Language:MATLAB 1.5%