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


Python Driver.followLineG方法代码示例

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


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

示例1: __init__

# 需要导入模块: from driver import Driver [as 别名]
# 或者: from driver.Driver import followLineG [as 别名]
class FieldRobot:
  rowWidth = 0.75
  rowPotsWidth = 0 #0.45
  def __init__( self, robot, configFilename, verbose = False ):
    self.robot = robot
    self.robot.insideField = True
#    self.robot.fnSpeedLimitController = [self.robot.pauseSpeedFn] 
    self.robot.fnSpeedLimitController = [] 
    self.robot.addExtension( emergencyStopExtension )
#    self.robot.attachGPS()
    self.robot.attachLaser( remission=True )
    self.robot.laser.stopOnExit = False  # for faster boot-up
#    self.robot.attachCamera( cameraExe = "../robotchallenge/rc" ) # TODO what was used?!
#    self.robot.attachCamera( cameraExe = "../robotchallenge/redcone" ) # FRE2015 - task2
    self.robot.attachCamera( cameraExe = "../robotchallenge/dark" ) # FRE2015 - task3
    self.robot.attachHand()
    self.robot.rfidData = None # hack 2013
    self.robot.gpsData = None
    self.driver = Driver( self.robot, maxSpeed = 0.7, maxAngularSpeed = math.radians(60) )
#    self.robot.localisation = KalmanFilter() # needed for better direction handling
    self.robot.localisation = SimpleOdometry()
    self.verbose = verbose
    self.configFilename = configFilename
    self.rowHeading = None

  def waitForStart( self ):
    print "Waiting for start cable insertion ..."
    while self.robot.startCableIn is None or not self.robot.startCableIn:
      self.robot.setSpeedPxPa( 0.0, 0.0 )
      self.robot.update()
    print "READY & waiting for start ..."
    while self.robot.startCableIn is None or self.robot.startCableIn:
      self.robot.setSpeedPxPa( 0.0, 0.0 )
      if self.robot.laserData:
        self.robot.toDisplay = 'O'
        if self.robot.remissionData:
          self.robot.toDisplay = 'R'
      else:
        self.robot.toDisplay = '-'
      if self.robot.rfidData:
        self.robot.toDisplay += str( self.robot.rfidData[0] % 10 )
      else:
        self.robot.toDisplay += '-'

      self.robot.update()
    print "!!! GO !!!" 


  def ver2( self, code, detectWeeds = True, detectBlockedRow = True ):
    print "Field Robot - LASER & CAMERA"

    try:
      # start GPS sooner to get position fix
#      self.robot.gps.start()
      self.robot.laser.start()
      self.waitForStart()
      if not self.robot.switchBlueSelected:
        print "RED -> mirroring code directions!!!"
        code = [-x for x in code]
        print code

      if self.robot.compass:
        self.rowHeading = compassHeading(self.robot.compass)
      self.robot.camera.start()
      laserRow = LaserRow( verbose = self.verbose, rowHeading = self.robot.localisation.pose()[2] )
      self.robot.addExtension( laserRow.updateExtension )
      cameraRow = CameraRow( verbose = self.verbose )
      self.robot.addExtension( cameraRow.updateExtension )
      angularSpeed = 0.0
      self.robot.maxSpeed = 0.2
      speed = 0 # wait for first camera image (maybe beep?? if no route to host)
      startTime = self.robot.time
      row = laserRow
      row.reset( offsetDeg=None ) # just for test, try to find the gap (kitchen test)
#      row = cameraRow
      for action in code:
        self.robot.insideFiled = True
        print "=================  ACTION ", action, "================="
        print "battery:", self.robot.battery
        while not row.endOfRow:
#          sprayer( self.robot, True, True )
          for (speed, angularSpeed) in self.driver.followLineG( row.line ):
#            print "TEST %.2f" % (math.degrees(normalizeAnglePIPI(row.line.angle - self.robot.localisation.pose()[2])))
            if abs(normalizeAnglePIPI(row.line.angle - self.robot.localisation.pose()[2])) > SLOW_DOWN_ANGLE:
              speed *= 0.9
            if self.robot.laserData:
              self.robot.toDisplay = 'OK'
            else:
               self.robot.toDisplay = '--'
               speed, angularSpeed = 0.0, 0.0            
#            if detectBlockedRow and row.collisionAhead[1] < 0.25:

            blockedCamCount = 0
            if detectBlockedRow and self.robot.cameraData:
              camDat, fileName = self.robot.cameraData
              if camDat:
                blockedCamCount = int(camDat.split()[0])
                if blockedCamCount > RED_ALERT:
                  print "CAMERA BLOCKED!!", blockedCamCount

#.........这里部分代码省略.........
开发者ID:robotika,项目名称:eduro,代码行数:103,代码来源:fre.py


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