Exemplo n.º 1
0
import multiprocessing
import time
import os

from hal.simulator.motor import Motor
from hal.simulator import visual
from hal.simulator.switch import Switch
import hal.simulator.camera as camera
from file.configuration import Configuration

CWD_PATH = os.path.dirname(os.path.realpath(__file__))
conf = Configuration(inifile=os.path.join(CWD_PATH, "hardware.ini"))

# required
# export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES

import random


class Hardware():
    try:
        switch1_angle = conf.get_int(section="axis_x", key="start_angle")
        switch2_angle = conf.get_int(section="axis_x", key="end_angle")
        switch3_angle = conf.get_int(section="axis_y", key="start_angle")
        switch4_angle = conf.get_int(section="axis_y", key="end_angle")

        # Open up our window
        queue = multiprocessing.Queue(100)
        visual.queue = queue

        p = multiprocessing.Process(target=visual.display, args=(queue, ))
Exemplo n.º 2
0
import math
from hal import Hardware

from file.configuration import Configuration

conf = Configuration(inifile="config/service.ini")


def gimbal_adjust(context):
    box = context.prediction.bounding_box
    img_w = context.prediction.img_w
    img_h = context.prediction.img_h

    x, y = (int(box.x + (box.w / 2)), int(box.y + (box.h / 2)))
    norm_x, norm_y = (x / img_w - 0.5, y / img_h - 0.5)

    radian = -math.sin(norm_x)
    degree = math.degrees(radian) * 1.8
    Hardware.Axis_horizontal.set_angle(degree)
    #return

    radian = -math.sin(norm_y)
    degree = math.degrees(radian) * 1.4
    Hardware.Axis_vertical.set_angle(degree)
Exemplo n.º 3
0
import telegram
from file.configuration import Configuration

conf = Configuration(inifile="config/service.ini", reload_on_change=True)

bot = telegram.Bot(token=conf.get(section="telegram", key='api_token'))
chat_id = conf.get_int(section="telegram", key="channel_id")

bot.send_video(chat_id=chat_id,
               video=open('test.mp4', 'rb'),
               supports_streaming=True,
               timeout=10000)
Exemplo n.º 4
0
from file.configuration import Configuration
import sys
from pydoc import locate

conf = Configuration(inifile="config/service.ini")

from hal.axis import Axis

# Read the kind of input source from"service.ini" file and create an instance of them.
#
HARDWARE = conf.get('impl', 'hal')
if HARDWARE is None:
    print("No data source configured")
    sys.exit(1)
# create a python object by class name
Hardware = locate(HARDWARE)
if Hardware is None:
    print("Class [{}] not found.".format(HARDWARE))
    sys.exit(1)
print("Using hardware layer :" + HARDWARE)
Hardware.Axis_horizontal = Axis(Hardware.Motor1)
Hardware.Axis_vertical = Axis(Hardware.Motor2, Hardware.Motor3)
Exemplo n.º 5
0
import slack
import time

from datetime import datetime, date

from file.configuration import Configuration

conf = Configuration(inifile="config/service.ini", reload_on_change=True)

if __name__ == "__main__":
    client = slack.WebClient(token=conf.get("api_token", section="slack"))

    now = date.today()
    channel_id = None
    res = client.channels_list(count=1000)
    for channel in res['channels']:
        if channel['name'] == conf.get("channel", section="slack"):
            channel_id = channel['id']
            break

    res = client.channels_history(channel=channel_id, count=1000)
    for message in res['messages']:
        ts = message["ts"]
        timestamp = int(float(ts))
        dt_object = date.fromtimestamp(timestamp)
        diff = now - dt_object
        if diff.days > 10:
            del_res = client.chat_delete(channel=channel_id, ts=ts)
            print(del_res)

    res = client.files_list(channels="#" +
Exemplo n.º 6
0
from file.configuration import Configuration

conf = Configuration(inifile="config/service.ini", reload_on_change=True)


def write_history(context):
    last_frames = context.last_frames
    image = context.current_frame

    last_frames.put(image)
    if last_frames.qsize() > conf.get_int("frames", section="history"):
        last_frames.get()