def visualization(self, ind, E): if ind % 100 == 0 or self.done: #----------- list structure # V = np.array(list(initparams.V)) # E = initparams.E #----------- end # edges = initparams.E Path = np.array(self.Path) start = self.env.start goal = self.env.goal # edges = E.get_edge() #----------- list structure edges = np.array(list(E)) #----------- end # generate axis objects ax = plt.subplot(111, projection='3d') # ax.view_init(elev=0.+ 0.03*initparams.ind/(2*np.pi), azim=90 + 0.03*initparams.ind/(2*np.pi)) # ax.view_init(elev=0., azim=90.) ax.view_init(elev=8., azim=90.) # ax.view_init(elev=-8., azim=180) ax.clear() # drawing objects draw_Spheres(ax, self.env.balls) draw_block_list(ax, self.env.blocks) if self.env.OBB is not None: draw_obb(ax, self.env.OBB) draw_block_list(ax, np.array([self.env.boundary]), alpha=0) draw_line(ax, edges, visibility=0.75, color='g') draw_line(ax, Path, color='r') # if len(V) > 0: # ax.scatter3D(V[:, 0], V[:, 1], V[:, 2], s=2, color='g', ) ax.plot(start[0:1], start[1:2], start[2:], 'go', markersize=7, markeredgecolor='k') ax.plot(goal[0:1], goal[1:2], goal[2:], 'ro', markersize=7, markeredgecolor='k') # adjust the aspect ratio xmin, xmax = self.env.boundary[0], self.env.boundary[3] ymin, ymax = self.env.boundary[1], self.env.boundary[4] zmin, zmax = self.env.boundary[2], self.env.boundary[5] dx, dy, dz = xmax - xmin, ymax - ymin, zmax - zmin ax.get_proj = make_get_proj(ax, 1 * dx, 1 * dy, 2 * dy) make_transparent(ax) #plt.xlabel('x') #plt.ylabel('y') ax.set_axis_off() plt.pause(0.0001)
def visualization(self): if self.ind % 100 == 0 or self.done: V = np.array(self.V) Path = np.array(self.Path) start = self.env.start goal = self.env.goal # edges = [] # for i in self.Parent: # edges.append([i, self.Parent[i]]) edges = np.array([list(i) for i in self.Edge]) ax = plt.subplot(111, projection='3d') # ax.view_init(elev=0.+ 0.03*initparams.ind/(2*np.pi), azim=90 + 0.03*initparams.ind/(2*np.pi)) # ax.view_init(elev=0., azim=90.) ax.view_init(elev=90., azim=0.) ax.clear() # drawing objects draw_Spheres(ax, self.env.balls) draw_block_list(ax, self.env.blocks) if self.env.OBB is not None: draw_obb(ax, self.env.OBB) draw_block_list(ax, np.array([self.env.boundary]), alpha=0) draw_line(ax, edges, visibility=0.75, color='g') draw_line(ax, Path, color='r') # if len(V) > 0: # ax.scatter3D(V[:, 0], V[:, 1], V[:, 2], s=2, color='g', ) ax.plot(start[0:1], start[1:2], start[2:], 'go', markersize=7, markeredgecolor='k') ax.plot(goal[0:1], goal[1:2], goal[2:], 'ro', markersize=7, markeredgecolor='k') # adjust the aspect ratio set_axes_equal(ax) make_transparent(ax) # plt.xlabel('s') # plt.ylabel('y') ax.set_axis_off() plt.pause(0.0001)
def visualization(self, tree_a, tree_b, index): if (index % 20 == 0 and index != 0) or self.done: # a_V = np.array(tree_a.V) # b_V = np.array(tree_b.V) Path = self.Path start = self.env.start goal = self.env.goal a_edges, b_edges = [], [] for i in tree_a.Parent: a_edges.append([i, tree_a.Parent[i]]) for i in tree_b.Parent: b_edges.append([i, tree_b.Parent[i]]) ax = plt.subplot(111, projection='3d') ax.view_init(elev=8., azim=90.) ax.clear() draw_Spheres(ax, self.env.balls) draw_block_list(ax, self.env.blocks) if self.env.OBB is not None: draw_obb(ax, self.env.OBB) draw_block_list(ax, np.array([self.env.boundary]), alpha=0) draw_line(ax, a_edges, visibility=0.75, color='g') draw_line(ax, b_edges, visibility=0.75, color='y') draw_line(ax, Path, color='r') ax.plot(start[0:1], start[1:2], start[2:], 'go', markersize=7, markeredgecolor='k') ax.plot(goal[0:1], goal[1:2], goal[2:], 'ro', markersize=7, markeredgecolor='k') xmin, xmax = self.env.boundary[0], self.env.boundary[3] ymin, ymax = self.env.boundary[1], self.env.boundary[4] zmin, zmax = self.env.boundary[2], self.env.boundary[5] dx, dy, _ = xmax - xmin, ymax - ymin, zmax - zmin ax.get_proj = make_get_proj(ax, 1 * dx, 1 * dy, 2 * dy) make_transparent(ax) ax.set_axis_off() plt.pause(0.0001)
def visualization(self): if self.ind % 500 == 0: V = np.array(self.V) edges = list(map(list, self.E)) Path = np.array(self.Path) start = self.env.start goal = self.env.goal # edges = E.get_edge() #----------- list structure # edges = [] # for i in self.Parent: # edges.append([i,self.Parent[i]]) #----------- end # generate axis objects ax = plt.subplot(111, projection='3d') # ax.view_init(elev=0.+ 0.03*self.ind/(2*np.pi), azim=90 + 0.03*self.ind/(2*np.pi)) # ax.view_init(elev=0., azim=90.) ax.view_init(elev=90., azim=0.) # ax.view_init(elev=-8., azim=180) ax.clear() # drawing objects draw_Spheres(ax, self.env.balls) draw_block_list(ax, self.env.blocks) if self.env.OBB is not None: draw_obb(ax, self.env.OBB) draw_block_list(ax, np.array([self.env.boundary]), alpha=0) draw_line(ax, edges, visibility=0.75, color='g') draw_line(ax, Path, color='r') if self.show_ellipse: draw_ellipsoid( ax, self.C, self.L, self.xcenter ) # beware, depending on start and goal position, this might be bad for vis if len(V) > 0: ax.scatter3D( V[:, 0], V[:, 1], V[:, 2], s=2, color='g', ) ax.plot(start[0:1], start[1:2], start[2:], 'go', markersize=7, markeredgecolor='k') ax.plot(goal[0:1], goal[1:2], goal[2:], 'ro', markersize=7, markeredgecolor='k') # adjust the aspect ratio ax.dist = 5 set_axes_equal(ax) make_transparent(ax) #plt.xlabel('s') #plt.ylabel('y') ax.set_axis_off() plt.pause(0.0001)