env3D.py 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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,
  21. i[5] / resolution))
  22. return np.array(Obstacles)
  23. class env():
  24. def __init__(self, xmin=0, ymin=0, zmin=0, xmax=20, ymax=5, zmax=6, resolution=1):
  25. self.resolution = resolution
  26. self.boundary = np.array([xmin, ymin, zmin, xmax, ymax, zmax]) / resolution
  27. self.blocks = getblocks(resolution)
  28. self.start = np.array([0.5, 2.5, 5.5])
  29. self.goal = np.array([19.0, 2.5, 5.5])
  30. def visualize(self):
  31. # fig = plt.figure()
  32. # TODO: do visualizations
  33. return
  34. if __name__ == '__main__':
  35. newenv = env()
  36. X = StateSpace(newenv.boundary, newenv.resolution)
  37. print(X)