示例#1
0
while (navigator.notGoal(position, nextPoint, path)):

    ### get current status (position, heading)
    position = robot.getPosition()
    heading = navigator.convertToDegree(robot.getHeading())

    ### get next point
    nextPoint = pathHandler.getNextPathPoint(position, path, nextPoint,
                                             lookAheadDistance,
                                             lookAheadSwitchDistance)

    ### find direction to path
    directionToPoint = navigator.getDirection(position, path, nextPoint)

    ### get turn direction +/- maximum turn rate
    turnDirection = navigator.getTurnDirection(heading, directionToPoint)

    ### determine dynamic turn rate based on interecpt angle
    turnRate = navigator.getTurnRate(directionToPoint, turnDirection)

    ### apply a dampler on the turn rate output
    turnRate = navigator.dampen(turnRate)

    ### dynamic speed adjustment according turnRate (currently not in use)
    #speed = navigator.adjustSpeed( turnRate )
    speed = maxSpeed

    ### set motion
    robot.setMotion(speed, turnRate)
    sleep(0.1)