Exemplo n.º 1
0
#! /usr/bin/env python



from comp0037_planner_controller.occupancy_grid import OccupancyGrid
from comp0037_planner_controller.greedy_planner import GREEDYPlanner

occupancyGrid = OccupancyGrid(21, 21, 0.5)

for y in xrange(0, 19):
    occupancyGrid.setCell(11, y, 1)

start = (3, 18)
goal = (20, 0)

planner = GREEDYPlanner('Greedy Search', occupancyGrid);
planner.setRunInteractively(True)

planner.setWindowHeightInPixels(400)

goalReached = planner.search(start, goal)

path = planner.extractPathToGoal()
from comp0037_planner_controller.astar_by_OD_planner import AStarByODPlanner
from comp0037_planner_controller.astar_by_MD_planner import AStarByMDPlanner
from comp0037_planner_controller.astar_by_SED_planner import AStarBySEDPlanner

# Planners = (FIFOPlanner, LIFOPlanner, GreedyPlanner, GreedyRewiringPlanner, DijkstraPlanner)
Planners = (FIFOPlanner, LIFOPlanner)

for mapindex in range(1, 4):
    occupancyGrid = OccupancyGrid(21, 21, 0.5)
    if mapindex == 0:  #empty map
        start = (2, 18)
        goal = (20, 0)

    elif mapindex == 1:  #One Line Map
        for y in xrange(0, 20):  # set block cell positions here
            occupancyGrid.setCell(11, y, 1)

        start = (0, 0)
        goal = (20, 0)

    elif mapindex == 2:
        for y in xrange(1, 20):  # set block cell positions here
            occupancyGrid.setCell(2, y, 1)
        for y in xrange(0, 18):  # set block cell positions here
            occupancyGrid.setCell(5, y, 1)
        for y in xrange(1, 20):  # set block cell positions here
            occupancyGrid.setCell(8, y, 1)
        for y in xrange(0, 18):  # set block cell positions here
            occupancyGrid.setCell(11, y, 1)
        for y in xrange(1, 20):  # set block cell positions here
            occupancyGrid.setCell(14, y, 1)