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


Python NavHelper.setOdometryDestination方法代码示例

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


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

示例1: avoidRight

# 需要导入模块: import NavHelper [as 别名]
# 或者: from NavHelper import setOdometryDestination [as 别名]
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,代码行数:9,代码来源:NavStates.py

示例2: dodge

# 需要导入模块: import NavHelper [as 别名]
# 或者: from NavHelper import setOdometryDestination [as 别名]
def dodge(nav):
    if nav.firstFrame():
        ## 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
        if dodge.position is dodge.position.NORTH:
            print "Dodging NORTH obstacle"
            relDest = helper.getRelativeDestination(nav.brain.loc,
                                                    goToPosition.dest)
            if relDest.relY <= 0:
                direction = -1
            else:
                direction = 1
            dodgeDest = RelRobotLocation(-15, direction*10, 0)
        elif dodge.position is dodge.position.NORTHEAST:
            print "Dodging NORTHEAST obstacle"
            dodgeDest = RelRobotLocation(0, 15, 0)
        elif dodge.position is dodge.position.EAST:
            print "Dodging EAST obstacle"
            dodgeDest = RelRobotLocation(0, 20, 0)
        elif dodge.position is dodge.position.SOUTHEAST:
            print "Dodging SOUTHEAST obstacle"
            dodgeDest = RelRobotLocation(0, 15, 0)
        # if directly behind us, move forward and to one side based on
        # where the goToPosition dest is
        elif dodge.position is dodge.position.SOUTH:
            print "Dodging SOUTH obstacle"
            relDest = helper.getRelativeDestination(nav.brain.loc,
                                                    goToPosition.dest)
            if relDest.relY <= 0:
                direction = -1
            else:
                direction = 1
            dodgeDest = RelRobotLocation(15, direction*10, 0)
        elif dodge.position is dodge.position.SOUTHWEST:
            print "Dodging SOUTHWEST obstacle"
            dodgeDest = RelRobotLocation(0, -15, 0)
        elif dodge.position is dodge.position.WEST:
            print "Dodging WEST obstacle"
            dodgeDest = RelRobotLocation(0, -20, 0)
        elif dodge.position is dodge.position.NORTHWEST:
            print "Dodging NORTHWEST obstacle"
            dodgeDest = RelRobotLocation(0, -15, 0)

        helper.setOdometryDestination(nav, dodgeDest)

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

示例3: walkingTo

# 需要导入模块: import NavHelper [as 别名]
# 或者: from NavHelper import setOdometryDestination [as 别名]
def walkingTo(nav):
    """
    Walks to a relative location based on odometry
    """
    if nav.firstFrame():
        helper.stand(nav)
        return nav.stay()

    if nav.brain.motion.isStanding():
        if len(walkingTo.destQueue) > 0:
            dest = walkingTo.destQueue.popleft()
            helper.setOdometryDestination(nav, dest, walkingTo.speed)
            return nav.stay()
        else:
            return nav.goNow('standing')

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

示例4: walkingTo

# 需要导入模块: import NavHelper [as 别名]
# 或者: from NavHelper import setOdometryDestination [as 别名]
def walkingTo(nav):
    """
    State to be used for odometry walking.
    """
    if nav.firstFrame():
        helper.stand(nav)
        return nav.stay()

    if nav.brain.interface.motionStatus.standing:
        if len(walkingTo.destQueue) > 0:
            dest = walkingTo.destQueue.popleft()
            helper.setOdometryDestination(nav, dest, walkingTo.speed)
            return nav.stay()
        else:
            return nav.goNow("standing")

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

示例5: walkingTo

# 需要导入模块: import NavHelper [as 别名]
# 或者: from NavHelper import setOdometryDestination [as 别名]
def walkingTo(nav):
    """
    State to be used for odometry walking.
    """
    if nav.firstFrame():
        print ("Resetting odometry!")
        nav.brain.interface.motionRequest.reset_odometry = True
        nav.brain.interface.motionRequest.timestamp = int(nav.brain.time * 1000)
        print ("MY dest: ", nav.destination.relX, nav.destination.relY, nav.destination.relH)
        helper.walkInPlace(nav)
        return nav.stay()

    
    if not nav.brain.motion.calibrated:
        helper.stand(nav)
        return nav.stay()

    if nav.counter < 5:
        return nav.stay()

    walkingTo.currentOdo = RelRobotLocation(nav.brain.interface.odometry.x,
                         nav.brain.interface.odometry.y,
                         nav.brain.interface.odometry.h)

    # TODO why check standing?
    if nav.brain.interface.motionStatus.standing:

        if len(walkingTo.destQueue) > 0:
            dest = walkingTo.destQueue.popleft()
            # dest.relH = 0
            helper.setOdometryDestination(nav, dest, walkingTo.speed)
            # helper.setDestination(nav, dest, walkingTo.speed)
            print ("MY dest: ", dest.relX, dest.relY, dest.relH)

    if locationsMatch(nav.destination, walkingTo.currentOdo):
        print("I think i'm there!")
        return nav.goNow('standing')

    # if nav.counter % 10 == 0:
    #     print "Current odo:"
    #     print ("x:", walkingTo.currentOdo.relX)
    #     print ("y:", walkingTo.currentOdo.relY)
    #     print ("h:", walkingTo.currentOdo.relH)

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

示例6: walkingTo

# 需要导入模块: import NavHelper [as 别名]
# 或者: from NavHelper import setOdometryDestination [as 别名]
def walkingTo(nav):
    """
    State to be used for odometry walking.
    """
    if nav.firstFrame():
        print ("Resetting odometry!")
        nav.brain.interface.motionRequest.reset_odometry = True
        nav.brain.interface.motionRequest.timestamp = int(nav.brain.time * 1000)
        helper.stand(nav)
        return nav.stay()


    walkingTo.currentOdo = RelRobotLocation(nav.brain.interface.odometry.x,
                         nav.brain.interface.odometry.y,
                         nav.brain.interface.odometry.h)

    # TODO why check standing?
    if nav.brain.interface.motionStatus.standing:

        if len(walkingTo.destQueue) > 0:
            dest = walkingTo.destQueue.popleft()
            helper.setOdometryDestination(nav, dest, walkingTo.speed)
            print ("MY dest: ", dest.relX, dest.relY, dest.relH)

    if locationsMatch(nav.destination, walkingTo.currentOdo):
        return nav.goNow('standing')

    # walkingTo.currentOdow = RelRobotLocation(nav.brain.interface.odometry.x,
    #                          nav.brain.interface.odometry.y,
    #                          nav.brain.interface.odometry.h)
    if nav.counter % 30 == 0:
        print "Current odo:"
        print ("x:", walkingTo.currentOdo.relX)
        print ("y:", walkingTo.currentOdo.relY)
        print ("h:", walkingTo.currentOdo.relH)
        # print "Current odow:"
        # print ("x:", walkingTo.currentOdow.relX)
        # print ("y:", walkingTo.currentOdow.relY)
        # print ("h:", walkingTo.currentOdow.relH)
        # print "---------------"



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


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