예제 #1
0
 def update_ft_state_to_atomspace(self, enabled):
     if enabled:
         state = 'on'
     else:
         state = 'off'
     face = '(StateLink face-tracking-state face-tracking-%s)\n' % state
     netcat(self.hostname, self.port, face)
예제 #2
0
	def update_ft_state_to_atomspace(self, enabled):
		if enabled:
			state = 'on'
		else:
			state = 'off'
		face = '(StateLink face-tracking-state face-tracking-%s)\n' % state
		netcat(self.hostname, self.port, face)
예제 #3
0
	def saliency(self, x, y, z, deg):
		sal = '(StateLink (AnchorNode "Salient location")' + \
			'(List (NumberNode '+ str(x)+ ')' + \
			'  (NumberNode '+ str(y) + ')' + \
			'  (NumberNode '+ str(z) + ')))\n' + \
			'(StateLink (AnchorNode "Salient degree")' + \
			'  (NumberNode '+ str(deg) + '))\n'
		netcat(self.hostname, self.port, sal)
예제 #4
0
 def parse_status(self):
     self.status=dict()
     for entry in self.hosts:
         host,port=entry.split(':')
         self.status[host]=dict()
         self.status[host]['ok']=True if netcat.netcat(host,int(port),'ruok') == 'imok' else False
         self.status[host]['rw']=True if netcat.netcat(host,int(port),'isro') == 'rw' else False
         self.status[host]['version'],self.status[host]['mode'],self.status[host]['latency']=Zookeeper.get_status(host,port)
예제 #5
0
 def saliency(self, x, y, z, deg):
     sal = '(StateLink (AnchorNode "locations")' + \
      '(List (NumberNode '+ str(x)+ ')' + \
      '(NumberNode '+ str(y)+ ')' + \
      '(NumberNode '+ str(z) + ')))\n' + \
      '(StateLink (AnchorNode "Degree value")' + \
      '(NumberNode '+ str(deg)+'))\n'
     netcat(self.hostname, self.port, sal)
 def create_face_octomap(self):
     ldcmd = '(use-modules (opencog pointmem))'
     cmd = '(cog-pointmem-create-map (ConceptNode "' + self.OCTOMAP_NAME + '") \
            (ListLink (NumberNode "' + self.SPATIAL_RESOLUTION + '") \
                      (NumberNode "' + self.TIME_RESOLUTION + '") \
                      (NumberNode "' + self.TIME_UNITS + '")))'
     cmd = ldcmd + "\n" + cmd + "\n"
     print("Sending message %s " % cmd)
     netcat(self.hostname, self.port, cmd)
 def update_face_octomap(self, faceid, xx, yy, zz):
     face = '(cog-pointmem-map-atom (ConceptNode "' + self.OCTOMAP_NAME + '") \
            (NumberNode "' + str(faceid) + '" (av 5 0 0)) \
            (ListLink (NumberNode "' + str(xx) + '") \
                      (NumberNode "' + str(yy) + '") \
                      (NumberNode "' + str(zz) + '")))'
     face = face + "\n"
     print("Sending message %s " % face)
     netcat(self.hostname, self.port, face)
예제 #8
0
	def create_face_octomap(self):
		ldcmd = '(use-modules (opencog pointmem))'
		cmd = '(cog-pointmem-create-map (ConceptNode "'+self.OCTOMAP_NAME+'") \
               (ListLink (NumberNode "'+ self.SPATIAL_RESOLUTION+'") \
                         (NumberNode "'+ self.TIME_RESOLUTION+'") \
                         (NumberNode "'+ self.TIME_UNITS+'")))'
		cmd = ldcmd + "\n" + cmd + "\n"
		print("Sending message %s " % cmd)
		netcat(self.hostname, self.port, cmd)
