Skip to content

Commit

Permalink
Verion 0.0.5 released, add IMU print example
Browse files Browse the repository at this point in the history
  • Loading branch information
PerlinWarp committed Nov 13, 2021
1 parent 6a00d5f commit 23f5d4c
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
2 changes: 1 addition & 1 deletion examples/dino_jump.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def dino_handler(pose):
# XGBoost Classifier Example
model = XGBClassifier(eval_metric='logloss')
clr = Live_Classifier(model, name="XG", color=(50,50,255))
m = MyoClassifier(clr, mode=emg_mode.PREPROCESSED)
m = MyoClassifier(clr, mode=emg_mode.PREPROCESSED, hist_len=10)

hnd = EMGHandler(m)
m.add_emg_handler(hnd)
Expand Down
50 changes: 50 additions & 0 deletions examples/myo_imu_examp.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import multiprocessing
from pyomyo import Myo, emg_mode
import os

def cls():
# Clear the screen in a cross platform way
# https://stackoverflow.com/questions/517970/how-to-clear-the-interpreter-console
os.system('cls' if os.name=='nt' else 'clear')

# ------------ Myo Setup ---------------
q = multiprocessing.Queue()

def worker(q):
m = Myo(mode=emg_mode.FILTERED)
m.connect()

def add_to_queue(quat, acc, gyro):
imu_data = [quat, acc, gyro]
q.put(imu_data)

m.add_imu_handler(add_to_queue)

# Orange logo and bar LEDs
m.set_leds([128, 128, 0], [128, 128, 0])
# Vibrate to know we connected okay
m.vibrate(1)

"""worker function"""
while True:
m.run()
print("Worker Stopped")

# -------- Main Program Loop -----------
if __name__ == "__main__":
p = multiprocessing.Process(target=worker, args=(q,))
p.start()

try:
while True:
while not(q.empty()):
imu = list(q.get())
quat, acc, gyro = imu
print("Quaternions:", quat)
print("Acceleration:", acc)
print("Gyroscope:", gyro)
cls()

except KeyboardInterrupt:
print("Quitting")
quit()
4 changes: 3 additions & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[metadata]
name = pyomyo
version = 0.0.4
version = 0.0.5
author = PerlinWarp
author_email = [email protected]
description = Python Opensource Myo library
Expand All @@ -24,5 +24,7 @@ install_requires =
numpy
matplotlib
pygame
scikit-learn
xgboost
[options.packages.find]
where = src

0 comments on commit 23f5d4c

Please sign in to comment.