예제 #1
0
def left():
    global move_flag, lastevent
    if not (move_flag):
        move_flag = True
        naocmd.tourner_a_gauche(motion, 1)
        print "Tourne a gauche"
    time.sleep(0.5)
    newKey, val = getKey()
    event = "Again"  # define the default event
    if newKey:
        if val == t_avance:
            move_flag = False
            event = "Walk"
        if val == t_pivot_r:
            move_flag = False
            event = "Turn on the Right"
        if val == t_wait:
            move_flag = False
            event = "Wait"
        if val == t_r:
            move_flag = False
            event = "Right"
        if val == t_l:
            move_flag = False
            event = "Left"
        if val == t_b:
            move_flag = False
            event = "Go back"
    if naocmd.donnee_sonar(sonar, memory, motion, float(dist))[0]:
        move_flag = False
        event = "Obstacle"
        lastevent = "Turn on the Left"
    return event  # return event to be able to define the transition
예제 #2
0
def evitement():
    global move_flag
    if not (move_flag):
        move_flag = True
        #Si cote gauche detecte en premier alors on tourne a droite
        if naocmd.donnee_sonar(sonar, memory, motion,
                               float(dist))[1] < naocmd.donnee_sonar(
                                   sonar, memory, motion, float(dist))[2]:
            naocmd.tourner_a_droite(motion, 1)
        else:
            naocmd.tourner_a_gauche(motion, 1)
        print "Detection Obstacle"
    time.sleep(0.5)
    if not (naocmd.donnee_sonar(sonar, memory, motion, 0.1 + float(dist))[0]):
        print "Fin d'evitement"
        move_flag = False
        return lastevent
    else:
        return "Again"