本文整理汇总了Python中myo.init函数的典型用法代码示例。如果您正苦于以下问题:Python init函数的具体用法?Python init怎么用?Python init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了init函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
def main():
global wingl
global wingr
viz.cam.setHandler(vizcam.KeyboardCamera())
myo.init()
gyrolist = [[0,0,0]]
viz.fov(150)
#wingl.setScale([10,0.3,1])
#wingl.setCenter([100,100,100])
wingl.setEuler([0,90,0])
wingl.collideSphere(0.5)
lStartPOS = [ 0, 2.5, 2 ]
wingl.setPosition( lStartPOS )
#wingr.setScale([10,0.3,1])
#wingr.setCenter([100,100,100])
wingr.setEuler([0,90,0])
wingr.collideSphere(0.5)
rStartPOS = [ 0, 2.5, 2 ]
wingr.setPosition( rStartPOS )
hub = myo.Hub()
hub.set_locking_policy(myo.locking_policy.none)
hub.run(1000, Listener())
vizact.ontimer(0.01 ,updateMyo, [gy, gy2, gy3, wingl, orx, ory, orz, orw, or1x, or1y, or1z, or1w, wingr])
vizact.ontimer(0, updateEuler)
FileReader()
initializeObjectFiles()
initializeLocations()
getCurrentTestingLocationOrder()
vizact.ontimer(0.1, update)
示例2: main
def main():
global wingl
global wingr
viz.cam.setHandler(vizcam.KeyboardCamera())
myo.init()
gyrolist = [[0,0,0]]
viz.setMultiSample(4)
viz.fov(150)
wingl = viz.addChild('basketball.osgb')
wingl.setScale([10,0.3,1])
wingl.setCenter([100,100,100])
wingl.setEuler([0,90,0])
wingl.collideSphere(0.5)
lStartPOS = [ 0, 2.5, 2 ]
wingl.setPosition( lStartPOS )
wingr = viz.addChild('basketball.osgb')
wingr.setScale([10,0.3,1])
wingr.setCenter([100,100,100])
wingr.setEuler([0,90,0])
wingr.collideSphere(0.5)
rStartPOS = [ 0, 2.5, 2 ]
wingr.setPosition( rStartPOS )
#viz.MainView.setPosition([0,2,-15])
hub = myo.Hub()
hub.set_locking_policy(myo.locking_policy.none)
hub.run(1000, Listener())
vizact.ontimer(0.01 ,updateMyo, [gy, gy2, gy3, wingl, orx, ory, orz, orw, or1x, or1y, or1z, or1w, wingr])
示例3: main
def main():
myo.init()
hub = myo.Hub()
listener = EmgRate(n=50)
while hub.run(listener.on_event, 500):
print("\r\033[KEMG Rate:", listener.rate, end='')
sys.stdout.flush()
示例4: main
def main():
libmyo.init()
hub = libmyo.Hub()
listener = EmgRate(50)
try:
while True:
hub.run_once(100, listener)
print("\r\033[KEMG Rate:", listener.rate, end='')
sys.stdout.flush()
finally:
hub.stop(True)
hub.shutdown()
示例5: main
def main():
myo.init()
hub = myo.Hub()
listener = myo.ApiDeviceListener()
with hub.run_in_background(listener.on_event):
print("Waiting for a Myo to connect ...")
device = listener.wait_for_single_device(2)
if not device:
print("No Myo connected after 2 seconds.")
return
print("Hello, Myo! Requesting RSSI ...")
device.request_rssi()
while hub.running and device.connected and not device.rssi:
print("Waiting for RRSI...")
time.sleep(0.001)
print("RSSI:", device.rssi)
print("Goodbye, Myo!")
示例6: stream
def stream():
#Initialize
libmyo.init()
feed = libmyo.device_listener.Feed()
hub = libmyo.Hub()
hub.run(1000, feed)
myo = feed.wait_for_single_device()
#Continuously collect and emit data
while 1:
try:
gyro = myo.gyroscope
accel = myo.acceleration
myo_sock.emit('data', [time.clock(), gyro.x, gyro.y, gyro.z, accel.x, accel.y, accel.z])
time.sleep(0.02)
except KeyboardInterrupt:
break
except:
print 'Unexpected error'
hub.shutdown()
示例7: main
def main():
global wingl
# global wingr
viz.cam.setHandler(vizcam.KeyboardCamera())
myo.init()
gyrolist = [[0,0,0]]
viz.setMultiSample(4)
#
wingl = viz.addChild('basketball.osgb')
wingl.setScale([10,0.3,1])
wingl.setCenter([100,100,100])
wingl.setEuler([0,90,0])
wingl.collideSphere(0.5)
lStartPOS = [ 0, 2.5, 2 ]
wingl.setPosition( lStartPOS )
# wingr = viz.addChild('basketball.osgb')
# wingr.setScale([10,0.3,1])
# wingr.setCenter([100,100,100])
# wingr.setEuler([0,90,0])
# wingr.collideSphere(0.5)
# rStartPOS = [ 0, 2.5, 2 ]
# wingr.setPosition( rStartPOS )
#viz.MainView.setPosition([0,2,-15])
hub = myo.Hub()
hub.set_locking_policy(myo.locking_policy.none)
hub.run(1000, Listener())
vizact.ontimer(0.01 ,updateMyo, [gy, gy2, gy3, wingl, orx, ory, orz, orw, or1x, or1y, or1z, or1w])
vizact.onkeydown('p', hub.shutdown)
FileReader()
initializeObjectFiles()
initializeLocations()
vizact.ontimer(0.1, update)
vizact.onkeydown(' ', statusUpdate)
vizact.onkeydown('s', hub.shutdown)
# viz.AVIRecorder.maxWidth = 1920;
# viz.AVIRecorder.maxHight = 1080;
vizact.onkeydown('b', viz.window.startRecording, 'myo_capture.avi' )
vizact.onkeydown('e', viz.window.stopRecording )
示例8: print
__author__ = 'James Boggs'
__version__ = 'alpha 0.03'
# Just reads Myo input and writes it to a serial port for an Arduino
# to read. A stand-in for reading a Myo directly from the Arduino,
# which will come later.
import serial
import myo as libmyo
libmyo.init('C:\\Users\\James\\Documents\\Coding\\MyoArm\\myo-sdk-win-0.9.0\\bin')
from time import sleep
HUB_INTERVAL_MS = 1000
SERIAL_OUT_PORT = 2 #COM3
if __name__ == '__main__':
# set up myo listener
hub = libmyo.Hub()
feed = libmyo.device_listener.Feed()
hub.run(HUB_INTERVAL_MS, feed)
# set up serial communications
ser = serial.Serial(SERIAL_OUT_PORT)
# begin Myo loop
try:
myo = feed.wait_for_single_device(timeout=10)
if not myo:
print("No Myo connected after 10 seconds.")
raise
示例9: Jarvis
from __future__ import print_function
from pync import Notifier
from phue import Bridge
from random import randint
from os import system
import myo as libmyo; libmyo.init('./myo.framework')
import time
import sys
class Jarvis():
hue_bridge_ip = '192.168.0.29'
default_bulb_id = 2
request_interval = 0.1 # Output only 0.1 seconds
default_voice_names = ["Zarvox", "Ava"]
def __init__(self):
print("Hi ! I'm Jarvis. Nice to meet you !")
self.last_time = 0
self.voiceNameId = 0
self.initHueBridge()
self.initMyo()
def run(self):
# Listen to keyboard interrupts and stop the hub in that case.
try:
while self.hub.running:
time.sleep(0.25)
except KeyboardInterrupt:
print("\nQuitting ...")
finally:
示例10: init
self.z1=quat.z
self.w1 = quat.w
init("/users/dominic/downloads/sdk/myo.framework")
hub = Hub()
hub.run(1000, Listener(),lil_sleep=0.01)
try:
while True:
sleep(0.5)
except KeyboardInterrupt:
print('\nQuit')
finally:
hub.shutdown() # !! crucial
示例11: Listener
from __future__ import print_function
import myo as libmyo
from firebase import firebase
libmyo.init()
import time
class Listener(libmyo.DeviceListener):
"""
Listener implementation. Return False from any function to
stop the Hub.
"""
interval = 0.5; # Output only 0.05 seconds
firebase = firebase.FirebaseApplication('https://rock-paper-scissors-game.firebaseio.com/', None)
def __init__(self):
super(Listener, self).__init__()
self.orientation = None
self.pose = libmyo.Pose.rest
self.emg_enabled = False
self.locked = False
self.rssi = None
self.emg = None
self.last_time = 0
def post_result(self):
result = self.firebase.get('/user1', None)
示例12: Listener
from __future__ import print_function
import myo as libmyo; libmyo.init('E:\\Documents\\Fall 2015\\Fall 2015_\\CSE442\\crazyflie-clients-python\\raf')
import time
import sys
import sling as Crazy
import math
class Listener(libmyo.DeviceListener):
"""
Listener implementation. Return False from any function to
stop the Hub.
"""
interval = 0.08 # Output only 0.05 seconds
def __init__(self):
super(Listener, self).__init__()
self.orientation = None
self.pose = libmyo.Pose.rest
self.emg_enabled = False
self.locked = False
self.rssi = None
self.emg = None
self.acceleration = None
self.gyroscope = None
self.last_time = 0
self.TakeOff = True
available = "radio://0/80/2M"
self.le = Crazy.Sling(available)
self.gotCenterYaw = False;
示例13: print
Listener.temp = quat.x
else:
print("Lower your hand/n")
sleep(1)
Listener.temp = quat.x
# newx = 1
# Listener.temp = quat.x
# sleep(1)
# else:
# newx = 15
# Listener.temp = quat.x
# sleep(1)
# print newx
# response = urllib2.urlopen('http://rpi.michaelbailey.co/control?dc='+str(newx))
# html = response.read()
init()
hub = Hub()
hub.run(1000, Listener())
try:
while True:
sleep(0.5)
except KeyboardInterrupt:
print('\nQuit')
finally:
hub.shutdown() # !! crucial
示例14: Listener
addon_dir = xbmc.translatePath( my_addon.getAddonInfo('path') )
libdir = os.path.join( addon_dir, 'resources', 'lib' )
sys.path.append(libdir )
import myo
print '############################################'
xbmcgui.Dialog().notification(TITLE,'Module loading')
''' if __name__ == '__main__':
monitor = xbmc.Monitor()
while not monitor.waitForAbort(10):
xbmc.log("hello addon! %s" % time.time(), level=xbmc.LOGDEBUG)
'''
myo.init(libdir)
xbmcgui.Dialog().notification(TITLE,'Starting 2')
class Listener(myo.DeviceListener):
# return False from any method to stop the Hub
def on_connect(self, myo, timestamp):
myo.vibrate('short')
myo.request_rssi()
def on_rssi(self, myo, timestamp, rssi):
pass
def on_event(self, event):
pass
def on_event_finished(self, event):
示例15: Copyright
# Copyright (C) 2014 Niklas Rosenstein
# All rights reserved.
import os, sys
sys.path.append(os.path.join('Users', 'raychen', 'Documents', 'Design', 'Hackathons', 'LAHacks', 'LeapCAD', 'myo-python'))
import myo
from myo.lowlevel import pose_t, stream_emg
from myo.six import print_
import random
myo.init()
SHOW_OUTPUT_CHANCE = 0.01
r"""
There can be a lot of output from certain data like acceleration and orientation.
This parameter controls the percent of times that data is shown.
"""
class Listener(myo.DeviceListener):
# return False from any method to stop the Hub
def on_connect(self, myo, timestamp):
print_("Connected to Myo")
myo.vibrate('short')
myo.request_rssi()
# def on_rssi(self, myo, timestamp, rssi):
# print_("RSSI:", rssi)
def on_event(self, event):
r""" Called before any of the event callbacks. """