ssardina-research / p4-simulator

Python Path Planning Project (P4)
GNU General Public License v3.0
4 stars 2 forks source link

p4 - Python Path Planning Project

p4 (aka the "Python Path Planning Project is a Python-based path planning framework and simulator, useful to prototype, evaluate, and benchmark path planning algorithms.

The system began as a Python version of the Java-based APPARATE path-planning simulator to be able to prototype algorithms in a "lighter" programming language. It started as part of Peta Masters' 2013 programming course project and then extended to support her Honours thesis and doctorate program, under the supervision of A/Prof. Sebastian Sardina.

The p4 simulator relies on maps in the Movingai format. Run with GUI, to observe their operation, without GUI to obtain cost, steps and time-taken, or in auto mode to output csv files of accumulated results from map problems in .scen format (also from Movingai).

The p4 system has been used in the our Goal Recognition in Path Planning AAMAS'17 and the Deception in Path Planning IJCAI'17 papers.

This dedicated GR fork of this repo for the extensions to p4 related to those works; check the sub-folders:

Check some screenshots of p4: screenshot 1 - screenshot 2 - screenshot 3 - screenshot 4


Prerequisites

Features

Director Structure

Supplied Files include:

Configurations & Options

Config file

CFG_FILE: Configuration file with all settings as Python variables and includes information such as what map and search algorithm to use.

See config.py for expected format.

If config_file or file path not supplied, looks for default config.py.

Cost model

This is the cost model when using mixed-cost grids:

Straight moves are 2 x cost of destination

Diagonal moves are 3*cost of destination

Batch mode

Batch mode, via --batch, allows to read and run problems from a .scen file and outputs results to the OUT_FILE in CSV format.

It can optionally take an integer reps for the number of repetitions across, which test times are to be averaged.

Examples

All run from folder src/.

To see the options:

$ python p4.py --help

Run from customised config file and ASTAR in uniform cost with a deadline of 4 seconds:

$ python p4.py config.py
Total Cost : 510.416305603 | Total Steps : 440 | Time Remaining : 19.519 | Total Time : 0.48086

$ python p4.py

Run by providing a map, start and goal locations, deadline, and agent to use:

$ python p4.py -m ../maps/bloodvenomfalls.map -s 128,405 -g 403,93 -d 4 -a agent_astar
Total Cost : 498.8320 | Total Steps : 421 | Time Remaining : inf | Total Time : 1.258769

Interpreting the results:

Run the GUI with a random agent:

$ python p4.py -m AR0306SR.map  -s 218,110 -g 444,386 -a agent_random  -e euclid -d 20 -gui

Run with mixed cost:

$ python p4.py -m ../maps/bloodvenomfalls.map -c ../maps/mixedcost/G1-W5-S10.cost -s 128,405 -g 403,93 -a agent_astar

Run a BATCH of scenarios described in AR0011SR.map.scen, write results in file astar_batch.csv, each problem is run 3 times (and time averaged across):

$ python p4.py -batch ../maps/bgmaps/AR0011SR.map.scen astar_batch.csv 3 -a agent_astar

Note: if there's a difference between 'optimum' and astar 'actual', check SQRT2 definition in p4_utils.

Output is in CSV format: cost;steps;time_taken;time_remaining, e.g:

187.13708499;154;0.32759;19.672

Interrogate Model Outside Simulator

In the src/ directory run the Python interpreter:

>>>import p4_model as m
>>>l = m.LogicalMap("../maps/mixedcost3.map")   #or other existing map
>>># now you can interrogate the model, e.g...
>>>l.getCost((0,0))                         #note double brackets

Batch and Profiling (Unix only)

Profile a run:

$ python -m cProfile p4.py -s time -m ../maps/AR0306SR.map  -s 218,110 -g 444,386 -a agent_astar -e euclid -d 20

Run it 10 times and get the average time:

$ run 10 /usr/bin/python  p4.py -m ../maps/AR0306SR.map  -s 218,110 -g 444,386 \
        -a agent_jps_inv -e euclid -d 20 | grep Cost | awk '{total += $19} END {print total/10}'

Function run() should be defined (e.g., in .bashrc) as follows:

run() {
    number=$1
    shift
    for i in `seq $number`; do
        bash $@
    done
}

Technical Information

Contributors and Contact

License

This project is using the GPLv3 for open source licensing for information and the license visit GNU website (https://www.gnu.org/licenses/gpl-3.0.en.html).

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program. If not, see http://www.gnu.org/licenses/.


Screenshots

Blue agent navigating to destination:

screenshot

After arrival, area searched (closed list) is shown in yellow:

screenshot

A random agent:

screenshot

Use via terminal to do batch testing (many scenario problems in one map):

screenshot