Astar3D.py 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. # this is the three dimensional A* algo
  2. # !/usr/bin/env python3
  3. # -*- coding: utf-8 -*-
  4. """
  5. @author: yue qi
  6. """
  7. import numpy as np
  8. import os
  9. import sys
  10. sys.path.append(os.path.dirname(os.path.abspath(__file__)) + "/../../Search-based Planning/")
  11. from Astar_3D.env3D import env
  12. from Astar_3D.utils3D import getAABB, getDist, getRay, StateSpace, Heuristic, getNearest
  13. import queue
  14. class Weighted_A_star(object):
  15. def __init__(self):
  16. self.Alldirec = np.array([[1 ,0,0],[0,1 ,0],[0,0, 1],[1 ,1 ,0],[1 ,0,1 ],[0, 1, 1],[ 1, 1, 1],\
  17. [-1,0,0],[0,-1,0],[0,0,-1],[-1,-1,0],[-1,0,-1],[0,-1,-1],[-1,-1,-1],\
  18. [1,-1,0],[-1,1,0],[1,0,-1],[-1,0, 1],[0,1, -1],[0, -1,1],\
  19. [1,-1,-1],[-1,1,-1],[-1,-1,1],[1,1,-1],[1,-1,1],[-1,1,1]])
  20. self.env = env()
  21. self.Space = StateSpace(self.env.boundary) # key is the point, store g value
  22. self.OPEN = queue.QueuePrior() # store [point,priority]
  23. self.start = getNearest(self.Space,self.env.start)
  24. self.goal = getNearest(self.Space,self.env.goal)
  25. self.h = Heuristic(self.Space,self.goal)
  26. self.Parent = {}
  27. self.CLOSED = {}
  28. def run(self):
  29. pass
  30. if __name__ == '__main__':
  31. Astar = Weighted_A_star()