예제 #9
0
	def update_face_octomap(self, faceid, xx, yy, zz):
		face = '(cog-pointmem-map-atom (ConceptNode "'+self.OCTOMAP_NAME+'") \
               (NumberNode "'+ str(faceid)+'" (av 5 0 0)) \
               (ListLink (NumberNode "'+ str(xx)+'") \
                         (NumberNode "'+ str(yy)+'") \
                         (NumberNode "'+ str(zz)+'")))'
		face = face + "\n"
		print("Sending message %s " % face)
		netcat(self.hostname, self.port, face)
	def face_recognition(self,tracker_id,rec_id):
		'''
		tracker_id is id for tracking, needs to map to recocgzed or unrecognized rec_id.
		rec_id is "0" for un recognized face and some other string for recognized face
		if THIS evaluation link does not exist then face is seen but not determined as known or unknown
		rec_id is a string and is stored as ConceptNode
		tracker_id is integer stored as NumberNode
		'''
		stl = "(EvaluationLink (Predicate \"name\") (ListLink (ConceptNode \"" + str(tracker_id) + "\") (ConceptNode \"" + rec_id + "\")))\n"
		#stl = "(StateLink (NumberNode \"" + str(faceid) + "\") (ConceptNode \"" + rec_id +"\"))\n"
		netcat(self.hostname, self.port, stl + "\n")
예제 #11
0
 def parse_status(self):
     self.status = dict()
     for entry in self.hosts:
         host, port = entry.split(':')
         self.status[host] = dict()
         self.status[host]['ok'] = True if netcat.netcat(
             host, int(port), 'ruok') == 'imok' else False
         self.status[host]['rw'] = True if netcat.netcat(
             host, int(port), 'isro') == 'rw' else False
         self.status[host]['version'], self.status[host][
             'mode'], self.status[host]['latency'] = Zookeeper.get_status(
                 host, port)
예제 #12
0
	def face_recognition(self, tracker_id, name):
		'''
		Associate a face-recognition ID with a face-tracker ID.

		`tracker_id` is the ID that the 3D face-location tracker is using.
		Currently, the tracker-ID is an integer, stored as a NumberNode
		in the atomspace.

		`rec_id` is "0" for an unrecognized face and some other string
		for a recognized face. It is currently stored as a ConceptNode.
		'''
		fc = '(make-recognized-face ' + str(tracker_id) + ' "' + name + '")\n'
		netcat(self.hostname, self.port, fc)
예제 #13
0
    def face_recognition(self, tracker_id, name):
        '''
		Associate a face-recognition ID with a face-tracker ID.

		`tracker_id` is the ID that the 3D face-location tracker is using.
		Currently, the tracker-ID is an integer, stored as a NumberNode
		in the atomspace.

		`rec_id` is "0" for an unrecognized face and some other string
		for a recognized face. It is currently stored as a ConceptNode.
		'''
        fc = '(make-recognized-face ' + str(tracker_id) + ' "' + name + '")\n'
        netcat(self.hostname, self.port, fc)
예제 #14
0
	def face_recognition(self, tracker_id, rec_id):
		'''
		Associate a face-recognition ID with a face-tracker ID.

		`tracker_id` is the ID that the 3D face-location tracker is using.
		Currently, the tracker-ID is an integer, stored as a NumberNode
		in the atomspace.

		`rec_id` is "0" for an unrecognized face and some other string
		for a recognized face. It is currently stored as a ConceptNode.
		'''
		stl = "(EvaluationLink (Predicate \"name\") " + \
			"(ListLink (ConceptNode \"" + \
			str(tracker_id) + "\") (ConceptNode \"" + rec_id + "\")))\n"
		netcat(self.hostname, self.port, stl)
예제 #15
0
 def GetSuddenClass(self, msg):
   change = msg.data
   print "sudden sound change value {}".format(msg.data)
   loud = "(StateLink (AnchorNode \"Sudden sound change value\")" + \
            "(ListLink(NumberNode {})))\n".format(msg.data)
   
   netcat(self.hostname, self.port, loud + "\n")
   
   if int(change) >= 10:
       l = "(cog-evaluate! (EvaluationLink (DefinedPredicateNode \"Show expression\")" + \
          "(ListLink (ConceptNode \"surprised\") (NumberNode 2) (NumberNode 0.5))))\n"
                 
       netcat(self.hostname, self.port, l + "\n")
   else:
       self.AudioEnergy(self.Decibel)
