Example #1
0
        if (len(data) == 0):
            if (printData):
                print "None"
            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"
Example #2
0

    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")
Example #3
0
    return fileList


def Purge(basePath, fileList):
    for file in fileList:
        try:
            fullPath = os.path.normpath(os.path.join(basePath, "." + file))
            print "Delete:", fullPath
            os.remove(fullPath)
        except:
            print "Deletion failed:", fullPath


PIDName = "Update"
if (Pid.HasPid(PIDName)):
    print "Update already running"
    exit()
Pid.Create(PIDName)

try:

    deploymentPath = os.path.join(Global.RootPath, 'Deployment')
    Global.EnsureDirectoryExists(deploymentPath)
    versionFilePath = os.path.join(deploymentPath, 'versionfile.txt')

    downloadFilename = os.path.join(deploymentPath, 'currentVersion.tar.gz')

    if Config().GetBoolean("DEFAULT", "Beta"):  # Default False
        highestVersionNumber = 'beta'
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")
Example #5
0
# -*- 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")
Example #6
0
                        continue

                    self.SendTrigger("KEY", event.key)

    def SendTrigger(self, name, pressId):
        triggerData = "TRIGGER|{0}|{1}|{2}".format(name, pressId,
                                                   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)
Example #7
0
            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")
Example #8
0
    camType = "STD"
    surveillanceMode = False
    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()
Example #9
0
                              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")
Example #12
0
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")
Example #13
0
        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")