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


Python NavHelper类代码示例

本文整理汇总了Python中NavHelper的典型用法代码示例。如果您正苦于以下问题:Python NavHelper类的具体用法?Python NavHelper怎么用?Python NavHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: avoidRight

def avoidRight(nav):
    if nav.firstFrame():
        avoidDest = RelRobotLocation(0, -25, 0)
        helper.setOdometryDestination(nav, avoidDest)
        return nav.stay()

    return Transition.getNextState(nav, avoidRight)
开发者ID:WangHanbin,项目名称:nbites,代码行数:7,代码来源:NavStates.py

示例2: walking

def walking(nav):
    """
    State to be used for velocity walking.
    """
    helper.setSpeed(nav, walking.speeds)

    return Transition.getNextState(nav, walking)
开发者ID:emamanto,项目名称:nbites,代码行数:7,代码来源:NavStates.py

示例3: dodge

def dodge(nav):
    if nav.firstFrame():
        nav.dodging = True

        if nav.brain.ball.vis.frames_off < 5:
            nav.brain.tracker.trackBall()
        else:
            nav.brain.tracker.trackObstacle(dodge.obstaclePosition)

        ## SET UP the dodge direction based on where the obstacle is
        # if directly in front of us, move back and to one side based on
        # where the goToPosition dest is
        dodge.speed = Navigator.BRISK_SPEED

        obstacleInfo = constants.OBS_DICT[dodge.obstaclePosition]
        helper.createAndSendWalkVector(nav, 
                                        dodge.speed*obstacleInfo[0], 
                                        dodge.speed*obstacleInfo[1], 
                                        0)
        print "Dodging ", obstacleInfo[2], " Obstacle"

    if navTrans.doneDodging(nav):
        nav.dodging = False
        nav.brain.tracker.repeatBasicPan()
        return nav.goLater('briefStand')

    return nav.stay()
开发者ID:MarcusEFC,项目名称:nbites,代码行数:27,代码来源:NavStates.py

示例4: avoidRightObstacle

def avoidRightObstacle(nav):
    """
    dodges left if we only detect something to the left of us
    """
    if nav.firstFrame():
        nav.doneAvoidingCounter = 0
        nav.printf(nav.brain.sonar)
        nav.printf("Avoid by left dodge");
        helper.setSpeed(nav, (0, constants.DODGE_LEFT_SPEED, 0))

    avoidLeft = navTrans.shouldAvoidObstacleLeft(nav)
    avoidRight = navTrans.shouldAvoidObstacleRight(nav)

    if (avoidLeft and avoidRight):
        return nav.goLater('avoidFrontObstacle')
    elif avoidLeft:
        return nav.goLater('avoidLeftObstacle')
    elif avoidRight:
        nav.doneAvoidingCounter -= 1
        nav.doneAvoidingCounter = max(0, nav.doneAvoidingCounter)
        return nav.stay()
    else:
        nav.doneAvoidingCounter += 1

    if nav.doneAvoidingCounter > constants.DONE_AVOIDING_FRAMES_THRESH:
        nav.shouldAvoidObstacleRight = 0
        nav.shouldAvoidObstacleLeft = 0
        return nav.goLater(nav.preAvoidState)

    return nav.stay()
开发者ID:chachi,项目名称:nbites,代码行数:30,代码来源:NavStates.py

示例5: goToPosition

def goToPosition(nav):
    """
    Go to a position set in the navigator. General go to state.  Goes
    towards a location on the field stored in dest.
    The location can be a RobotLocation, Location, RelRobotLocation, RelLocation
    Absolute locations get transformed to relative locations based on current loc
    For relative locations we use our bearing to that point as the heading
    """

    relDest = helper.getRelativeDestination(nav.brain.my, goToPosition.dest)
    goToPosition.deltaDest = relDest # cache it for later use

#    if nav.counter % 10 is 0:
#        print "going to " + str(relDest)
#        print "ball is at {0}, {1}, {2} ".format(nav.brain.ball.loc.relX,
#                                                 nav.brain.ball.loc.relY,
#                                                 nav.brain.ball.loc.bearing)
    if goToPosition.adaptive and relDest.relX >= 0:
        #reduce the speed if we're close to the target
        speed = helper.adaptSpeed(relDest.dist,
                                 constants.ADAPT_DISTANCE,
                                 goToPosition.speed)
    else:
        speed = goToPosition.speed

