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


Python Robot.draw方法代码示例

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


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

示例1: Planner

# 需要导入模块: from Robot import Robot [as 别名]
# 或者: from Robot.Robot import draw [as 别名]

#.........这里部分代码省略.........
            elif line.startswith('endrobot'):
                points = self.processPolygon(robotLines, start, i)
                self.robot = Robot(points)
    
    def computeCObstacles(self):

        for obs in self.obstacles:
            obs.computeCSpaceObstcale(self.robot)
            #self.cSpaceObs.append(obs.merged)
        
        return
            
        change = True

        
        while change:
            
            change = False
            o1 = None
            o2 = None
            m = None
            
            for obs in self.cSpaceObs:
                for obs2 in self.cSpaceObs:
                    
                    if obs == obs2:
                        continue
                    
                    m = obs.merge(obs2)
                    
                    if len(m) == 1:
                        change = True
                        o1 = obs
                        o2 = obs2
            
            if change:
                self.cSpaceObs.remove(o1)
                self.cSpaceObs.remove(o2)
                self.cSpaceObs.extend(m)
    
    
    def processPolygon(self, lines, startLine, endLine):
        print 'process polygon'
        
        
        points = []
        
        previousPoint = None
        
        for x in range(startLine + 1, endLine):
            line = lines[x]
            
            if line.startswith("#"):
                continue
            
            tokens = line.split()
            if len(tokens) == 2:
                point = self.list2point(tokens)
                points.append(point)
            else:
                print 'Error invalid vertex length: ' + line
                
        return points       
        # obstacle = Obstacle(points)
        # self.obstacles.append(obstacle)
            
    def list2point(self, pointList):
        coords = [float(x) for x in pointList]
        return Point(*coords);
        

    def getRoadmap(self):
        
        # First compute the c-space obstacles
        self.computeCObstacles()
        
        
        
        
    def drawCSpace(self):
        
        for obs in self.cSpaceObs:
            for line in obs:
                line.draw()
        

    
    def draw(self):
               
        glPushMatrix()
                
                
        for obstacle in self.obstacles:
            obstacle.draw()

        self.robot.draw()
        
        self.drawCSpace()
        
        glPopMatrix()
开发者ID:swighton,项目名称:MotionPlanner,代码行数:104,代码来源:Planner.py


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