当前位置: 首页>>代码示例>>Python>>正文


Python Delaunay.sum方法代码示例

本文整理汇总了Python中scipy.spatial.Delaunay.sum方法的典型用法代码示例。如果您正苦于以下问题:Python Delaunay.sum方法的具体用法?Python Delaunay.sum怎么用?Python Delaunay.sum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在scipy.spatial.Delaunay的用法示例。


在下文中一共展示了Delaunay.sum方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_reachability_graph

# 需要导入模块: from scipy.spatial import Delaunay [as 别名]
# 或者: from scipy.spatial.Delaunay import sum [as 别名]
  def create_reachability_graph(self, args):
    robot_xml = args.robot_xml
    n_data_points = int(args.data_points)
    show_graph = args.show_graph
    log_file = args.log_file
    clip_zero_pts = args.clip_zero_pts
    volume_graph = args.volume_graph

    from scipy.spatial import ConvexHull
    from scipy.spatial import Delaunay
    from mpl_toolkits.mplot3d import Axes3D

    rospy.loginfo('Loading reachability database for %s' % robot_xml)

    # load up the data
    ppfile = self.get_filename(robot_xml, args.manipname)
    f=h5py.File(ppfile,'r')
    reachability3d = f['reachability3d'].value
    
    total_pts = reachability3d.size
    
    nonzero_tot_pts = (reachability3d > 0).sum()
    rospy.loginfo('%d out of %d total tested points are reachable (%f%%)' % (nonzero_tot_pts,total_pts,(float(nonzero_tot_pts)/float(total_pts))*100.))
    
    #~ if volume_graph:
      #~ from scipy import ndimage #for volume graph
      #~ desired_reach = 0.95
      #~ volmask = reachability3d >= desired_reach
      #~ regions, nregs = ndimage.label(volmask)
      #~ 
      #~ fig = plot.figure()
      #~ ax = fig.add_subplot(111, projection='3d')
      #~ x,y,z = numpy.where(reachability3d >= desired_reach)
      #~ every = 2
      #~ ax.scatter(x[0::every],y[0::every],z[0::every],c=((0.5,0.5,1,0.8)))
      #~ 
      #~ cmap = plot.get_cmap('jet')
      #~ for reg in range(1,nregs):
        #~ x,y,z = numpy.where(regions == reg)
        #~ print "region %s: %s points"%(reg,x.size)
        #~ ax.scatter(x[0::every],y[0::every],z[0::every],c=cmap(float(reg)/float(nregs)))
        #~ 
      #~ plot.show()
      #~ exit()
    
    #orientations range between 0 and 1
    #~ orientations = [float(x)/float(n_data_points) + 1/float(n_data_points) for x in range(n_data_points)]
    orientations = [float(x)/float(n_data_points) for x in range(n_data_points)]
    
    #omit points with zero reachability (improves graph)
    if clip_zero_pts:
      orientations[0] += 1/(100*float(n_data_points))
    
    rospy.loginfo('Calculating Reachable Zone Convex Hull')
    
    #get nonzero indices
    x,y,z = numpy.where(reachability3d > 0)
    nz_points = numpy.array([[x[i],y[i],z[i]] for i in range(len(x))])
    convex_hull = ConvexHull(nz_points)
    
    #Plotting! plot the convex hull
    #~ fig = plot.figure()
    #~ ax = fig.add_subplot(111, projection='3d')
    #~ colourmap = []
    #~ colours = plot.get_cmap('jet')
    #~ for i in range(len(x)):
      #~ pt_val = reachability3d[x[i],y[i],z[i]]
      #~ col = colours(pt_val/1.2)
      #~ colour = col#(col[0],col[1],col[2],pt_val) #vary alpha too
      #~ colourmap.append(colour)
    #~ every = 5
    #~ ax.scatter(x[0::every],y[0::every],z[0::every],c=colourmap[0::every],marker='o')
    #~ for simplex in convex_hull.simplices:
      #~ plot.plot(x[simplex],y[simplex],z[simplex],'--',c=(1,0,0,1))
    #~ plot.show()
    
    #~ #Plotting! plot 2D convex hull
    #~ fig = plot.figure()
    #~ colourmap = []
    #~ colours = plot.get_cmap('jet')
    #~ for i in range(len(x)):
      #~ if z[i] > 65 and z[i] < 75:
        #~ pt_val = reachability3d[x[i],y[i],z[i]]
        #~ col = colours(pt_val*5)
        #~ plot.plot(y[i],x[i],'o',c=col)
    #~ plot.show() 
    #~ fig = plot.figure()
    #~ colourmap = []
    #~ colours = plot.get_cmap('jet')
    #~ for i in range(len(x)):
      #~ if x[i] > 50 and x[i] < 60:
        #~ pt_val = reachability3d[x[i],y[i],z[i]]
        #~ col = colours(pt_val*5)
        #~ plot.plot(y[i],z[i],'o',c=col)
    #~ plot.show() 
    
    #~ #Plotting! plot whole workspace
    #~ fig = plot.figure()
    #~ ax = fig.add_subplot(111, projection='3d')
    #~ colourmap = []
#.........这里部分代码省略.........
开发者ID:fsuarez6,项目名称:moveit_kinematic_reachability,代码行数:103,代码来源:reachability_workspace.py


注:本文中的scipy.spatial.Delaunay.sum方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。