示例#1
0
from vispy import app, scene
from glove.gloveHandle import GloveHandle, SourceConfig, Sources
from util.filers import MagvikFilter, LPFilterIterator
from util.extmath import angleFromQuat
import imageio
from plotting.glovecanvas import GloveCanvas

np.set_printoptions(suppress=True)

output_filename = '../glovecanvas.gif'
gloveCanvas = GloveCanvas()

#glove = GloveHandle(SourceConfig(Sources.USB_TTL, portName="COM7", baudrate=115200), nonBlocking=False)
#glove = GloveHandle(SourceConfig(Sources.BLUETOOTH, port=1, host="00:21:13:04:d9:63"), nonBlocking=False)
glove = GloveHandle(SourceConfig(
    Sources.SIMULATION,
    data=bytearray(open("../dataprocessing/data/glovetest.rec", "rb").read())),
                    nonBlocking=False)

mag = MagvikFilter()
angles = (0, 0, 0)
flex = (0, 0, 0, 0, 0)


#@glove.imuFrameDecorator
def imuFrame(data):
    global gloveCanvas, mag, angles

    ax = data[0] / 32768 * 4 - 0.05
    ay = data[1] / 32768 * 4 - 0.00
    az = data[2] / 32768 * 4 - 0.045
    wx = (np.pi / 180) * ((data[3] + 90) / 32768 * 500)
示例#2
0
import sys
import time
from util.extmath import *
import numpy as np
from vispy import app, scene
from glove.gloveHandle import GloveHandle, SourceConfig, Sources
from plotting.imuplotter import ImuPlotter
from util.filers import MagvikFilter, LPFilterIterator

#glove = GloveHandle(SourceConfig(Sources.USB_TTL, portName="COM10", baudrate=115200), nonBlocking=True)
glove = GloveHandle(SourceConfig(
    Sources.SIMULATION,
    data=bytearray(
        open("dataprocessing/data/gestures/log/log(4).rec", "rb").read()),
    frametime=0.01),
                    nonBlocking=False)
plotter = ImuPlotter(sampleInterval=0.002, timeWindow=5.)
axgo = 0
aygo = 0
azgo = 0
t = 0
mag = MagvikFilter(beta=1)
count = 0
q = [1, 0, 0, 0]
vx = 0
vy = 0
vz = 0
sx = 0
sy = 0
sz = 0
示例#3
0
#glove = GloveHandle(SourceConfig(Sources.USB_TTL, portName="COM10", baudrate=115200), nonBlocking=True)

path = "data/gestures/"
fileind = "triangle/triangle(17)"
#fileind = "log/log(18)"
#fileind = "rect/rect(20)"
#fileind = "triangle/triangle(20)"
#fileind = "v/v(20)"
rec = ".rec"
procpath = "data/gestures/"
procrec = ".proc"

glove = GloveHandle(SourceConfig(Sources.SIMULATION,
                                 data=bytearray(
                                     open(path + fileind + rec, "rb").read()),
                                 frametime=0.001),
                    nonBlocking=False)
plotter = ImuPlotter(sampleInterval=0.0002, timeWindow=5.)
axgo = 0
aygo = 0
azgo = 0
t = 0
mag = MagvikFilter(beta=1)
count = 0
q = [1, 0, 0, 0]
vx = 0
vy = 0
vz = 0
sx = 0
sy = 0
示例#4
0
import time
from pynput import keyboard
from glove.gloveHandle import GloveHandle, SourceConfig, Sources

filename = "data/glovetest.rec"
file = open(filename, 'rb')

glove = GloveHandle(SourceConfig(Sources.SIMULATION,
                                 data=bytearray(file.read())),
                    nonBlocking=False)


@glove.imuFrameDecorator
def imuFrame(data):
    print("IMU data: ", data)
    time.sleep(0.5)


@glove.deformationFrameDecorator
def deformationFrame(data):
    print("deformation data: ", data)


glove.connect(
    "FRAME", glove.newFrameDecorator(lambda head, data: print("FRAME:", data)))
glove.connect("IMU_FRAME", imuFrame)
glove.connect("DEFORMATION_FRAME", deformationFrame)
glove.open()
glove.start()
time.sleep(10)
glove.exit()
示例#5
0
import time
from pynput import keyboard
from glove.gloveHandle import GloveHandle, SourceConfig, Sources

filename = "data/gestures/v/v(20).rec"
#filename = "data/gestures/log/log(18).rec"
file = open(filename, 'wb')
_exit = False
glove = GloveHandle(SourceConfig(Sources.BLUETOOTH,
                                 port=1,
                                 host="00:21:13:04:d9:63"),
                    nonBlocking=False)


def on_press(key):
    try:
        pass
    except AttributeError:
        pass


def on_release(key):
    global _exit
    if key == keyboard.Key.esc:
        _exit = True
        return False


glove.open()

listener = keyboard.Listener(on_press=on_press, on_release=on_release)
示例#6
0
import sys
import time
from util.extmath import *
import numpy as np
from vispy import app, scene
from glove.gloveHandle import GloveHandle, SourceConfig, Sources
from plotting.imuplotter import ImuPlotter
from util.filers import MagvikFilter, LPFilterIterator

glove = GloveHandle(SourceConfig(Sources.USB_TTL,
                                 portName="COM10",
                                 baudrate=115200),
                    nonBlocking=True)
plotter = ImuPlotter(sampleInterval=0.002, timeWindow=5.)
axgo = 0
aygo = 0
azgo = 0
kp = 0.2
t = 0
mag = MagvikFilter()


@glove.imuFrameDecorator
def imuFrame(data):
    global plotter, t, mag
    global axgo, aygo, azgo
    ax = data[0] / 32768 * 4 + 0.015
    ay = data[1] / 32768 * 4 - 0.00
    az = data[2] / 32768 * 4 - 0.045
    wx = (np.pi / 180) * ((data[3] + 90) / 32768 * 500)
    wy = (np.pi / 180) * ((data[4] + 0) / 32768 * 500)