예제 #16
0
    def face_recognition(self, tracker_id, rec_id):
        '''
		Associate a face-recognition ID with a face-tracker ID.

		`tracker_id` is the ID that the 3D face-location tracker is using.
		Currently, the tracker-ID is an integer, stored as a NumberNode
		in the atomspace.

		`rec_id` is "0" for an unrecognized face and some other string
		for a recognized face. It is currently stored as a ConceptNode.
		'''
        stl = "(EvaluationLink (Predicate \"name\") " + \
         "(ListLink (ConceptNode \"" + \
         str(tracker_id) + "\") (ConceptNode \"" + rec_id + "\")))\n"
        netcat(self.hostname, self.port, stl)
예제 #17
0
파일: app.py 프로젝트: wwwins/TreeAdmin
def home(name='茫茫大海'):
    # Server Title
    SERVER_TITLE = "TreeGateway Daemon v1.0 \r\n"
    # 設定裝置名稱
    # deviceName = ["0號機","1號機","2號機","NANO","4號機"]
    deviceName = ["大會議室","小魚缸","UX","NANO","Edith"]
    # 設定最大距離
    maxDistance = 15.0
    # receive data from TreeGateway
    # nc localhost 8888
    # format: [ID,ADDRESS,ONLINE,DISTANCE]
    # passData.append([0,"00",int("1"),0.0])
    # passData.append([1,"041",int("1"),0.0])
    # passData.append([2,"03",int("1"),0.0])
    # passData.append([4,"01",int("0"),0.0])
    currentDistance = 100
    currentNode = -1
    passData = []
    results = ''
    try:
        # TreeGateway
        results = netcat('192.168.200.102',8888,'INFO')
    except socket.error as e:
        print "Socket Error"

    if len(results)>len(SERVER_TITLE):
        nodes = results[len(SERVER_TITLE):].split('\n')
        for node in nodes:
            if node:
                s = node.split(' ')
                if (float(s[3])<0.1):
                    dist = '???'
                else:
                    if currentDistance > float(s[3]) and int(s[2]) > 0:
                        currentDistance = float(s[3])
                        currentNode = int(s[0])
                    if float(s[3]) > maxDistance:
                        dist = "{:.2f}m!".format(float(s[3]))
                    else:
                        dist = "{:.2f}m".format(float(s[3]))
                passData.append([int(s[0]),s[1],int(s[2]),dist])

    if currentNode < 0:
        name = name
    else:
        name = deviceName[currentNode]

    # 搜尋目錄 ./ 及 ./views 下 gatewap.tpl
    # tpl 檔案裡的 {{變數}} 會被相對應的 變數 取代
    # location=name 是指 tpl 裡的 {{location}} 會被 name 取代
    # 傳入的 name 如果含有 html tag 會被 escape
    # 如果不要 escape 請在前面加上驚嘆號 {{!location}}
    return template('gateway',deviceName=deviceName,location=name,passData=passData)
예제 #18
0
 def send_command(self, script):
     self.script = script
     self.command = ("echo '%s' > run.py;python3 run.py" % (script))
     self.result = netcat(self.host, self.port, self.command)
     dec = [
         i.decode().replace("[", "").replace("]", "").split(",")
         for i in self.result
     ]
     res = [i for i in dec[0]]
     if len(res) == 1:
         res = res[0]
     print(res + "\r")
예제 #19
0
async def NetCatRank(ctx):
    if ctx.message.mentions and ctx.message.mentions[0]:
        try:
            cls = netcat.netcat(ctx.message.mentions[0].id)
            await bot.send_message(
                ctx.message.channel,
                "[NetCat API] ~ User {}'s rank is {}".format(
                    cls.username, cls.rank))

        except ValueError as e:
            await bot.send_message(ctx.message.channel,
                                   "[NetCat API] ~ {}".format(e))
            return
