• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python myo.init函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中myo.init函数的典型用法代码示例。如果您正苦于以下问题:Python init函数的具体用法?Python init怎么用?Python init使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了init函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:rhodesvr,项目名称:myo-march,代码行数:35,代码来源:MYO.py


示例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])
开发者ID:rhodesvr,项目名称:myo-march,代码行数:29,代码来源:myoTVDemo.py


示例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()
开发者ID:NiklasRosenstein,项目名称:myo-python,代码行数:7,代码来源:04_emg_rate.py


示例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()
开发者ID:Brentbin,项目名称:myo-python,代码行数:12,代码来源:emg_rate.py


示例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!")
开发者ID:NiklasRosenstein,项目名称:myo-python,代码行数:19,代码来源:05_api_listener.py


示例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()
开发者ID:dylanebert,项目名称:MyoLearn,代码行数:21,代码来源:myl.py


示例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 )
开发者ID:rhodesvr,项目名称:myo-march,代码行数:40,代码来源:MYO2.py


示例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
开发者ID:JBoggsy,项目名称:MyoArm,代码行数:31,代码来源:MyoReader.py


示例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:
开发者ID:V1C0D3R,项目名称:Jarvis,代码行数:31,代码来源:jarvis.py


示例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
开发者ID:qema,项目名称:gesture-sound,代码行数:30,代码来源:Stop.py


示例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)
开发者ID:HackerPack,项目名称:rock-paper-myo,代码行数:30,代码来源:RockPaperScissor.py


示例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;
开发者ID:shirazamin,项目名称:CrazyFile_MyoArmband,代码行数:31,代码来源:Myo.py


示例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
开发者ID:noctisilva,项目名称:makecdt,代码行数:30,代码来源:test2.py


示例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):
开发者ID:hllhll,项目名称:myo-kodi-control,代码行数:31,代码来源:myo_service.py


