continue if (printData): print "We got:", data FileLogger().Info("STT, RunSTT(), Input Data: {0}".format(data)) rospy.loginfo("STT|{0}".format(data)) pub.publish("STT|{0}".format(data)) if __name__ == "__main__": if (Pid.HasPid("STT")): print "Process is already runnung. Bye!" sys.exit() Pid.Create("STT") printData = False if len(sys.argv) > 1: for arg in sys.argv: if (arg.lower().startswith("-output")): printData = True try: InitSettings() RunSTT(printData) except KeyboardInterrupt: print "End" finally: Pid.Remove("STT")
def ProcessAnimation(self, animation): if animation is not None and len(animation) > 0: print animation, "TODO" animationData = "FACEMASTER|{0}".format(animation) rospy.loginfo(animationData) self.__FaceappPublisher.publish(animationData) def __TTSActive(self): storedTimestamp = TTSMemory().GetFloat("TTS.Until") if(storedTimestamp >= rospy.Time.now().to_sec()): return True return False ##### MAIN ##### if __name__ == "__main__": if(Pid.HasPid("Brain.STT")): print "Process is already runnung. Bye!" sys.exit() Pid.Create("Brain.STT") try: BrainSTT() except KeyboardInterrupt: print "End" finally: Pid.Remove("Brain.STT")
targetFileList = GetFileList(Global.EmeraldPath) diffList = list(set(targetFileList) - set(sourceFileList)) diffList = [ x for x in diffList if not x.endswith('.pyc') and not x.endswith('.mdl') and not x.endswith('.npy') and not x.endswith('.mp3') and not x.endswith('.config') and not x.endswith('.sqlite') and not x.endswith('.log') and not x.startswith('/Data/ComputerVisionData') ] Purge(Global.EmeraldPath, diffList) print "Update files" # move into destination MoveDirectory( os.path.join(deploymentPath, extractedFolderName, 'EmeraldAI'), Global.EmeraldPath) # update version file = open(versionFilePath, 'w') file.write(highestVersionNumber) file.close() # delete everything left over in tmp folder os.remove(downloadFilename) shutil.rmtree(os.path.join(deploymentPath, extractedFolderName)) finally: Pid.Remove(PIDName)
from EmeraldAI.Logic.Modules import Pid from EmeraldAI.Logic.Logger import FileLogger def EnsureModelUpdate(): moduleList = Config().GetList("ComputerVision", "Modules") for moduleName in moduleList: if (ModelMonitor().CompareHash( moduleName, ModelMonitor().GetStoredHash(moduleName))): continue FileLogger().Info( "CV Model Rebuilder: Rebuild {0} Model".format(moduleName)) ModelMonitor().Rebuild(moduleName) ##### MAIN ##### if __name__ == "__main__": if (Pid.HasPid("CVModelRebuilder")): print "Process is already runnung. Bye!" sys.exit() Pid.Create("CVModelRebuilder") try: EnsureModelUpdate() except KeyboardInterrupt: print "End" finally: Pid.Remove("CVModelRebuilder")
# -*- coding: utf-8 -*- import sys from os.path import dirname, abspath sys.path.append(dirname(dirname(dirname(dirname(abspath(__file__)))))) reload(sys) sys.setdefaultencoding('utf-8') from EmeraldAI.Logic.SpeechProcessing.Watson import Watson from EmeraldAI.Logic.Modules import Pid from EmeraldAI.Config.Config import Config def RunSTT(): sttProvider = Config().Get("SpeechToText", "Provider") if(sttProvider.lower() == "watson"): provider = Watson() provider.Listen() if __name__ == "__main__": if(Pid.HasPid("STTLive")): print "Process is already runnung. Bye!" sys.exit() Pid.Create("STTLive") try: RunSTT() except KeyboardInterrupt: print "End" finally: Pid.Remove("STTLive")
rospy.Time.now().to_sec()) rospy.loginfo(triggerData) self.__Publisher.publish(triggerData) def GPIOTrigger(self, callback): self.SendTrigger(self.__GPIOTriggerName, self.__GPIOInputChannel) if __name__ == "__main__": if (Pid.HasPid("Trigger")): print "Process is already runnung. Bye!" sys.exit() Pid.Create("Trigger") try: tmpTriggername = None if len(sys.argv) > 1: for arg in sys.argv: if (arg.lower().startswith("-name")): tmpTriggername = int(arg.lower().replace("-name", "")) if tmpTriggername is None: HardwareTrigger() else: HardwareTrigger(tmpTriggername) except KeyboardInterrupt: print "End" finally: Pid.Remove("Trigger")
audioPlayer = Config().Get("TextToSpeech", "AudioPlayer") + " '{0}'" os.system(audioPlayer.format(data)) FileLogger().Info("TTS, callback(), Play Audio: {0}".format(data)) GLOBAL_FileNamePublisher.publish("TTS|{0}".format(data)) user = User().LoadObject() if (user.GetName() is not None): user.UpdateSpokenTo() user.Update() except Exception as e: FileLogger().Error( "TTS, callback(), Error on processing TTS data: {0}".format(e)) if __name__ == "__main__": if (Pid.HasPid("TTS")): print "Process is already runnung. Bye!" sys.exit() Pid.Create("TTS") try: InitSettings() RunTTS() except KeyboardInterrupt: print "End" finally: Pid.Remove("TTS")
if len(sys.argv) > 1: for arg in sys.argv: if (arg.lower().startswith("-cam")): camID = int(arg.lower().replace("-cam", "")) if (arg.lower().startswith("-type")): camType = int(arg.lower().replace("-type", "")) if (arg.lower().startswith("-surveillance")): surveillanceMode = True if (camID < 0): camID = Config().GetInt("ComputerVision", "CameraID") tmpCamID = "" if camID == -1 else camID if (Pid.HasPid("CV{0}".format(tmpCamID))): print "Process is already runnung. Bye!" sys.exit() Pid.Create("CV{0}".format(tmpCamID)) videoStream = None if Config().GetBoolean("ComputerVision", "UseThreadedVideo"): videoStream = WebcamVideoStream(camID) try: EnsureModelUpdate() RunCV(camID, camType, surveillanceMode, videoStream) except KeyboardInterrupt: print "End" finally: videoStream.stop() Pid.Remove("CV{0}".format(tmpCamID))
Clock, queue_size=2) rate = rospy.Rate(10) # Herz clockMessage = Clock() while True: clockData = "CLOCK|{0}".format(int(round(time.time()))) systemTime.publish(clockData) clockMessage.clock = rospy.Time.now() rosTime.publish(clockMessage) rate.sleep() ##### MAIN ##### if __name__ == "__main__": if (Pid.HasPid("Clock")): print "Process is already runnung. Bye!" sys.exit() Pid.Create("Clock") try: RunClock() except KeyboardInterrupt: print "End" finally: Pid.Remove("Clock")
if (len(response) > 1): FileLogger().Info( "ActionTrigger, unknownPersonCallback(): {0}".format( response)) self.__ResponsePublisher.publish("TTS|{0}".format(response)) self.__IFTTTWebhook.TriggerWebhook(self.__IFTTTIntruder) self.__TriggerPublisher.publish("TRIGGER|Warning|Intruder") def appCallback(self, data): dataParts = data.data.split("|") if dataParts[0] == "FACEAPP": response = "TRIGGER_FACEAPP_{0}".format( dataParts[1]) # == ON / OFF FileLogger().Info( "ActionTrigger, appCallback(): {0}".format(response)) self.__SpeechTriggerPublisher.publish("STT|{0}".format(response)) if __name__ == "__main__": if (Pid.HasPid("Brain.Trigger")): print "Process is already runnung. Bye!" sys.exit() Pid.Create("Brain.Trigger") try: BrainActionTrigger() except KeyboardInterrupt: print "End" finally: Pid.Remove("Brain.Trigger")
nodeNameToRepeat): return for t in data.transforms: TFLooper().add(t) def mainLoop(): rateInHz = 20 # in Hz rospy.init_node(nodeName) rospy.Subscriber('tf', TFMessage, callback) rate = rospy.Rate(rateInHz) # hz while not rospy.is_shutdown(): if not TFLooper().loop(): rate.sleep() rate.sleep() if __name__ == '__main__': if (Pid.HasPid("SerialTFRepeater")): print "Process is already runnung. Bye!" sys.exit() Pid.Create("SerialTFRepeater") try: mainLoop() except KeyboardInterrupt: print "End" finally: Pid.Remove("SerialTFRepeater")
from EmeraldAI.Logic.Modules import Pid from EmeraldAI.Config.Config import Config def RunMovement(): rospy.init_node('movement_node', anonymous=True) rospy.Subscriber("/emerald_ai/movement/commander", String, callback) rospy.spin() def callback(data): dataParts = data.data.split("|") print dataParts if __name__ == "__main__": if (Pid.HasPid("Movement")): print "Process is already runnung. Bye!" sys.exit() Pid.Create("Movement") try: RunMovement() except KeyboardInterrupt: print "End" finally: Pid.Remove("Movement")
for port in finderResult: if port in processList: continue else: print "Launching process for", port process = multiprocessing.Process(name=port, target=Processing, args=( port, baud, )) process.start() processList[port] = process time.sleep(timeToSleep) if __name__ == "__main__": if (Pid.HasPid("SerialToRos")): print "Process is already runnung. Bye!" sys.exit() Pid.Create("SerialToRos") try: mainLoop() except KeyboardInterrupt: print "End SerialToRos" finally: Pid.Remove("SerialToRos")