Пример #1
0
def possibilityLeft():
    fenetre.blit(fond, (0, 0))
    fenetre.blit(perso, (190, 260))
    arrow_left = pygame.transform.scale(arrow_rot_l, (300, 300))
    fenetre.blit(arrow_left, (100, 220))
    pygame.display.flip()
    global event
    X = 0.0
    Y = 0.0
    Theta = 0.5
    Frequency = 0.8
    motionProxy.setWalkTargetVelocity(X, Y, Theta, Frequency)  # do some work
    time.sleep(tseq)
    if event == "RotateLeftA":
        sonarProxy.subscribe("SonarApp")
        time.sleep(0.25)
        valL = memoryProxy.getData("Device/SubDeviceList/US/Left/Sensor/Value")
        print("a gauche, mon sonar detecte", valL)
        valR = memoryProxy.getData(
            "Device/SubDeviceList/US/Right/Sensor/Value")
        print("a droite, mon sonar detecte", valR)
        sonarProxy.unsubscribe("SonarApp")
        if valR > TP:
            event = "StopRotateA"
        for even in pygame.event.get():
            if even.type == pygame.KEYDOWN:
                event = "Stay"
    else:
        event = "Stay"  # define the default event
        for even in pygame.event.get():
            if even.type == pygame.QUIT:
                sys.exit()
            if even.type == pygame.KEYDOWN:
                if even.key == pygame.K_s:
                    event = "StopRotate"
                elif even.key == pygame.K_UP:
                    event = "MoveForward"
                    cm.ReadytoAvance()
                elif even.key == pygame.K_DOWN:
                    event = "MoveBackward"
                    cm.AlltoBK()
                elif even.key == pygame.K_RIGHT:
                    event = "StopRotate"
            if even.type == pygame.JOYBUTTONDOWN:
                if joy.get_button(7) == 1:
                    event = "StopRotate"
            elif even.type == pygame.JOYAXISMOTION:
                if joy.get_axis(1) < 0:
                    event = "MoveForward"
                elif joy.get_axis(1) > 0:
                    event = "MoveBackward"
                elif joy.get_axis(0) > 0:
                    event = "StopRotate"
    return event
Пример #2
0
def possibilityStart():
    fenetre.blit(fond, (0, 0))
    fenetre.blit(perso, (190, 260))
    pygame.display.flip()
    global is_sleeping
    global event
    is_sleeping = False
    motionProxy.setStiffnesses("Body", 1.0)
    X = 0.0
    Y = 0.0
    Theta = 0.0
    Frequency = 0.8
    motionProxy.setWalkTargetVelocity(X, Y, Theta,
                                      Frequency)  # do some work # do some work
    postureProxy.goToPosture("StandInit", fractSpeed)
    time.sleep(tseq)
    #procédure évitement
    if event == "StopMoveA":
        event = "MoveBackwardA"
        cm.AlltoBK()
    elif event == "StopMoveAR":
        #Rajouter compteur au bsn
        event = "RotateRightA"
        cm.ReadytoRD()
    elif event == "StopMoveAL":
        event = "RotateLeftA"
        cm.ReadytoRG()
    elif event == "StopRotateA" or event == "StopMoveAF":
        event = "MoveForward"
        cm.ReadytoAvance()
    else:
        event = "Stay"
        for even in pygame.event.get():
            if even.type == pygame.QUIT:
                sys.exit()
            if even.type == pygame.KEYDOWN:
                if even.key == pygame.K_UP:
                    event = "MoveForward"
                    cm.ReadytoAvance()
                elif even.key == pygame.K_DOWN:
                    event = "MoveBackward"
                    cm.AlltoBK()
                elif even.key == pygame.K_LEFT:
                    event = "RotateLeft"
                    cm.ReadytoRG()
                elif even.key == pygame.K_RIGHT:
                    event = "RotateRight"
                    cm.ReadytoRD()
                elif even.key == pygame.K_p:
                    event = "Pause"
                    cm.ReadytoIDLE()
                elif even.key == pygame.K_k:
                    event = "Kill"
                elif even.key == pygame.K_SPACE:
                    event = "Shoot"
                    cm.ReadytoShoot()
                elif even.key == pygame.K_d:
                    event = "Dab"
            if even.type == pygame.JOYAXISMOTION:
                if joy.get_axis(1) < 0:
                    event = "MoveForward"
                elif joy.get_axis(1) > 0:
                    event = "MoveBackward"
                elif joy.get_axis(0) < 0:
                    event = "RotateLeft"
                elif joy.get_axis(0) > 0:
                    event = "RotateRight"
            if even.type == pygame.JOYBUTTONDOWN:
                if joy.get_button(2) == 1:
                    event = "Pause"
                elif joy.get_button(6) == 1:
                    event = "Kill"
                elif joy.get_button(0) == 1:
                    event = "Shoot"
                elif joy.get_button(9) == 1:
                    event = "Dab"
    return event