def possibilityForwardRight(): fenetre.blit(fond, (0, 0)) fenetre.blit(perso, (190, 260)) arrow_dbl = pygame.transform.rotate(arrow, 40) arrow_dbl = pygame.transform.scale(arrow_dbl, (150, 300)) arrow_dbl.set_colorkey((255, 255, 255)) fenetre.blit(arrow_dbl, (250, 70)) pygame.display.flip() global event X = 1.0 Y = 0.0 Theta = -0.5 Frequency = 0.8 motionProxy.setWalkTargetVelocity(X, Y, Theta, Frequency) # do some work time.sleep(tseq) if event == "RotateRightA": 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 valL > P or valL <= TP: event = "StopRotate" if valR < valL: event = "RotateLeftA" cm.ReadytoRG() 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 = "Stop" elif even.key == pygame.K_UP: event = "StopRotate" elif even.key == pygame.K_RIGHT: event = "StopMove" elif even.key == pygame.K_DOWN: event = "StopMove" elif even.key == pygame.K_LEFT: event = "StopRotate" if even.type == pygame.JOYBUTTONDOWN: if joy.get_button(7) == 1: event = "Stop" elif even.type == pygame.JOYAXISMOTION: if joy.get_axis(1) > 0: event = "StopMove" elif joy.get_axis(0) < 0: event = "StopRotate" return event # return event to be able to define the transition
def possibilityBackwardLeft(): fenetre.blit(fond, (0, 0)) fenetre.blit(perso, (190, 260)) arrow_dbl = pygame.transform.rotate(arrow, -140) arrow_dbl = pygame.transform.scale(arrow_dbl, (150, 300)) arrow_dbl.set_colorkey((255, 255, 255)) fenetre.blit(arrow_dbl, (70, 370)) pygame.display.flip() global event X = -1.0 Y = 0.0 Theta = 0.5 Frequency = 0.8 motionProxy.setWalkTargetVelocity(X, Y, Theta, Frequency) # do some work time.sleep(tseq) 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 = "Stop" elif even.key == pygame.K_DOWN: event = "StopRotate" cm.AlltoBK() elif even.key == pygame.K_LEFT: event = "StopMove" cm.ReadytoRG() elif even.key == pygame.K_UP: event = "StopMove" elif even.key == pygame.K_RIGHT: event = "StopRotate" cm.AlltoBK() if even.type == pygame.JOYBUTTONDOWN: if joy.get_button(7) == 1: event = "Stop" elif even.type == pygame.JOYAXISMOTION: if joy.get_axis(1) < 0: event = "StopMove" elif joy.get_axis(0) > 0: event = "StopRotate" return event # return event to be able to define the transition
def possibilityForward(): global event X = 1.0 Y = 0.0 Theta = 0.0 Frequency = 0.8 motionProxy.setWalkTargetVelocity(X, Y, Theta, Frequency) # do some work time.sleep(tseq) fenetre.blit(fond, (0, 0)) fenetre.blit(perso, (190, 260)) arrow_up = pygame.transform.rotate(arrow, 90) fenetre.blit(arrow_up, (110, 0)) pygame.display.flip() event = "Stay" # define the default event # Modification des méthodes d'esquives automatiques; 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 valL <= TP and valR <= TP: print("Objets tres proches droit devant") event = "StopMoveA" #MOD elif valL <= TP: print("objet tres proche a ma gauche") event = "StopMoveAR" elif valR <= TP: print("objet tres proche a ma droite") event = "StopMoveAL" elif valL <= P: print("objet proche a ma gauche") event = "RotateRightA" cm.ReadytoRD() elif valR <= P: print("objet proche a ma droite") event = "RotateLeftA" cm.ReadytoRG() 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 = "StopMove" elif even.key == pygame.K_DOWN: event = "StopMove" elif even.key == pygame.K_LEFT: event = "RotateLeft" cm.ReadytoRG() elif even.key == pygame.K_RIGHT: event = "RotateRight" cm.ReadytoRD() if even.type == pygame.JOYAXISMOTION: if joy.get_axis(1) > 0: event = "StopMove" elif joy.get_axis(0) < 0: event = "RotateLeft" elif joy.get_axis(0) > 0: event = "RotateRight" elif even.type == pygame.JOYBUTTONDOWN: if joy.get_button(7) == 1: event = "StopMove" return event # return event to be able to define the transition
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