예제 #1
0
				if hipothesis_location in self.graph.edges[observed_location]:
					self.graph.edges[observed_location].remove(hipothesis_location)

				observed_location = (self.location[0], self.location[1]+observation, (orientation+2)%4)
				hipothesis_location = (self.location[0], self.location[1]+observation+1, (orientation+2)%4)
				if observed_location in self.graph.edges[hipothesis_location]:
					self.graph.edges[hipothesis_location].remove(observed_location)

			

if __name__ == "__main__":
	from file_loader import FileLoader
	from time import sleep

	f_loader = FileLoader()
	f_loader.read_map('Mapas/With_Start/lab4.map')
	f_loader.generate_undirected_graph()
	f_loader.estimate_distances()

	location = f_loader.starts[0]
	goals    = f_loader.goals
	max_col  = f_loader.max_cols
	max_row  = f_loader.max_rows
	
	mapper   = Mapper(max_col,max_row,location,goals)
	mapper.init_map()

	print 'Location: ', mapper.location
	print 'Goals: ', mapper.goal

	test_path = [mapper.location]
예제 #2
0
    """
    A simple undirected, weighted graph
    """
    def __init__(self):
        self.nodes = set()
        self.edges = {}
        self.distances = {}

    def add_node(self, value):
        #print '\t>>UndirectedGraph::Adding node: ', value
        self.nodes.add(value)

    def add_edge(self, from_node, to_node, distance=1):
        #print '\t>>UndirectedGraph::Adding edge: ', from_node, ' - ', to_node
        self._add_edge(from_node, to_node, distance)
        self._add_edge(to_node, from_node, distance)

    def _add_edge(self, from_node, to_node, distance):
        self.edges.setdefault(from_node, [])
        self.edges[from_node].append(to_node)
        self.distances[(from_node, to_node)] = distance

if __name__ == '__main__':
    from file_loader import FileLoader
    loader=FileLoader()

    loader.read_map("Mapas/With_Start/lab4.map")
    loader.generate_directed_graph()

    print loader.directed_graph.get_map()
예제 #3
0
if __name__=="__main__":

	import multiprocessing
	from localization import Localization
	from planner import Planner
	from mapper import Mapper
	from file_loader import FileLoader
	from enums import Action, Sign
	import properties
	import time

	filename = properties.file_name

	f_loader = FileLoader()
	f_loader.read_map(filename)
	f_loader.generate_undirected_graph()
	f_loader.generate_directed_graph()
	f_loader.estimate_distances()

	location 		= f_loader.starts[0]
	goals    		= f_loader.goals
	max_col  		= f_loader.max_cols
	max_row  		= f_loader.max_rows
	graph    		= f_loader.directed_graph
	node_distance 	= f_loader.node_distance
	walls = f_loader.walls
	keys = f_loader.keys

	signals = {}
	signals[(1,0,1)] = Sign.turn_left