예제 #20
0
 def get_status(host,port):
     version=""
     latency=""
     mode=""
     status = netcat.netcat(host,int(port),'stat')
     for line in status.splitlines():
         m = re.match('^Zookeeper version:\s*(?P<VERSION>.+)',line)
         if m:
             version = m.group('VERSION')
         m = re.match('Mode:\s(?P<MODE>.+)',line)
         if m:
             mode = m.group('MODE')
         m = re.match('Latency min/avg/max:\s*\d+/(?P<AVG>\d+)/\d+',line)
         if m:
             latency=int(m.group('AVG'))
     return version,mode,latency
예제 #21
0
 def get_status(host, port):
     version = ""
     latency = ""
     mode = ""
     status = netcat.netcat(host, int(port), 'stat')
     for line in status.splitlines():
         m = re.match('^Zookeeper version:\s*(?P<VERSION>.+)', line)
         if m:
             version = m.group('VERSION')
         m = re.match('Mode:\s(?P<MODE>.+)', line)
         if m:
             mode = m.group('MODE')
         m = re.match('Latency min/avg/max:\s*\d+/(?P<AVG>\d+)/\d+', line)
         if m:
             latency = int(m.group('AVG'))
     return version, mode, latency
예제 #22
0
async def NetCatChallenges(ctx):
    if ctx.message.mentions and ctx.message.mentions[0]:
        try:
            cls = netcat.netcat(ctx.message.mentions[0].id)
            challengelist = ""

            for challenge in cls.complete_challenges:
                challengelist += challenge + "\n"

            await bot.send_message(
                ctx.message.channel,
                "[NetCat API] ~ User {} has completed {} challenges:\n{}".
                format(cls.username, len(cls.complete_challenges),
                       challengelist))

        except ValueError as e:
            await bot.send_message(ctx.message.channel,
                                   "[NetCat API] ~ {}".format(e))
            return
예제 #23
0
 def wholeshow_start(self):
     netcat(self.hostname, self.port, "(enable-all-demos)")
     netcat(self.hostname, self.port, '(run)')
예제 #24
0
	def remove_face_from_atomspace(self, faceid):

		# AtomSpace cog-delete takes handle as an argument.
		msg = self.delete_face(faceid)
		netcat(self.hostname, self.port, msg)
		print "Removed face from atomspace: ", faceid
예제 #25
0
	def add_face_to_atomspace(self, faceid):
		face = "(EvaluationLink (PredicateNode \"visible face\") " + \
		       "(ListLink (NumberNode \"" + str(faceid) + "\")))\n"
		netcat(self.hostname, self.port, face)
		print "New visible face in atomspace: ", faceid
예제 #26
0
 def add_tracked_face_to_atomspace(self, faceid):
     face = '(StateLink request-eye-contact-state (NumberNode "' + \
            str(faceid) + '"))\n'
     netcat(self.hostname, self.port, face)
     print "Force focus of attention on face: ", faceid
예제 #27
0
	def add_face_to_atomspace(self, faceid):
		face = self.define_face(faceid)
		netcat(self.hostname, self.port, face + "\n")
		print "New visible face in atomspace: ", faceid
	def who_said(self,stt):
		spoke = "(who-said? \""+stt+"\")\n"
		print spoke
		netcat(self.hostname, self.port, spoke + "\n")
예제 #29
0
	def vocalization_started(self):
		netcat(self.hostname, self.port, "(State chat-state chat-start)")
예제 #30
0
	def wholeshow_stop(self):
		netcat(self.hostname, self.port, "(disable-all-demos)")
		netcat(self.hostname, self.port, "(halt)")
예제 #31
0
 def audio_energy(self, decibel):
     # A StateLink is used because evaluation of psi-rules should
     # only depend on the most recent value.
     deci = '(StateLink (AnchorNode "Decibel value") ' + \
      ' (NumberNode ' + str(decibel) + '))\n'
     netcat(self.hostname, self.port, deci)
예제 #32
0
	def audio_energy(self, decibel):
		# A StateLink is used because evaluation of psi-rules should
		# only depend on the most recent value.
		deci = '(StateLink (AnchorNode "Decibel value") ' + \
			' (NumberNode ' + str(decibel) + '))\n'
		netcat(self.hostname, self.port, deci)
