Exemple #1
0
#from utils.RedisClient import RedisClient
#from utils.Broker import BROKER
from utils.RabbitCtl import BROKER
from datetime import datetime
import json
import time
from time import sleep
from utils import Logger


SC_CH = 'SC'
DCM_CH = 'DCMC'
US_CH = 'US'
MAUC_CH = 'MAUC'

log = Logger.RCLog('MainAUC')



def execute_action(data, broker):
    if data['action'] == "slowdown":
        command = '{"action": "go",  "speed": "50", "time_limit": "0"}'
        broker.publish(DCM_CH, command)
    elif data['action'] == "stopandturn":
        # first of all stop
        com1 = '{"action": "stop",  "speed": "0", "time_limit": "0"}'
        broker.publish(DCM_CH, com1)
        # go back a little to stop US warnings
        com2 = json = '{"action": "back",  "speed": "100", "time_limit": "0.5"}'
        broker.publish(DCM_CH, com2)
        
Exemple #2
0
'''

#import redis
#from utils.RedisClient import RedisClient
#from utils.Broker import BROKER
from utils.RabbitCtl import BROKER
from datetime import datetime
import json
import ast
import time
from time import sleep
from utils import Logger
from lib.mvt.Servo import SERVO

SC_CH = 'SC'
log = Logger.RCLog('ServosController')

# json = '{"action": "moveX",  "angle": "-1"}'
# json = '{"action": "moveY",  "angle": "-1"}'
# json = '{"action": "up",  "angle": "-1"}'
# json = '{"action": "down",  "angle": "-1"}'
# json = '{"action": "left",  "angle": "-1"}'
# json = '{"action": "right",  "angle": "-1"}'
# json = '{"action": "exit",  "angle": "-1"}'


def execute_action(servo, action, angle):
    try:

        # servo.move_UD
        # servo.move_LR
Exemple #3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys, time, os
sys.path.append('/home/pi/ava')
from utils.RabbitCtl import BROKER
from utils import Logger
import types
from datetime import datetime

log = Logger.RCLog('CamStreamer')
try:
    from picamera.array import PiRGBArray
    from picamera import PiCamera
    from threading import Thread
    import numpy as np
    import cv2
except ImportError:
    log.error("Camera not installed or detected")


class PiVideoStream:
    camera = None
    stream = None
    rawCapture = None
    USE_RABBIT = False
    broker = None
    frame_size = (320, 320)

    def __init__(self,
                 frame_size=(320, 320),
Exemple #4
0
#from utils.RedisClient import RedisClient
#from utils.Broker import BROKER
from utils.RabbitCtl import BROKER
from utils import Logger
from lib.light.Rgb import RGB
import subprocess
import json
from time import sleep
import hashlib
import pyaudio
import wave
from ctypes import *

# json =  '{"action": "speak",  "sentence": ""}'

log = Logger.RCLog('TTSController')
TTSC_CH = 'TTSC'
HC_CH = 'HC'
# code to suppress pyaudio warnings
ERROR_HANDLER_FUNC = CFUNCTYPE(None, c_char_p, c_int, c_char_p, c_int,
                               c_char_p)


def py_error_handler(filename, line, function, err, fmt):
    pass


c_error_handler = ERROR_HANDLER_FUNC(py_error_handler)

asound = cdll.LoadLibrary('libasound.so')
# Set error handler
Exemple #5
0
#import redis
#from utils.RedisClient import RedisClient
from utils import Logger
import logging
from logging.handlers import RotatingFileHandler
import json as js
# utils.Broker import BROKER
from utils.RabbitCtl import BROKER
from lib.ai.detector.ObjectDetector import Detector
#from lib.ai.detector.detect_picamera import main as pc
#from DetectionStreamController import DestectionStream
#from flask_mqtt import Mqtt
#import paho.mqtt.publish as publish 

app = Flask(__name__)
log = Logger.RCLog('AMSpiServer')


my_loader = jinja2.ChoiceLoader([
    app.jinja_loader,
    jinja2.FileSystemLoader('templates'),
])
app.jinja_loader = my_loader


@app.route('/')
@app.route('/index')
def index():
    
    test="ok"
    return render_template(
Exemple #6
0
import sys
sys.path.append('/home/pi/ava')
from lib.mvt.Servo import SERVO
from utils.RabbitCtl import BROKER
from utils import Logger
import cv2
from time import sleep
log = Logger.RCLog('CamTracker')


class Tracker:
    FRAME_W = 320
    FRAME_H = 320
    USE_RABBIT = False
    srv = None
    broker = None
    SC_CH = 'SC'
    CURRENT_PAN = 0
    CURRENT_TILT = 25
    NEUTRAL_PAN = 0
    NEUTRAL_TILT = 25
    PAN_TILT_THRESHOLD = 10
    PAN_TILT_ERROR = 10

    def __init__(self, frame_w=320, frame_h=320, use_rabbit=False):
        self.FRAME_W = frame_w
        self.FRAME_H = frame_h
        self.USE_RABBIT = use_rabbit
        if not self.USE_RABBIT:
            self.srv = SERVO()
        else:
Exemple #7
0
from lib.agent import snowboydecoder
from lib.light.Rgb import RGB
import sys, os
import signal
#import redis
#from utils.RedisClient import RedisClient
#from utils.Broker import BROKER
from utils.RabbitCtl import BROKER
from utils import Logger
from time import sleep

TTSC_CH = 'TTSC'
DCM_CH = 'DCMC'
interrupted = False
log = Logger.RCLog('AgentController')
RES_PATH = os.path.join(os.path.dirname(__file__), 'lib', 'agent', 'resources')

AVA_MODEL = os.path.join(RES_PATH, 'ava.pmdl')
AVA_STOP_MODEL = os.path.join(RES_PATH, 'ava_stop.pmdl')
AVA_GO_MODEL = os.path.join(RES_PATH, 'ava_go.pmdl')
AVA_BACK_MODEL = os.path.join(RES_PATH, 'ava_back.pmdl')
AVA_TURN_LEFT_MODEL = os.path.join(RES_PATH, 'ava_turn_left.pmdl')
AVA_TURN_RIGHT_MODEL = os.path.join(RES_PATH, 'ava_turn_right.pmdl')
AVA_WHO_ARE_YOU_MODEL = os.path.join(RES_PATH, 'ava_who_are_you.pmdl')
AVA_DANCE_MODEL = os.path.join(RES_PATH, 'ava_dance.pmdl')
AVA_FOLLOW_ME_MODEL = os.path.join(RES_PATH, 'ava_follow_me.pmdl')

models = [
    AVA_MODEL, AVA_STOP_MODEL, AVA_GO_MODEL, AVA_BACK_MODEL,
    AVA_TURN_LEFT_MODEL, AVA_TURN_RIGHT_MODEL, AVA_WHO_ARE_YOU_MODEL,
Exemple #8
0
#import redis
#from utils.RedisClient import RedisClient
#from utils.Broker import BROKER
from utils.RabbitCtl import BROKER
from datetime import datetime
import json
import time
from utils import Logger
from lib.sensor.DSensor import DSensor
import threading

# both pub and sub
US_CH = 'US'
MAUC_CH = 'MAUC'

log = Logger.RCLog('USController')

# sub json = '{"action": "mesure", "distance": "0"}'
# sub json = '{"action": "exit", "distance": "0"}'

# pub json = '{"action": "mesure", "distance": "15"}'
# pub json = '{"action": "stopandturn", "distance": "15"}'
# pub json = '{"action": "slowdown", "distance": "25"}'


def execute_action(us, action, broker, metadata=None):
    if action == "mesure":
        d = us.get_distance()
        if metadata is not None:
            data = '{"action": "mesure", "distance": "' + str(
                d) + '", "metadata": "' + str(metadata) + '"}'
Exemple #9
0
#import redis
#from utils.RedisClient import RedisClient
#from utils.Broker import BROKER
from utils.RabbitCtl import BROKER
from lib.light.Rgb import RGB
from datetime import datetime
import json
#from pprint import pprint
import ast
from lib.mvt.Dcm import DCM
import time
from time import sleep
from utils import Logger

DCM_CH = 'DCMC'
log = Logger.RCLog('DCMController')
# json = '{"action": "go",  "speed": "100", "time_limit": "0"}'
# json = '{"action": "back",  "speed": "100", "time_limit": "0"}'
# json = '{"action": "left",  "speed": "100", "time_limit": "0"}'
# json = '{"action": "right",  "speed": "100", "time_limit": "0"}'
# json = '{"action": "stop",  "speed": "0", "time_limit": "0"}'
# json = '{"action": "exit",  "speed": "0", "time_limit": "0"}'


def execute_action(dcm, action, speed=100, time_limit=0):
    try:

        if action == 'go':
            dcm.go(speed)
            log.debug('go')
        elif action == 'back':
Exemple #10
0
#from utils.RedisClient import RedisClient
#from utils.Broker import BROKER
from utils.RabbitCtl import BROKER
from utils import Logger
import json
from time import sleep
from PyQt4 import QtGui
from lib.ai.Head import AVA
#from lib.ai import config

# json =  '{"action": "play",  "anime": "standby"}'
# json =  '{"action": "play",  "anime": "talk"}'
# json =  '{"action": "play",  "anime": "happy"}'
# json =  '{"action": "play",  "anime": "sad"}'

log = Logger.RCLog('HeadController')
HC_CH = 'HC'
TTSC_CH = 'TTSC'


def execute_action(head, action, anime):
    log.info("exec head action")
    if action == 'play':
        if anime == 'standby':
            print('standby')
            head.set_motion(head.CONFIG.AVA_STANDBY_ANIME)
        elif anime == 'talk':
            print('talk')
            head.set_motion(head.CONFIG.AVA_TALK_ANIME)
        elif anime == 'happy':
            print('happy')