Example #1
0
 def __init__(self, resolution=0.5):
     self.Alldirec = {(1, 0, 0): 1, (0, 1, 0): 1, (0, 0, 1): 1, \
                     (-1, 0, 0): 1, (0, -1, 0): 1, (0, 0, -1): 1, \
                     (1, 1, 0): np.sqrt(2), (1, 0, 1): np.sqrt(2), (0, 1, 1): np.sqrt(2), \
                     (-1, -1, 0): np.sqrt(2), (-1, 0, -1): np.sqrt(2), (0, -1, -1): np.sqrt(2), \
                     (1, -1, 0): np.sqrt(2), (-1, 1, 0): np.sqrt(2), (1, 0, -1): np.sqrt(2), \
                     (-1, 0, 1): np.sqrt(2), (0, 1, -1): np.sqrt(2), (0, -1, 1): np.sqrt(2), \
                     (1, 1, 1): np.sqrt(3), (-1, -1, -1) : np.sqrt(3), \
                     (1, -1, -1): np.sqrt(3), (-1, 1, -1): np.sqrt(3), (-1, -1, 1): np.sqrt(3), \
                     (1, 1, -1): np.sqrt(3), (1, -1, 1): np.sqrt(3), (-1, 1, 1): np.sqrt(3)}
     self.settings = 'NonCollisionChecking'  # 'NonCollisionChecking' or 'CollisionChecking'
     self.env = env(resolution=resolution)
     self.start, self.goal = tuple(self.env.start), tuple(self.env.goal)
     self.g = {self.start: 0, self.goal: np.inf}
     self.Parent = {}
     self.CLOSED = set()
     self.V = []
     self.done = False
     self.Path = []
     self.ind = 0
     self.x0, self.xt = self.start, self.goal
     self.OPEN = queue.MinheapPQ()  # store [point,priority]
     self.OPEN.put(self.x0, self.g[self.x0] +
                   heuristic_fun(self, self.x0))  # item, priority = g + h
     self.lastpoint = self.x0
Example #2
0
    def __init__(self,resolution = 1):
        self.Alldirec = {(1, 0, 0): 1, (0, 1, 0): 1, (0, 0, 1): 1, \
                        (-1, 0, 0): 1, (0, -1, 0): 1, (0, 0, -1): 1, \
                        (1, 1, 0): np.sqrt(2), (1, 0, 1): np.sqrt(2), (0, 1, 1): np.sqrt(2), \
                        (-1, -1, 0): np.sqrt(2), (-1, 0, -1): np.sqrt(2), (0, -1, -1): np.sqrt(2), \
                        (1, -1, 0): np.sqrt(2), (-1, 1, 0): np.sqrt(2), (1, 0, -1): np.sqrt(2), \
                        (-1, 0, 1): np.sqrt(2), (0, 1, -1): np.sqrt(2), (0, -1, 1): np.sqrt(2), \
                        (1, 1, 1): np.sqrt(3), (-1, -1, -1) : np.sqrt(3), \
                        (1, -1, -1): np.sqrt(3), (-1, 1, -1): np.sqrt(3), (-1, -1, 1): np.sqrt(3), \
                        (1, 1, -1): np.sqrt(3), (1, -1, 1): np.sqrt(3), (-1, 1, 1): np.sqrt(3)}
        self.env = env(resolution=resolution)
        self.g = g_Space(self)
        self.start, self.goal = getNearest(self.g, self.env.start), getNearest(self.g, self.env.goal)
        self.x0, self.xt = self.start, self.goal
        self.rhs = g_Space(self) # rhs(.) = g(.) = inf
        self.rhs[self.start] = 0 # rhs(x0) = 0
        self.h = Heuristic(self.g, self.goal)
        
        self.OPEN = queue.MinheapPQ()  # store [point,priority]
        self.OPEN.put(self.x0, [self.h[self.x0],0])
        self.CLOSED = set()

        # used for A*
        self.done = False
        self.Path = []
        self.V = []
        self.ind = 0

        # initialize children list
        self.CHILDREN = {}
        self.getCHILDRENset()

        # initialize cost list
        self.COST = {}
        _ = self.costset()
 def __init__(self,resolution=0.5):
     self.Alldirec = {(1, 0, 0): 1, (0, 1, 0): 1, (0, 0, 1): 1, \
                     (-1, 0, 0): 1, (0, -1, 0): 1, (0, 0, -1): 1, \
                     (1, 1, 0): np.sqrt(2), (1, 0, 1): np.sqrt(2), (0, 1, 1): np.sqrt(2), \
                     (-1, -1, 0): np.sqrt(2), (-1, 0, -1): np.sqrt(2), (0, -1, -1): np.sqrt(2), \
                     (1, -1, 0): np.sqrt(2), (-1, 1, 0): np.sqrt(2), (1, 0, -1): np.sqrt(2), \
                     (-1, 0, 1): np.sqrt(2), (0, 1, -1): np.sqrt(2), (0, -1, 1): np.sqrt(2), \
                     (1, 1, 1): np.sqrt(3), (-1, -1, -1) : np.sqrt(3), \
                     (1, -1, -1): np.sqrt(3), (-1, 1, -1): np.sqrt(3), (-1, -1, 1): np.sqrt(3), \
                     (1, 1, -1): np.sqrt(3), (1, -1, 1): np.sqrt(3), (-1, 1, 1): np.sqrt(3)}
     self.env = env(resolution = resolution)
     self.start, self.goal = tuple(self.env.start), tuple(self.env.goal)
     self.g = {self.start:0,self.goal:0}
     self.OPEN1 = queue.MinheapPQ() # store [point,priority]
     self.OPEN2 = queue.MinheapPQ()
     self.Parent1, self.Parent2 = {}, {}
     self.CLOSED1, self.CLOSED2 = set(), set()
     self.V = []
     self.done = False
     self.Path = []