예제 #33
0
	def add_tracked_face_to_atomspace(self, faceid):
		face = '(StateLink request-eye-contact-state (NumberNode "' + \
		       str(faceid) + '"))\n'
		netcat(self.hostname, self.port, face)
		print "Force focus of attention on face: ", faceid
예제 #34
0
	def room_brightness(self, bright):
		room = '(StateLink (AnchorNode "luminance")' +\
			' (NumberNode ' + str(bright) +'))\n'
		netcat(self.hostname, self.port, room)
예제 #35
0
	def audio_bang(self, decibel):
		loud = '(StateLink (AnchorNode "Sudden sound change value")' + \
			' (NumberNode ' + str(decibel) + '))\n'
		netcat(self.hostname, self.port, loud)
	def save_snd1(self,x,y,z):
		snd="(map-sound "+str(x)+" "+str(y)+" "+str(z)+")\n"
		netcat(self.hostname, self.port, snd + "\n")
예제 #37
0
	def evaluate_scm(self, scm_string):
		netcat(self.hostname, self.port, scm_string)
예제 #38
0
	def vocalization_ended(self):
		netcat(self.hostname, self.port, "(State chat-state chat-stop)")
	def update_ft_state_to_atomspace(self, ft_enabled):
		str = self.set_face_tracking_state(ft_enabled)
		netcat(self.hostname, self.port, str + "\n")
	def update_face_octomap(self, faceid, xx, yy, zz):
		face="(map-ato \"faces\" (NumberNode \""+str(faceid)+"\" (av 5 0 0)) "+str(xx)+" "+str(yy)+" "+str(zz)+")\n"
		netcat(self.hostname, self.port, face + "\n")
예제 #41
0
  def AudioEnergy(self, value):
    # A StateLink is used b/c evaluation of psi-rules should only depend on
    # the most value.
    deci = "(StateLink (AnchorNode \"Decibel value\")" + \
                "(ListLink (NumberNode {})))\n".format(value)

    netcat(self.hostname, self.port, deci + "\n")

    # TODO: Convert each if/elif clause into a psi-rule.
    if value < 35:
        print "very low sound", value
        x = "(cog-evaluate! (EvaluationLink  (DefinedPredicateNode \"Show expression\")" + \
       "(ListLink (ConceptNode \"happy\") (NumberNode 3) (NumberNode 0.5))))\n"


        netcat(self.hostname, self.port, x + "\n")

        return 'Quiet Whisper'

    elif value < 65:
        print "Normal conversation:", value

        y = "(cog-evaluate! (EvaluationLink  (DefinedPredicateNode \"Show expression\")" + \
       "(ListLink (ConceptNode \"amused\") (NumberNode 3) (NumberNode 0.5))))\n"

        netcat(self.hostname, self.port, y + "\n")

        m = "(cog-evaluate! (EvaluationLink  (DefinedPredicateNode \"Show gesture\")" + \
       "(ListLink (ConceptNode \"nod-1\") (NumberNode 0.2) (NumberNode 2) (NumberNode 0.8))))\n"

        netcat(self.hostname, self.port, m + "\n")

        return 'Normal Conversation'

    elif value < 90:
        print "high sound:", value
        z = "(cog-evaluate! (EvaluationLink  (DefinedPredicateNode \"Show expression\")" + \
       "(ListLink (ConceptNode \"irritated\") (NumberNode 3) (NumberNode 0.5))))\n"
        netcat(self.hostname, self.port, z + "\n")

        n = "(cog-evaluate! (EvaluationLink  (DefinedPredicateNode \"Show gesture\")" + \
       "(ListLink (ConceptNode \"think-browsDown.001\") (NumberNode 0.2) (NumberNode 2) (NumberNode 0.8))))\n"

        netcat(self.hostname, self.port, n + "\n")
        return 'Loud: Shouted Conversation'
    else:
        print 'critical:', value
        t = "(cog-evaluate! (EvaluationLink  (DefinedPredicateNode \"Show expression\")" + \
       "(ListLink (ConceptNode \"afraid\") (NumberNode 3) (NumberNode 0.5))))\n"
        netcat(self.hostname, self.port, t + "\n")
        return 'Loud: Critical'
예제 #42
0
 def who_said(self, stt):
     spoke = "(who-said? \"" + stt + "\")\n"
     netcat(self.hostname, self.port, spoke)
예제 #43
0
 def add_tracked_face_to_atomspace(self, faceid):
     face = self.set_tracked_face(faceid)
     netcat(self.hostname, self.port, face + "\n")
     print "Force focus of attention on face: ", faceid
예제 #44
0
	def update_sound(self, x, y, z):
		snd = "(map-sound " + str(x) + " " + str(y) + " " + str(z) + ")\n"
		netcat(self.hostname, self.port, snd)
예제 #45
0
 def update_sound(self, x, y, z):
     snd = "(map-sound " + str(x) + " " + str(y) + " " + str(z) + ")\n"
     netcat(self.hostname, self.port, snd)
예제 #46
0
 def affect_happy(self):
     netcat(self.hostname, self.port, "(State chat-affect chat-happy)")
예제 #47
0
 def audio_bang(self, decibel):
     loud = '(StateLink (AnchorNode "Sudden sound change value")' + \
      ' (NumberNode ' + str(decibel) + '))\n'
     netcat(self.hostname, self.port, loud)
예제 #48
0
 def affect_negative(self):
     netcat(self.hostname, self.port, "(State chat-affect chat-negative)")
예제 #49
0
 def room_brightness(self, bright):
     room = '(StateLink (AnchorNode "luminance")' +\
      ' (NumberNode ' + str(bright) +'))\n'
     netcat(self.hostname, self.port, room)
예제 #50
0
 def vocalization_started(self):
     netcat(self.hostname, self.port, "(State chat-state chat-start)")
예제 #51
0
 def add_face_to_atomspace(self, faceid):
     face = "(EvaluationLink (PredicateNode \"visible face\") " + \
            "(ListLink (NumberNode \"" + str(faceid) + "\")))\n"
     netcat(self.hostname, self.port, face)
     print "New visible face in atomspace: ", faceid
예제 #52
0
 def vocalization_ended(self):
     netcat(self.hostname, self.port, "(State chat-state chat-stop)")
예제 #53
0
 def update_face_octomap(self, faceid, xx, yy, zz):
     face = "(map-ato \"faces\" (NumberNode \"" + str(faceid) + \
             "\" (av 5 0 0)) " + str(xx) + " " + str(yy) + \
             " " + str(zz) + ")\n"
     netcat(self.hostname, self.port, face)
예제 #54
0
 def evaluate_scm(self, scm_string):
     netcat(self.hostname, self.port, scm_string)
예제 #55
0
	def add_tracked_face_to_atomspace(self, faceid):
		face = self.set_tracked_face(faceid)
		netcat(self.hostname, self.port, face + "\n")
		print "Force focus of attention on face: ", faceid
예제 #56
0
 def wholeshow_stop(self):
     netcat(self.hostname, self.port, "(disable-all-demos)")
     netcat(self.hostname, self.port, "(halt)")
예제 #57
0
 def add_face_to_atomspace(self, faceid):
     face = self.define_face(faceid)
     netcat(self.hostname, self.port, face + "\n")
     print "New visible face in atomspace: ", faceid
예제 #58
0
	def wholeshow_start(self):
		netcat(self.hostname, self.port, "(enable-all-demos)")
		netcat(self.hostname, self.port, '(run)')
예제 #59
0
    def remove_face_from_atomspace(self, faceid):

        # AtomSpace cog-delete takes handle as an argument.
        msg = self.delete_face(faceid)
        netcat(self.hostname, self.port, msg)
        print "Removed face from atomspace: ", faceid
예제 #60
0
 def perceived_text(self, text):
     netcat(
         self.hostname, self.port,
         '(cog-evaluate! (PutLink (DefinedPredicate "heard text")' +
         ' (SentenceNode "' + text + '")))')