-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Verion 0.0.5 released, add IMU print example
- Loading branch information
1 parent
6a00d5f
commit 23f5d4c
Showing
3 changed files
with
54 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
@@ -24,5 +24,7 @@ install_requires = | |
numpy | ||
matplotlib | ||
pygame | ||
scikit-learn | ||
xgboost | ||
[options.packages.find] | ||
where = src |