env3D.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. # this is the three dimensional configuration space for rrt
  2. #!/usr/bin/env python3
  3. # -*- coding: utf-8 -*-
  4. """
  5. @author: yue qi
  6. """
  7. import numpy as np
  8. def getblocks(resolution):
  9. # AABBs
  10. block = [[3.10e+00,0.00e+00,2.10e+00,3.90e+00,5.00e+00,6.00e+00],
  11. [9.10e+00,0.00e+00,2.10e+00,9.90e+00,5.00e+00,6.00e+00],
  12. [1.51e+01,0.00e+00,2.10e+00,1.59e+01,5.00e+00,6.00e+00],
  13. [1.00e-01,0.00e+00,0.00e+00,9.00e-01,5.00e+00,3.90e+00],
  14. [6.10e+00,0.00e+00,0.00e+00,6.90e+00,5.00e+00,3.90e+00],
  15. [1.21e+01,0.00e+00,0.00e+00,1.29e+01,5.00e+00,3.90e+00],
  16. [1.81e+01,0.00e+00,0.00e+00,1.89e+01,5.00e+00,3.90e+00]]
  17. Obstacles = []
  18. for i in block:
  19. i = np.array(i)
  20. Obstacles.append((i[0]/resolution,i[1]/resolution,i[2]/resolution,i[3]/resolution,i[4]/resolution,i[5]/resolution))
  21. return np.array(Obstacles)
  22. class env():
  23. def __init__(self,xmin=0,ymin=0,zmin=0,xmax=20,ymax=5,zmax=6,resolution=1):
  24. self.resolution = resolution
  25. self.boundary = np.array([xmin,ymin,zmin,xmax,ymax,zmax])/resolution
  26. self.blocks = getblocks(resolution)
  27. self.start = np.array([0.5, 2.5, 5.5])
  28. self.goal = np.array([19.0, 2.5, 5.5])
  29. def visualize(self):
  30. # fig = plt.figure()
  31. # TODO: do visualizations
  32. return
  33. if __name__ == '__main__':
  34. newenv = env()
  35. X = StateSpace(newenv.boundary,newenv.resolution)
  36. print(X)