示例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. """
开发者ID:raychensg,项目名称:LeapCAD,代码行数:30,代码来源:hello_myo.py


示例16: on_pose

    def on_pose(self, myo, timestamp, pose):
        print(pose)
        if pose=="fist":
            print("FIRED!")
            
            queue.publish('fire', json.dumps({
                'fire':True
            }))
    #def on_accelerometer_data(self,myo, timestamp, acceleration):
        # Do something with acceleration data

    def on_gyroscope_data(self, myo, timestamp, gyroscope):
        queue.publish('position', json.dumps({
            'th':gyroscope.y
        })) 
        #print(gyroscope.y)

        
myo.init('C:/myo-sdk-win-0.9.0/bin')
hub = Hub()
hub.run(1000, Listener())
try:
    while True:
        sleep(0.5)
        
except KeyboardInterrupt:
    print('\nQuit')
finally:
    hub.shutdown()  # !! crucial
开发者ID:strangesast,项目名称:hackru2016,代码行数:29,代码来源:__main__.py


示例17: Listener

__author__ = 'e_tak_000'

# The work is based over Niklas Rosenstein's myo-python

import myo as libmyo; libmyo.init()
import time
import os
import sys
import math

class Listener(libmyo.DeviceListener):

    def on_connect(self, myo, timestamp):
        print("Hello, Myo!")
        myo.vibrate('short')
        myo.vibrate('short')
        myo.vibrate('short')


    def on_disconnect(self, myo, timestamp):
        print("Goodbye, Myo!")


    def on_orientation_data(self, myo, timestamp, quat):
        print("Orientation:", quat.x, quat.y, quat.z, quat.w)


    def on_pose(self, myo, timestamp, pose):
        if pose == libmyo.Pose.fist:
            print("Don't show me 'ya fist!")
            return False  # Stops the Hub
开发者ID:mitibhaavsar,项目名称:courses,代码行数:31,代码来源:MyoToWords.py


示例18: print

            print("X-axis failure")
            # myo.vibrate("short")
        elif quat.y > 0.8:
            print("Y-axis failure")
            # myo.vibrate("short")
        elif quat.z > 0.1:
            print("Z-axis failure")
            # myo.vibrate("short")
        else:
            print("Good job!")

    def set(self, keyPress):
        print('set')
        if (keyPress == " "):
            print("hi")
            #originPoint = [quad.w, quad.x, quad.y, quad.z]


libmyo.init('~/Downloads/sdk/myo.framework')
#expects list
listener = Listener()
hub = Hub()
hub.run(1000, listener)

try:
    while True:
        sleep(0.5)
except KeyboardInterrupt:
    print('\nQuit')
finally:
    hub.shutdown()  # !! crucial
开发者ID:JaiGhanekar,项目名称:HackPrincetonExercises,代码行数:31,代码来源:test.py


示例19: main

def main():
    """ MYO init """
    libmyo.init()
    print("Connecting to Myo ... Use CTRL^C to exit.")
    hub = libmyo.Hub()
    hub.set_locking_policy(libmyo.LockingPolicy.none)
    myo = MyoListener()
    hub.run(1000, myo)
    """ Audio engine init """
    pygame.mixer.init(44100, channels=1)
    sounds = samplebank.load_samples(pygame.mixer)
    State.currentGroup = sounds["single"]["random"]
    time.sleep(1)
    say("Welcome to VoCoMi")
    """ Main loop """
    period = (60.0 / BPM) * 1000
    try:
        while hub.running:
            #
            # LISTENING for instructions
            #
            if State.currentState == State.LISTENING:
                try:
                    say(random.choice(["What would you like me to do?", "What should we do next?"]))
                    intent = nuance.get_intent()
                    print(intent)
                    if not intent:
                        continue
                    elif intent["intent"] == "Exit":
                        break
                    elif intent["intent"] == "Clear":
                        print("clear score")
                        State.score = [[] for x in range(NBEATS)]
                        say("Your mix has been cleared.")
                    elif intent["intent"] == "List_options":
                        print("list options")
                        if (
                            "concepts" in intent
                            and "Instruments" in intent["concepts"]
                            and intent["concepts"]["Instruments"] in sounds["double"]
                        ):
                            options = list(sounds["double"][intent["concepts"]["Instruments"]].keys())
                        else:
                            options = list(sounds["single"].keys()) + list(sounds["double"].keys())
                        last_option = options[-1]
                        other_options = ",".join(options[:-1])
                        say("We currently have %s, and %s samples in our database." % (other_options, last_option))
                    elif intent["intent"] == "Modify_instrument_track":
                        if "concepts" not in intent or "Instruments" not in intent["concepts"]:
                            continue
                        instrument = intent["concepts"]["Instruments"]
                        if instrument in sounds["double"]:
                            say("Please, be more specific. Which %s sample do you want?" % instrument)
                        else:
                            State.currentGroup = sounds["single"][instrument]  # fill with selection
                            State.currentSample = random.randint(0, len(State.currentGroup) - 1)
                            State.currentState = State.BROWSING
                            say(
                                "You can now browse the %d %s samples by waving your hand. How about this one?"
                                % (len(State.currentGroup), instrument)
                            )
                            State.currentGroup[State.currentSample].play()
                    elif intent["intent"] == "Select_drum_track":
                        if (
                            "concepts" not in intent
                            or "Drum_track" not in intent["concepts"]
                            or len(intent["concepts"]["Drum_track"]) == 0
                        ):
                            continue
                        instrument = intent["concepts"]["Drum_track"]
                        State.currentGroup = sounds["double"]["drums"][instrument]
                        State.currentSample = random.randint(0, len(State.currentGroup) - 1)
                        State.currentState = State.BROWSING
                        say(
                            "You can now browse the %d %s drum samples by waving your hand. How about this one?"
                            % (len(State.currentGroup), instrument)
                        )
                        State.currentGroup[State.currentSample].play()
                    elif intent["intent"] == "Select_voice_track":
                        if (
                            "concepts" not in intent
                            or "Voice_track" not in intent["concepts"]
                            or len(intent["concepts"]["Voice_track"]) == 0
                        ):
                            continue
                        instrument = intent["concepts"]["Voice_track"]
                        State.currentGroup = sounds["double"]["voice"][instrument]  # fill with selection
                        State.currentSample = random.randint(0, len(State.currentGroup) - 1)
                        State.currentState = State.BROWSING
                        say(
                            "You can now browse the %d %s voice samples by waving your hand. How about this one?"
                            % (len(State.currentGroup), instrument)
                        )
                        State.currentGroup[State.currentSample].play()
                    elif intent["intent"] == "Set_and_modify":
                        if "concepts" not in intent or "Instruments" not in intent["concepts"]:
                            continue
                        instrument = intent["concepts"]["Instruments"]
                        if instrument in sounds["single"]:
                            State.currentGroup = sounds["single"][instrument]
#.........这里部分代码省略.........
开发者ID:lemonzi,项目名称:VoCoMi,代码行数:101,代码来源:vocomi.py


示例20: init

'''
Created on 2016.5.21
edited on 2016.5.31
@Author: Gan
This program use to get 2 Myos' angle in real time.
the imported Myos_angle moudle has some functions that can caculate the angle from both ACC and GRY signals.

'''
import Myos_angle
from myo import init, Hub, Feed, StreamEmg
import time
import numpy as np
init()				# init the Myo
feed = Feed()	 	# use feed class
hub = Hub() 	
angle = [0,0]		# init 2 Myo's angle 
t_start = 0			# use to store the angle_updata function's start time
t_s = 0				# use to store the end time
T = 200				# Total time
t1 = 0				# to record the runing start time
t2 = 0				# to record current time
which_MYO = [0,1]	# choose which myo to use. threre are 4 types:[0],use the frist Myo; [1]:use the second; [0,1]or[1,0]:use both
hub.run(1000, feed)	
open('Angle&w.txt', 'w').close()
T = int(input("input time(s):"))

try:
	while True:
		myo = feed.get_devices()
		print(myo)
		t1 = time.time()
开发者ID:GanKunlu,项目名称:Myo-scope,代码行数:31,代码来源:get_Multiple_Angle.py



注:本文中的myo.init函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python six.print_函数代码示例发布时间:2022-05-27
下一篇:
Python utils.normpath函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap