예제 #1
0
def main():
    #broker = redis.StrictRedis()
    #broker = RedisClient().conn
    #sub = broker.pubsub()
    global sc

    try:
        '''
        UP/DOWN servo => pin 13
        LEFT/RIGHT servo => pin 19
        '''
        sub = BROKER()

        sc = SERVO()
        sub.subscribe(callback, SC_CH)
        # while True:
        # topic, message = sub.get()
        # if message != None:
        # log.debug(message)
        # data = json.loads(message)
        # log.debug("SC: received data:")
        # log.debug(data)
        # action = data['action']
        # angle = int(data['angle'])
        # if not (sc is None):
        # execute_action(sc, action, angle)
        # else:
        # log.error("servos were not initialized not performing action!")
        # sleep(0.2)

    except Exception as ex:
        log.error("exception in ServosController")
        log.error(ex, exc_info=True)
        sc.clean_up()
예제 #2
0
def main():
    try:
        #broker = redis.StrictRedis()
        #broker = RedisClient().conn
        #sub = broker.pubsub()
        #tts = TTS()
        sub = BROKER()
        sub.subscribe(callback, TTSC_CH)

        # while True:
        # topic, message = sub.get_b()
        # if message != None:
        # log.debug(message)
        # data = json.loads(message)
        # log.debug("TTSC: received data:")
        # log.debug(data)
        # action = data['action']
        # sentence = data['sentence']
        # #broker.publish(HC_CH, '{"action": "play",  "anime": "talk"}')
        # tts.speak(sentence, broker)
        # #broker.publish(HC_CH, '{"action": "play",  "anime": "standby"}')
        # sleep(0.4)

    except Exception as ex:
        log.error("error in TTSController")
        log.error(ex, exc_info=True)
예제 #3
0
def main():
    #broker = redis.StrictRedis()
    #broker = RedisClient().conn
    #sub = broker.pubsub()
    global dcm
    sub = BROKER()

    try:
        dcm = init_dc_motors()
        sub.subscribe(callback, DCM_CH)
        # while True:
        # #message = sub.get_message()
        # topic, message = sub.get()
        # if message != None:
        # log.debug((message))
        # data = json.loads(message)
        # log.debug("DCMC: received data:")
        # log.debug(data)
        # action = data['action']
        # speed = int(data['speed'])
        # time_limit = 0
        # if 'time_limit' in data:
        # time_limit = float(data['time_limit'])
        # if not (dcm is None):
        # execute_action(dcm, action, speed, time_limit)
        # else:
        # log.error("dcm was not initialized not performing action!")
        # sleep(0.2)

    except Exception as ex:
        log.error("exception in DCMController")
        log.error(ex, exc_info=True)
        dcm.clean_up()
예제 #4
0
def main():
    try:
        ava = AVA()
        #ava.set_motion(ava.CONFIG.AVA_STANDBY_ANIME)
        execute_action(ava, 'play', 'standby')

        print(ava.CONFIG.AVA_STANDBY_ANIME + "----------")
        #sleep(10)
        #ava.set_motion(ava.CONFIG.AVA_TALK_ANIME)
        #broker = redis.StrictRedis()
        #broker = RedisClient().conn
        #sub = broker.pubsub()
        sub = BROKER()
        sub.subscribe(callback, HC_CH)
        # while True:

        # ava.process_events()
        # topic, message = sub.get()
        # if message != None:
        # log.debug(message)
        # data = json.loads(message)

        # log.debug("HC: received data:")
        # log.debug(data)
        # action = data['action']
        # anime = data['anime']
        # execute_action(ava, action, anime)

        # sleep(0.4)

    except Exception as ex:
        log.error("error in HeadController")
        log.error(ex, exc_info=True)
예제 #5
0
파일: MainAUC.py 프로젝트: ayoubboulila/ava
def main():
    try:
        global left_dist 
        global right_dist 
        global broker
        
        broker = BROKER()
        
        broker.subscribe(callback, MAUC_CH)
        # while True:
            # topic, message = broker.get()
            # if message != None:
                # log.debug(message)
                # data = json.loads(message)
                # log.debug("MainAUC: received data:")
                # log.debug(data)
                # execute_action(data, broker)
            # sleep(0.2)
                
                
    except Exception as ex:
        log.error("exception in MainAUC")
        log.error(ex, exc_info=True)
예제 #6
0
def main():
    try:
        global us
        global broker
        us = DSensor()
        #broker = redis.StrictRedis()
        #broker = RedisClient().conn
        #sub = broker.pubsub()
        broker = BROKER()
        #sub = BROKER()
        thread = threading.Thread(target=background_job, args=(us, broker))
        thread.daemon = True
        thread.start()
        broker.subscribe(callback, US_CH)
        # while True:
        # background_job(us, broker)
        # time.sleep(2)
        # while True:
        # topic, message = sub.get()
        # if message != None:
        # log.debug(message)
        # data = json.loads(message)
        # log.debug("US: received data:")
        # log.debug(data)
        # action = data['action']
        # if not (us is None):
        # execute_action(us, action, broker)
        # else:
        # log.error("servos were not initialized not performing action!")
        # else:
        # background_job(us, broker)
        # time.sleep(1)

    except Exception as ex:
        log.error("exception in USController")
        log.error(ex, exc_info=True)
        us.clean_up()
예제 #7
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import numpy as np
import cv2
import sys 
sys.path.append('/home/pi/ava')
from utils.RabbitCtl import BROKER

def callback(ch, method, properties, body):
    
    # create int values from sting
    np_arr = np.frombuffer(body, np.uint8)

    # convert data from .jpg encoded image to cv2 format
    image = cv2.imdecode(np_arr, 1)
    cv2.imshow('image', image)

    #print("frame header stamp: {}".format(body.header.stamp))
    # show images and delay for 10ms
    cv2.waitKey(10)
    

if __name__ == '__main__':
    br = BROKER()
    br.subscribe(callback, "stream")