def run(self): with open(self.path.format(self.record_name)) as f: move = Move.load(f) self.player = MovePlayer(self.robot, move, max_start_speed=0) self.player.start() self.player.wait_to_stop()
def run(self): try: self.robot.upper_body_idle_motion.stop() self.robot.torso_idle_motion.stop() # self.robot.head_idle_motion.stop() except: pass else: pass finally: pass # initialize the time variable t = time.time() # find the right move with open("./moves/" + self.move + ".move") as f: m = Move.load(f) # chargement du .move # start the move movey = MovePlayer(self.robot, m) movey.start() #time to start the move el = time.time() - t # taking into account the movement time in itself (pos_number * framerate) md = movey.duration() - 0.3 time.sleep(md) # sleeping the wanted duration
class Play(Primitive): properties = ['record_name', 'moves'] path = '/tmp/{}.json' def __init__(self, robot): Primitive.__init__(self, robot) self.record_name = "demo_example" def setup(self): for m in self.robot.motors: m.compliant = False m.moving_speed = 0 def run(self): with open(self.path.format(self.record_name)) as f: move = Move.load(f) self.player = MovePlayer(self.robot, move, max_start_speed=0) self.player.start() self.player.wait_to_stop() def teardown(self): for m in self.robot.motors: m.moving_speed = 0 @property def moves(self): return [ s.replace('/tmp/', '').replace('.json', '') for s in glob.glob('/tmp/*.json') ]
def run(self): with open(self._move) as f: m = Move.load(f) self._robot.compliant = False move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): move = "\home\poppy\resources\move\devinette.move" with open(move) as f: m = Move.load(f) self._robot.compliant = False speak.start("J’ai une devinette pour toi, ça te dis ?") move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): move = '\home\poppy\resources\move\emotionsCommeToi.move' with open(move) as f: m = Move.load(f) self._robot.compliant = False speak.start("C’est intéressant, j’aimerai bien avoir des émotions comme toi." ) move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): move = '\home\poppy\resources\move\commentTuTeSens.move' with open(move) as f: m = Move.load(f) self._robot.compliant = False speak.start("Et comment tu te sens quand tu parles à un robot ?" ) move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): move = '\home\poppy\resources\move\merciDeTaVisite.move' with open(move) as f: m = Move.load(f) self._robot.compliant = False speak.start("Maintenant il faut laisser la place aux autres, c’était bien sympa, je te remercie pour ta visite ! Je t’invite à remplir ce questionnaire, ça va beaucoup aider mes amis." ) move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): move = '\home\poppy\resources\move\explicationsPlus.move' with open(move) as f: m = Move.load(f) self._robot.compliant = False speak.start("Je serais là pour jouer avec les enfants, et pour les accompagner quand ils sont dans la chambre! Grace à moi ils pourront garder contact avec leur famille et leur amis!" ) move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): move = '\home\poppy\resources\move\reponseSousmarins.move' with open(move) as f: m = Move.load(f) self._robot.compliant = False speak.start("Les sous-marins! J’aime cette blague pas toi?" ) move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): move = '\home\poppy\resources\move\super.move' with open(move) as f: m = Move.load(f) self._robot.compliant = False speak.start("Super ! J’aimerais beaucoup aussi." ) move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): move = '\home\poppy\resources\move\savoirPlus.move' with open(move) as f: m = Move.load(f) self._robot.compliant = False speak.start("Tu veux que je t’explique un peu plus ?" ) move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): move = '\home\poppy\resources\move\devinette.move' with open(move) as f: m = Move.load(f) self._robot.compliant = False speak.start("J’ai une devinette pour toi, ça te dis ?") move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): move = '\home\poppy\resources\move\quiJeSuis.move' with open(move) as f: m = Move.load(f) self._robot.compliant = False speak.start("Sais-tu qui je suis ?" ) move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): move = '\home\poppy\resources\move\savoirPlus.move' with open(move) as f: m = Move.load(f) self._robot.compliant = False speak.start("Tu veux que je t’explique un peu plus ?") move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): move = '\home\poppy\resources\move\monnaiePoissons.move' with open(move) as f: m = Move.load(f) self._robot.compliant = False speak.start("Quelle monnaie utilise les poissons ?" ) move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): move = '\home\poppy\resources\move\\parlerAvecMoi.move' with open(move) as f: m = Move.load(f) self._robot.compliant = False speak.start("Tu serais content de parler avec moi ?" ) move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): move = '\home\poppy\resources\move\explications.move' with open(move) as f: m = Move.load(f) self._robot.compliant = False speak.start("Je suis le nouveau compagnon des enfants dans les hôpitaux, je serais là pour participer à leur bonheur, avec moi tu vas t’amuser !" ) move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): move = '\home\poppy\resources\move\commentTuTeSens.move' with open(move) as f: m = Move.load(f) self._robot.compliant = False speak.start("Et comment tu te sens quand tu parles à un robot ?") move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): move = '\home\poppy\resources\move\quiJeSuis.move' with open(move) as f: m = Move.load(f) self._robot.compliant = False speak.start("Sais-tu qui je suis ?") move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): move = "\home\poppy\resources\move\premiereFoisRobot.move" with open(move) as f: m = Move.load(f) self._robot.compliant = False # speak.start("C’est gentil de passer me voir, c’est la première fois que tu parles avec un robot?") # move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): move = '\home\poppy\resources\move\emotionsCommeToi.move' with open(move) as f: m = Move.load(f) self._robot.compliant = False speak.start( "C’est intéressant, j’aimerai bien avoir des émotions comme toi.") move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): move = '\home\poppy\resources\move\explicationsPlus.move' with open(move) as f: m = Move.load(f) self._robot.compliant = False speak.start( "Je serais là pour jouer avec les enfants, et pour les accompagner quand ils sont dans la chambre! Grace à moi ils pourront garder contact avec leur famille et leur amis!" ) move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): move = '\home\poppy\resources\move\bonjourCaVa.move' with open(move) as f: m = Move.load(f) self._robot.compliant = False # speak.start("Bonjour, je me présente je m’appelle Cherry ! Comment t’appelles tu ?" ) # move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(1.5) self._speak.start("Hé non, mon nombre est plus grand. Essaye encore!")
def run(self): move = '\home\poppy\resources\move\premiereFoisRobot.move' with open(move) as f: m = Move.load(f) self._robot.compliant = False # speak.start( "C’est gentil de passer me voir, c’est la première fois que tu parles avec un robot?" ) # move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(1.5) self._speak.start("Bravo! Eh oui je suis un robot.")
def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(1.5) self._speak.start("Dommage, mon nombre est plus petit. Essaye encore!")
def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(2) self._speak.start("Non, ce n'est pas ça. Essaye encore!")
def run(self): move = '\home\poppy\resources\move\bonjourCaVa.move' with open(move) as f: m = Move.load(f) self._robot.compliant = False # speak.start( "Bonjour, je me présente je m’appelle Cherry ! Comment t’appelles tu ?" ) # move_player = MovePlayer(self._robot, m) move_player.start()
def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(1.5) self._speak.start("Bien joué! On croirait presque que tu lis dans mes électrons!")
def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(2) self._speak.start("Non, ce n'est pas ça. Essaye encore!")
def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(1.5) self._speak.start("Bravo! Tu t'y connais en orthographe!")
def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(1.5) self._speak.start( "Bien joué! On croirait presque que tu lis dans mes électrons!")
def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(1.5) self._speak.start("Bravo! Tu t'y connais en orthographe!")
def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(1.5) self._speak.start("Bravo! Quel génie mathématique!")
def run(self): while not self.should_stop(): if self.should_pause(): self.wait_to_resume() while not (self.posture_is(self.defaut_posture)): time.sleep(0.1) for m in self.robot.motors: m.led = "green" m.compliant = True my_record = MoveRecorder(self.robot, 50, self.robot.motors) my_record.start() sleep = int(self.record_time + (self.record_time / 5.)) for i in range(sleep): if not self.should_stop(): if self.should_pause(): self.wait_to_resume() for m in self.robot.motors: m.led = "green" time.sleep(0.5) for m in self.robot.motors: m.led = "off" time.sleep(0.5 - ((0.5 / sleep) * i)) my_record.stop() #my_record.wait_to_stop() if not self.should_stop(): if self.should_pause(): self.wait_to_resume() self.robot.tinsel.colors = ['red'] self.robot.tinsel.freq = 1 self.robot.tinsel.start() self.robot._primitive_manager.remove(self) # patch pour passer des fake moteurs de la primitive ProgByDemo aux moteurs reel de l ergo my_play = MovePlayer(self.robot, my_record.move) my_play.start() for t in range(self.record_time * 2): if not self.should_stop(): if self.should_pause(): self.wait_to_resume() time.sleep(0.5) if my_play.is_alive(): my_play.stop() self.robot.tinsel.stop() self.robot._primitive_manager.add( self ) # on redonne le control des moteurs a la primitive ProgByDemo duration = int(max(self.distance_with( self.defaut_posture))) / 100. for m in self.robot.motors: m.compliant = False m.goto_position(self.defaut_posture[m.id - 1], duration) time.sleep(duration)
def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False text = "Bonjour, " + self._name + ". Comment vas tu aujourd'hui?" with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(1.5) self._speak.start(text)
def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False text = "Bonjour, " + self._name + ". Comment vas tu aujourd'hui?" with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(1.5) self._speak.start(text)
def start_move_player(self, move_name, speed=1.0, backwards=False): """Move player need to have a move file <move_name.record> in the working directory to play it""" # check if running try: player = getattr(self.robot, '_{}_player'.format(move_name)) if player.running: return except AttributeError: pass # if not running, override the play primitive with open('{}.record'.format(move_name)) as f: loaded_move = Move.load(f) player = MovePlayer(self.robot, loaded_move, play_speed=speed, backwards=backwards) self.robot.attach_primitive(player, '_{}_player'.format(move_name)) player.start() return player.duration()
def run(self): ### Geste poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(0.5) ### Son self._speak.start(self._text)
def run(self): ### Geste poppy = self.robot for m in poppy.motors: m.compliant = False with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(0.5) ### Son self._speak.start(self._text)
def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False num = random.randint(1,100) print (num) print "lancer plus, moins ou egal suivant la réponse du patient" with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(0.5) self._speak.start("Essaye de deviner à quel nombre je pense. Il est compris entre 1 et 100")
def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False num1 = random.randint(1, 4) if num1 == 1: text1 = "singe" mouvement = self._movem1 elif num1 == 2: text1 = "poulet" mouvement = self._movem2 elif num1 == 3: text1 = "nager" mouvement = self._movem3 elif num1 == 4: text1 = "manger" mouvement = self._movem4 else: text1 = "singe" mouvement = self._movem1 print(text1) print "lancer vrai4 si le patient répond bien, faux si il se trompe." text = "Devine ce que je mime." with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(0.5) self._speak.start(text) time.sleep(3) with open(mouvement) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start()
def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False num = random.randint(1, 100) print(num) print "lancer plus, moins ou egal suivant la réponse du patient" with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(0.5) self._speak.start( "Essaye de deviner à quel nombre je pense. Il est compris entre 1 et 100" )
def start_move_player(self, move_name): """Move player need to have a move file <move_name.json> in th PATH to play it""" with open(move_name + '.record') as f: loaded_move = Move.load(f) move_name += '_player' player = MovePlayer(self.robot, loaded_move) self.robot.attach_primitive(player, move_name) player.start() player.wait_to_stop() return move_name
def start(self): with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) with open(self._move2) as f : m = Move.load(f) move_player2 = MovePlayer(self.robot, m) move_player.start() move_player2.start() time.sleep(1.5) # print "1" # phrase="Je vais te parler de l’Hyperthyroïdie. Ne t’inquiète pas, ce n’est pas très compliqué ! Je vais t’expliquer ce que c’est, pourquoi ça arrive et comment les médecins le soignent." # self._speak.start(phrase) # print "2" # phrase="Dans ton cou, juste au-dessous de la pomme d’Adam, se trouve ta glande thyroïde. Cette glande aide à contrôler la vitesse à laquelle ton corps travaille. Elle le fait en envoyant un message à tes organes grâce à l’hormone Thyroxine." # print phrase # self._speak.start(phrase) # phrase="Si la glande thyroïde envoie trop de thyroxine, ton corps travaille trop vite. Si elle en envoie trop peu, ton corps travaille trop lentement. Pour que ton corps travaille bien, il te faut une quantité normale de thyroxine." # self._speak.start(phrase) # phrase="""Quand ta glande thyroïde produit trop de thyroxine, on appelle cela l’hyperthyroïdie.""" # self._speak.start(phrase) # phrase="""Les médecins peuvent diagnostiquer l’hyperthyroïdie grâce à un prélèvement de sang, qui leur permet de savoir quelle quantité d’hormones tu as.""" # self._speak.start(phrase) # phrase="""Pour traiter ton hyperthyroïdie, les médecins vont te prescrire des comprimés. Ces comprimés vont diminuer la quantité de tes hormones thyroïdiennes. Il est très important que tu prennes bien tes médicaments tous les jours.""" # self._speak.start(phrase) # phrase="""Si, après quelques années, les médicaments ne suffisent pas pour te guérir, il est possible que tu reviennes pour un nouveau traitement.""" # self._speak.start(phrase) # phrase="""J’espère que tu comprends mieux l’hyperthyroïdie maintenant. Si tu as des questions, ou des choses que tu n’as pas bien comprises, n’hésite pas à en parler à ton médecin ou à une autre personne de l’hôpital. Ils pourront t’aider et t’expliquer.""" # self._speak.start(phrase) self._saytext.start("textToSpeech/disc_med.txt")
def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False num1 = random.randint(1, 4) if num1 == 1: text1 = "singe" mouvement = self._movem1 elif num1 == 2: text1 = "poulet" mouvement = self._movem2 elif num1 == 3: text1 = "nager" mouvement = self._movem3 elif num1 == 4: text1 = "manger" mouvement = self._movem4 else: text1 = "singe" mouvement = self._movem1 print (text1) print "lancer vrai4 si le patient répond bien, faux si il se trompe." text = "Devine ce que je mime." with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(0.5) self._speak.start(text) time.sleep(3) with open(mouvement) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start()
def run(self): with open("./moves/" + self.move + ".move") as f: m = Move.load(f) movey = MovePlayer(self.robot, m) movey.start()
#~ try: #~ with open(poppy_config_file) as f: #~ poppy_config = json.load(f) #~ poppy = pypot.robot.from_config(poppy_config) #~ poppy.start_sync() except Exception,e: print "could not create poppy object" print e for m in poppy.motors: m.compliant = False m.goal_position = 0.0 m.max_torque = 20 with open('mymove.json') as f: loaded_move = Move.load(f) player = MovePlayer(poppy, loaded_move) print "starting" player.start() player.wait_to_stop() print "finished" for m in poppy.motors: m.compliant = True print m.name time.wait(1)
def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False print "robot" print "lancer vrai2 si le patient répond bien, faux si il se trompe." with open(self._move) as f : m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(1.5) self._speak.start("J'ai une charade pour toi. Mon premier est un bruit malpoli. Mon deuxième est très joli. Mon tout est ce que je suis. Qui suis-je?") #while pas appuie sur o # while True : # rep = raw_input() # #if appuie sur n # if rep == "n" : # with open(self._moven) as f : # m = Move.load(f) # move_player = MovePlayer(self.robot, m) # move_player.start() # time.sleep(1.5) # self._speak.start("Non, ce n'est pas ça. Essaye encore!") # #if appuie sur r # elif rep == "r" : # with open(self._mover) as f : # m = Move.load(f) # move_player = MovePlayer(self.robot, m) # move_player.start() # time.sleep(1.5) # self._speak.start("D'accord, je te répète la charade.") # with open(self._move) as f : # m = Move.load(f) # move_player = MovePlayer(self.robot, m) # move_player.start() # time.sleep(1.5) # self._speak.start("Mon premier est un bruit malpoli. Mon deuxième est très joli. Mon tout est ce que je suis!") # #sortie while # elif rep == "o" : # with open(self._moveo) as f : # m = Move.load(f) # move_player = MovePlayer(self.robot, m) # move_player.start() # time.sleep(1.5) # self._speak.start("Bravo! C'est bien Robot!") # break
def run(self): poppy = self.robot for m in poppy.motors: m.compliant = False num1 = random.randint(1, 10) num2 = random.randint(1, 10) sol = num2 * num1 if num1 == 1: text1 = "un" elif num1 == 2: text1 = "deux" elif num1 == 3: text1 = "trois" elif num1 == 4: text1 = "quatre" elif num1 == 5: text1 = "cinq" elif num1 == 6: text1 = "six" elif num1 == 7: text1 = "sept" elif num1 == 8: text1 = "huit" elif num1 == 9: text1 = "neuf" elif num1 == 10: text1 = "dix" else: text1 = "un" if num2 == 1: text2 = "un" elif num2 == 2: text2 = "deux" elif num2 == 3: text2 = "trois" elif num2 == 4: text2 = "quatre" elif num2 == 5: text2 = "cinq" elif num2 == 6: text2 = "six" elif num2 == 7: text2 = "sept" elif num2 == 8: text2 = "huit" elif num2 == 9: text2 = "neuf" elif num2 == 10: text2 = "dix" else: text2 = "un" print(sol) print "Lancer vrai1 si le patient répond bien, faux il se trompe." text = "Dis moi, combien font " + text1 + "fois " + text2 + "?" with open(self._move) as f: m = Move.load(f) move_player = MovePlayer(self.robot, m) move_player.start() time.sleep(0.5) self._speak.start(text)