env3D.py 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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():
  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([j for j in i])
  21. return np.array(Obstacles)
  22. def getballs():
  23. spheres = [[16,2.5,3,2],[10,2.5,1,1]]
  24. Obstacles = []
  25. for i in spheres:
  26. Obstacles.append([j for j in i])
  27. return np.array(Obstacles)
  28. class env():
  29. def __init__(self, xmin=0, ymin=0, zmin=0, xmax=20, ymax=5, zmax=6, resolution=1):
  30. self.resolution = resolution
  31. self.boundary = np.array([xmin, ymin, zmin, xmax, ymax, zmax])
  32. self.blocks = getblocks()
  33. self.balls = getballs()
  34. self.start = np.array([0.5, 2.5, 5.5])
  35. self.goal = np.array([19.0, 2.5, 5.5])
  36. def visualize(self):
  37. # fig = plt.figure()
  38. # TODO: do visualizations
  39. return
  40. if __name__ == '__main__':
  41. newenv = env()
  42. print(newenv.balls)