def __init__(self,classifier : GestClassifier , window_length: int, overlap :int, sample_freq: int, username :str, debug = False):
        # debug status
        self.debug = debug

        # sampling paramaters
        self.window_length = window_length #number of Samples
        self.length_sample = 14
        self.classifier    = classifier
        self.data    = np.array([0.0]*self.length_sample*window_length)
        self.reading = np.array([0.0]*self.length_sample*(window_length-overlap))
        self.overlap = overlap
        self.samples_taken = 0
        self.sample_freq = sample_freq
        self.sample_period = 1/sample_freq

        # Setup Server Link
        self.board = "ece180d/MEAT/general/gesture"
        self.user = "******" + username
        self.mqtt_server = mqtt.MQTTLink( self.board, self.user)
        self.designated_reciever = username
        self.last_classification = ""
        self.last_classification_time = datetime.datetime.now()

        #initialize sensor
        IMU.detectIMU()
        if(IMU.BerryIMUversion == 99):
            print(" No BerryIMU found...sick nasty")
            sys.exit()
        IMU.initIMU() # initialize all the relevant sensors

        # Sensor Reading Values
        self.gyroXangle = 0.0
        self.gyroYangle = 0.0
        self.gyroZangle = 0.0
        self.CFangleX = 0.0
        self.CFangleY = 0.0
        self.CFangleXFiltered = 0.0
        self.CFangleYFiltered = 0.0
        self.kalmanX = 0.0
        self.kalmanY = 0.0
        self.oldXAccRawValue = 0
        self.oldYAccRawValue = 0
        self.oldZAccRawValue = 0

         #Setup the tables for the median filter. Fill them all with '1' so we dont get devide by zero error
        self.acc_medianTable1X = [1] * ACC_MEDIANTABLESIZE
        self.acc_medianTable1Y = [1] * ACC_MEDIANTABLESIZE
        self.acc_medianTable1Z = [1] * ACC_MEDIANTABLESIZE
        self.acc_medianTable2X = [1] * ACC_MEDIANTABLESIZE
        self.acc_medianTable2Y = [1] * ACC_MEDIANTABLESIZE
        self.acc_medianTable2Z = [1] * ACC_MEDIANTABLESIZE

        #timers
        self.a = datetime.datetime.now()
        self.b = datetime.datetime.now()
        self.c = datetime.datetime.now()
Beispiel #2
0
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setFocusPolicy(Qt.StrongFocus)
        self.manager = chat.BoardManager('Nico')
        self.display = DisplayWidget()
        self.link = mqtt.MQTTLink(topic='ece180d/MEAT', user_id='Jake')

        # threading
        self.threadpool = QThreadPool()

        for topic in TOPICS:
            self.manager.createBoard(topic)

        self.__create_worker__(self.manager.link.listen)

        self.manager.switch.connect(
            lambda topic: self.switchDisplayTopic(topic))

        self.switchDisplayTopic('general')

        self.layout = QGridLayout()
        self.setMainLayout()
Beispiel #3
0
import sys

PATH = ["src/comms/mqtt"]

for lib in PATH:
    sys.path.append(lib)

import mqtt_net as mqtt

# defining for test script
if __name__ == '__main__':

    # Note: make sure you are reading values from a subscriber on the same board to see the result
    # Start a client
    mqtt_tx = mqtt.MQTTLink("ece180d/MEAT/general", user_id='Jack')

    message = {
        'sender': 'Jack',
        'color': (255, 0, 0),
        'data': 'This is a test message.',
        'time': {
            'hour': 11,
            'minute': 52,
            'second': 0
        },
        'emoji': [1, 5]
    }

    mqtt_tx.send(message)
Beispiel #4
0
#
#  File: controller_receiver.py
# 
#  Author: Thomas Kost
#  
#  Date: 04 February 2021
#  
#  @brief  receives controller data for a generic user
#

import sys
import os
import time

sys.path.append('../../src/comms/mqtt/')
sys.path.append('src/comms/mqtt/')
import mqtt_net as mqtt

mqtt_link = mqtt.MQTTLink("ece180d/MEAT/general/gesture", "my_name",[0,0,0], True)
mqtt_link.listen()

while(True):
    mqtt_link.send()
    time.sleep(1)

time.sleep(1)

input("Press Enter to continue...")
#ece180d/MEAT/general/gesture
Beispiel #5
0
 def __link__(self):
     self.link = mqtt.MQTTLink(topic='ece180d/MEAT',
                               user_id=self.user,
                               color=self.color)
Beispiel #6
0
        if 1:                       #Change to '0' to stop  showing the angles from the gyro
            outputString +="\t# GRYX Angle %5.2f  GYRY Angle %5.2f  GYRZ Angle %5.2f # " % (gyroXangle,gyroYangle,gyroZangle)

        if 1:                       #Change to '0' to stop  showing the angles from the complementary filter
            outputString +="\t#  CFangleX Angle %5.2f   CFangleY Angle %5.2f  #" % (CFangleX,CFangleY)

        if 1:                       #Change to '0' to stop  showing the heading
            outputString +="\t# HEADING %5.2f  tiltCompensatedHeading %5.2f #" % (heading,tiltCompensatedHeading)

        if 1:                       #Change to '0' to stop  showing the angles from the Kalman filter
            outputString +="# kalmanX %5.2f   kalmanY %5.2f #" % (kalmanX,kalmanY)

        #print(outputString)

        #slow program down a bit, makes the output more readable
        time.sleep(0.03)

        if AccYangle > 60:
            handleIMU(mqtt_test, "up", reciever)
        elif AccYangle < -60:
            handleIMU(mqtt_test, "down", reciever)
        else:
            handleIMU(mqtt_test, "", reciever) # just send acks

if __name__ == "__main__": 
    reciever = "tommy"
    user = "******" + reciever
    mqtt_test = mqtt.MQTTLink("ece180d/MEAT/general/gesture", user)
    runIMU(mqtt_test,reciever)
Beispiel #7
0
 def __init__(self, user, parent=None):
     super().__init__(parent)
     self.link = mqtt.MQTTLink('ece180d/MEAT/general/gesture', user_id=user)
     self.user = user
     self.link.message.connect(lambda packet: self.gesture(packet))
Beispiel #8
0
#  @brief testing file creating mqtt user with tag "b"
#

import sys
import os
import time
import datetime
import threading

sys.path.append('../../src/comms/mqtt/')
sys.path.append('src/comms/mqtt')

import mqtt_net as mqtt

# Instantiate link
mqtt_link_b = mqtt.MQTTLink("ece180d/MEAT/general", "b", [0, 0, 0], True)

# Create Messages
now = datetime.datetime.now()
msg_for_a = {
    "message_type": "text",
    "sender": "b",
    "receiver": "a",
    "data": "for a",
    "time": {
        "hour": now.hour,
        "minute": now.minute,
        "second": now.second
    },
    "color": [0, 0, 0],
    "emoji": None