Exemplo n.º 1
0
 def command_autopilot(self):
     text = 'Runing autopilot!'
     speech = Speech()
     speech.create_voice(text)
     process = RaspieAutopilotProcess()
     process.start()
     return True
Exemplo n.º 2
0
 def command_weatcher(self):
     weather = Weather()
     weatcherData = weatcher.check_weather()
     text = weather['forecast']['txt_forecast']['forecastday'][0][
         'fcttext_metric']
     speech = Speech()
     speech.create_voice(text)
     return True
Exemplo n.º 3
0
 def key_control(self):
     for event in pygame.event.get():
         if event.type == pygame.KEYDOWN and event.key == pygame.K_POWER:
             self.shutdown()
         if event.type == pygame.KEYDOWN and event.key == pygame.K_0:
             self.shutdown()
         if event.type == pygame.KEYDOWN and event.key == pygame.K_9:
             self.display_text('Restarting raspie...')
             PyMove().gpio_cleanup()
             time.sleep(2)
             subprocess.call(['.././start.sh'])
             sys.exit()
         if event.type == pygame.KEYUP and event.key == pygame.K_1:
             self.run_autopilot()
             
             autopilot_process.start()
         if event.type == pygame.KEYDOWN and event.key == pygame.K_8:
             print 'Cleaning up gpio'
             PyMove().gpio_cleanup()
         if event.type == pygame.KEYUP and event.key == pygame.K_2:
             text = "Good Morning! My name is Shadow. I am prototype of home asistant robot. I was programmed to listen to your commands."
             self.display_text(text)
             Speech().create_voice(text)
         if event.type == pygame.KEYUP and event.key == pygame.K_3:
             text = "Let's dance!"
             speech = Speech()
             speech.create_voice(text)
             self.display_text(text)
             PyMove().run_left_start()
             time.sleep(1)
             PyMove().run_left_stop()
             PyMove().run_right_start()
             time.sleep(1)
             PyMove().run_right_stop()
             PyMove().run_up_start()
             time.sleep(1)
             PyMove().run_up_stop()
             PyMove().run_down_start()
             time.sleep(1)
             PyMove().run_down_stop()
         if event.type == pygame.KEYDOWN and event.key == pygame.K_4:
             self.play_sound('sounds/Very_Excited_R2D2.mp3')                               
         if event.type == pygame.KEYDOWN and event.key == pygame.K_UP:
             PyMove().run_up_start()
         elif event.type == pygame.KEYUP and event.key == pygame.K_UP:
             PyMove().run_up_stop()
         if event.type == pygame.KEYDOWN and event.key == pygame.K_DOWN:
             PyMove().run_down_start()
         elif event.type == pygame.KEYUP and event.key == pygame.K_DOWN:
             PyMove().run_down_stop()
         if event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT:
             PyMove().run_left_start()
         elif event.type == pygame.KEYUP and event.key == pygame.K_LEFT:
             PyMove().run_left_stop()
         if event.type == pygame.KEYDOWN and event.key == pygame.K_RIGHT:
             PyMove().run_right_start()
         elif event.type == pygame.KEYUP and event.key == pygame.K_RIGHT:
             PyMove().run_right_stop()
Exemplo n.º 4
0
 def listen_commands(self):
     text = "How I can help You."
     speech = Speech()
     speech.create_voice(text)
     r = SpeechRecognizer()
     command = (r.recognize()).lower()
     print 'Recognized command: {0}'.format(command)
     if 'weatcher' in command:
         self.command_weatcher()
     if 'autopilot' in command:
         self.command_autopilot()
     if 'dance' in command:
         self.command_dance()
     if 'exterminate' in command:
         self.command_exterminate()
Exemplo n.º 5
0
 def key_control(self, q_state):
     q_state.put('open')
     while True:
         if not q_state.empty():
             close = q_state.get()
             if close == 'exit':
                 print 'exiting key_control...'
                 break
             else:
                 pass
         for event in pygame.event.get():
             if event.type == pygame.KEYDOWN and event.key == pygame.K_POWER:
                 self.shutdown()
             if event.type == pygame.KEYDOWN and event.key == pygame.K_1:
                 self.display_text('Closing raspie...')
                 q_state.put('exit')
                 gpio.cleanup()
                 time.sleep(2)
                 sys.exit()
             if event.type == pygame.KEYUP and event.key == pygame.K_2:
                 autopilot_process = Process(target=self.autopilot_process, args=(q_state,))
                 autopilot_process.start()
                     
             if event.type == pygame.KEYDOWN and event.key == pygame.K_3:
                 print 'Cleaning up gpio'
                 gpio.cleanup()
             if event.type == pygame.KEYDOWN and event.key == pygame.K_4:
                 text = "Co słychać?"
                 speech = Speech()
                 speech.create_voice(text)
                 self.display_text(text)
             if event.type == pygame.KEYDOWN and event.key == pygame.K_5:
                 text = "Let's dance!"
                 speech = Speech()
                 speech.create_voice(text)
                 self.display_text(text)
                 self.run_left_start()
                 time.sleep(1)
                 self.run_left_stop()
                 self.run_right_start()
                 time.sleep(1)
                 self.run_right_stop()
                 self.run_up_start()
                 time.sleep(1)
                 self.run_up_stop()
                 self.run_down_start()
                 time.sleep(1)
                 self.run_down_stop()
             if event.type == pygame.KEYDOWN and event.key == pygame.K_UP:
                 self.run_up_start()
             elif event.type == pygame.KEYUP and event.key == pygame.K_UP:
                 self.run_up_stop()
             if event.type == pygame.KEYDOWN and event.key == pygame.K_DOWN:
                 self.run_down_start()
             elif event.type == pygame.KEYUP and event.key == pygame.K_DOWN:
                 self.run_down_stop()
             if event.type == pygame.KEYDOWN and event.key == pygame.K_LEFT:
                 self.run_left_start()
             elif event.type == pygame.KEYUP and event.key == pygame.K_LEFT:
                 self.run_left_stop()
             if event.type == pygame.KEYDOWN and event.key == pygame.K_RIGHT:
                 self.run_right_start()
             elif event.type == pygame.KEYUP and event.key == pygame.K_RIGHT:
                 self.run_right_stop()
Exemplo n.º 6
0
 def command_dance(self):
     text = 'Exterminate, exterminate, exterminate!'
     speech = Speech()
     speech.create_voice(text)
     return True
Exemplo n.º 7
0
 def command_dance(self):
     text = 'Lets Dance!'
     speech = Speech()
     speech.create_voice(text)
     return True