#    print "distance {0} and speed {1}".format(relDest.dist, speed)

    #if y-distance is small, ignore it to avoid strafing
    #strafelessDest = helper.getStrafelessDest(relDest)
    helper.setDestination(nav, relDest, speed)

#    if navTrans.shouldAvoidObstacle(nav):
#        return nav.goLater('avoidObstacle')

    return Transition.getNextState(nav, goToPosition)
开发者ID:WangHanbin,项目名称:nbites,代码行数:35,代码来源:NavStates.py

示例6: briefStand

def briefStand(nav):
    if nav.firstFrame():
        helper.stand(nav)

    if nav.counter > 3:
        return nav.goLater('goToPosition')

    return nav.stay()
开发者ID:WangHanbin,项目名称:nbites,代码行数:8,代码来源:NavStates.py

示例7: atPosition

def atPosition(nav):
    """
    Switches back if we're not at the destination anymore.
    """
    if nav.firstFrame():
        helper.stand(nav)

    return Transition.getNextState(nav, atPosition)
开发者ID:oneamtu,项目名称:nbites,代码行数:8,代码来源:NavStates.py

示例8: walkInPlace

def walkInPlace(nav):
    if nav.firstFrame():
        helper.walkInPlace(nav)

    # if nav.counter > 20:
    #     return nav.goLater('atPosition')    

    return nav.stay()
开发者ID:northern-bites,项目名称:nbites,代码行数:8,代码来源:NavStates.py

示例9: walking

def walking(nav):
    """
    State to be used for velocity walking.
    """
    helper.setSpeed(nav, walking.speeds)

    if navTrans.shouldDodge(nav):
        return nav.goNow('dodge')

    return Transition.getNextState(nav, walking)
开发者ID:MarcusEFC,项目名称:nbites,代码行数:10,代码来源:NavStates.py

示例10: scriptedMove

def scriptedMove(nav):
    '''State that we stay in while doing sweet moves'''
    if nav.firstFrame():
        helper.executeMove(nav.brain.motion, scriptedMove.sweetMove)
        return nav.stay()

    if not nav.brain.motion.isBodyActive():
        return nav.goNow('stopped')

    return nav.stay()
开发者ID:WangHanbin,项目名称:nbites,代码行数:10,代码来源:NavStates.py

示例11: scriptedMove

def scriptedMove(nav):
    """State that we stay in while doing sweet moves"""
    if nav.firstFrame():
        helper.executeMove(nav, scriptedMove.sweetMove)
        return nav.stay()

    if not nav.brain.interface.motionStatus.body_is_active:
        return nav.goNow("stopped")

    return nav.stay()
开发者ID:oneamtu,项目名称:nbites,代码行数:10,代码来源:NavStates.py

示例12: kickEngine

def kickEngine(nav):
    """
    State that we stay in while calling kick engine
    """
    if nav.firstFrame():
        helper.executeKickEngine(nav, kickEngine.kickType)
        return nav.stay()

    helper.stand(nav)
    return nav.stay()
开发者ID:coryalini,项目名称:nbites,代码行数:10,代码来源:NavStates.py

示例13: walking

def walking(nav):
    """
    State to be used when setSpeed is called
    """

    if (walking.speeds != walking.lastSpeeds) or not nav.brain.motion.isWalkActive():
        helper.setSpeed(nav, walking.speeds)
    walking.lastSpeeds = walking.speeds

    return Transition.getNextState(nav, walking)
开发者ID:WangHanbin,项目名称:nbites,代码行数:10,代码来源:NavStates.py

示例14: walking

def walking(nav):
    """
    State to be used for velocity walking.
    """

    if (walking.speeds != walking.lastSpeeds) or not nav.brain.interface.motionStatus.walk_is_active:
        helper.setSpeed(nav, walking.speeds)
    walking.lastSpeeds = walking.speeds

    return Transition.getNextState(nav, walking)
开发者ID:oneamtu,项目名称:nbites,代码行数:10,代码来源:NavStates.py

示例15: walking

def walking(nav):
    """
    State to be used when setSpeed is called
    """

    if ((walking.speeds != walking.lastSpeeds)
        or not nav.brain.interface.motionStatus.walk_is_active):
        helper.setSpeed(nav, walking.speeds)
    walking.lastSpeeds = walking.speeds

    return Transition.getNextState(nav, walking)
开发者ID:dmcavoy,项目名称:nbites,代码行数:11,代码来源:NavStates.py


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