Giter Site home page Giter Site logo

myo.js's Introduction

myo.js

NPM

North (formerly Thalmic Labs), the creator of the Myo armband, was acquired by Google in June 2020. Myo sales ended in October 2018 and Myo software, hardware and SDKs are no longer available or supported. Learn more.

Myo javascript bindings.

Myo.js allows you to interact with Thalmic Labs's Myo Gesture Control Armband using websockets. Listen for IMU, EMG, and gesture events, as well as controlling vibration and locking.

installation

On the browser, just include the myo.js file in your project. Myo will be global.

On node.js

npm install myo ws

getting started

You'll need a Myo and Myo Connect

Client-side
Myo.connect('com.stolksdorf.myAwesomeApp');

Myo.on('fist', function(){
	console.log('Hello Myo!');
	this.vibrate();
});
Node
var Myo = require('myo');

Myo.connect('com.stolksdorf.myAwesomeApp', require('ws'));

Myo.on('fist', function(){
	console.log('Hello Myo!');
	this.vibrate();
});

myo lifecycle

A myo can be paired, connected, and/or synced.

A myo is paired if it's ever been connected to your computer. You can see a list of paired myos in Myo Connect's armband manager. When Myo.connect() is called, Myo.js will create a myo instance for every paired Myo on your computer and store them in Myo.myos array.

A myo is connected if it's turned on and connected to your computer over bluetooth. It can send over IMU events at this point, vibrate, and EMG (if myo.streamEMG(true) is called) but not poses since it's not synced with the user.

A myo is synced when the user puts it on and does the sync gesture. At this point it will start sending over pose and lock/unlock events.

branding and assets

You can use assets provided in our branding and UX guidelines.

documentation

You can read the full documention in docs.md

changelog

Releases are documented in changelog.md

thanks

Thanks to stolksdorf for creating Myo.js

myo.js's People

Contributors

stolksdorf avatar andrebower avatar smngreenberg avatar brianheeseis avatar superkruger avatar alanhortz avatar freehaha avatar ianseyler avatar joshuaji avatar ucodia avatar phillippohlandt avatar

Stargazers

 avatar  avatar  avatar Hinata Kaga (samon) avatar Dan Larsen avatar Felipe Sayão Lobato Abreu avatar Kyle L. McGregor avatar Kriyen Padayachee avatar Mehmet Uzel avatar Sami Karakul avatar  avatar Emre Sevindik avatar Kartik Setia avatar samy kamkar avatar Hyung-il Kim avatar  avatar Zayn  avatar Joe Sterne avatar Carl Becker Carvajal avatar retact avatar Danrley Tavares avatar Kevin Vanderbeken avatar Shawn Giese avatar Rohit Paudel avatar Roland Németh avatar Benji avatar Shahin Eskandari avatar  avatar Ramith Hettiarachchi avatar Thomas Witt avatar Ashlee Muscroft avatar Caio Willian avatar Akshit Arora avatar  avatar  avatar James G. Best avatar Elizabeth Brooks avatar Halil İbrahim ŞAFAK avatar Álvaro García León avatar Hasan Bayat avatar mika avatar Hadziq Fabroyir avatar  avatar Mikhail avatar Brendan Schlagel avatar N. Daliot avatar Robert Gorrie avatar Ethan avatar Rebecca Kane avatar Tara O'Kelly avatar  avatar Pat Laughlin avatar  avatar Harshit Dwivedi avatar Aayush Arora (angularboy) avatar Elias Fares avatar Weston Miller avatar Jose Ivan Marquez avatar  avatar Brett Lamy avatar Christophe Marois avatar Dimitrios Ververidis avatar Thomas Munduchira avatar  avatar Glavin Wiechert avatar Sashko avatar Alex Castillo avatar Kostas Minaidis avatar  avatar Björn Kimminich avatar Xiaotao Liang avatar Rocco Musolino avatar nagaschinta avatar Mike Staub avatar Shivam Verma avatar Simone Conte avatar Nejc Galof avatar tomo-chan avatar Bandula Gamage avatar ZeonWang avatar Phillip avatar Jameson Steiner avatar Jure avatar Dmytro Yurchenko avatar Jean Lucas avatar Pascal Weinberger avatar Kushal Tirumala avatar Sonja Khan avatar jdrydn avatar Ronan Connolly avatar Chris Quinn avatar Erich Kuerschner avatar JoffreyGe avatar VinCi avatar Merab Tato Kutalia avatar Mike Guida avatar  avatar Emilee avatar Alex Canessa avatar Caner Gumus avatar

Watchers

Mark Simonds avatar T. Schroeder avatar tom zhou avatar  avatar maboiteaspam avatar Hampus Nordin avatar James Cloos avatar  avatar Howard avatar Hsuching avatar Michael Anthony avatar  avatar  avatar  David Kindle avatar Andrew Schneer avatar VinCi avatar  avatar  avatar Andrew Yip avatar Cornelius Johnson avatar N. Daliot avatar Bandula Gamage avatar Hitoshi Araki avatar  avatar tomo-chan avatar Pascal Weinberger avatar Simon Shirley avatar William de Witt avatar  avatar maysara avatar Autumn Loveless avatar  avatar

myo.js's Issues

Myo.js had an error with the socket

Hello

I struggled quite a bit with connecting to Myo from node.js. No matter what, I got the error message Myo.js had an error with the socket. Myo Connect might not be running. If it is, double check the API version.Myo.js had an error with the socket. Myo Connect might not be running. If it is, double check the API version..

After a while, I tried removing the "app id" in my.connect("my-app-id"), and suddenly it worked. Turns out it crashes if you have less than 3 dot-separated words in your app id (i.e. "my.app.id"). This might be common sense, I don't know, but I can't see any mention of it in the documentation. Also, the error message is not very helpful. I debugged it a bit (add console.log(arguments) between line 20 and 21 in myo.js), and it seems the websocket started by Myo Connect returns 400 if you have less than 3 dot-separated words in your app id.

Only trigger pose events from 'rest' state?

Is it possible to configure the myo lib to only trigger a pose event from the rest state? I'm having issues were during a sustained fingers_spread suddenly a wave_out is detected after which the fingers_spread off event won't be sent when I go back to the rest pose. I'll then have trigger fingers_spread again and release (without any other poses interfering) in order to catch the fingers_spread off event. How to prevent this from happening?

Some myos won't get detected by Myo.js

This is caused by the user not creating enough myo instances to handle all possible myo-index ids from Myo Connect. The library should handle this under the hood, and hide the myo-index from the user. User should use mac address as the identifier for the myo instances

How to unlock() permanently?

According to the docs, unlock() should do an infinite unlock. But the myo band locks after 3 seconds. How can I actually unlock it forever?

npm module myo.js crash due to [email protected], suggest to upgrade it to [email protected]

In the npm module, myo.js uses [email protected] by default, however it crashes after running several seconds.

Error message:

SyntaxError: Unexpected end of JSON input
    at Object.parse (native)
    at WebSocket.handleMessage (/Users/xuji/Desktop/home_automation/myo_control_client/node_modules/myo/myo.js:60:20)
    at WebSocket.onMessage (/Users/xuji/Desktop/home_automation/myo_control_client/node_modules/ws/lib/WebSocket.js:355:18)
    at emitTwo (events.js:106:13)
    at WebSocket.emit (events.js:191:7)
    at Receiver.self._receiver.ontext (/Users/xuji/Desktop/home_automation/myo_control_client/node_modules/ws/lib/WebSocket.js:682:10)
    at Receiver.finish (/Users/xuji/Desktop/home_automation/myo_control_client/node_modules/ws/lib/Receiver.js:391:14)
    at Receiver.expectHandler (/Users/xuji/Desktop/home_automation/myo_control_client/node_modules/ws/lib/Receiver.js:378:31)
    at Receiver.add (/Users/xuji/Desktop/home_automation/myo_control_client/node_modules/ws/lib/Receiver.js:87:24)
    at Socket.firstHandler (/Users/xuji/Desktop/home_automation/myo_control_client/node_modules/ws/lib/WebSocket.js:663:22)

After googling, I found out [email protected] will crash with [email protected] and above. Thus, I upgraded ws in myo module, and it never crashed ever since.

Please use [email protected] as default in npm module if possible. Thanks!

Throw error if no myo present

It'd be nice if you could wrap the Myo.create() in a try/catch to tell if there is a myo in the system. Consider throwing an error if the connection to the localhost server fails such that the error could be caught to tell if there's no myo present.

License

Hello,

package.json states that the code is licensed under ISC.

However, the LICENSE.txt looks like a BSD 3-clause license.

The README states "The Myo.js project is licensed using the modified BSD license" - which would fit both ISC and BSD3.

Could you please clarify which license is used and please fix either the package.json or the LICENSE.txt?

Please add option to override the onError handler

We are building an application that supports many different gesture input devices. As the user does not necessarily have a Myo band, connecting to Myo Connect may fail.

In this case, the library throws an error which is not easy to catch, since it is thrown async. In my case, this caused the EventEmitter of ws to fail, and it was quite hard to track down the source of this problem.

For the time being, I'm working around this by manually overwriting Myo.onError, but it would be better if there was a way to explicitly call Myo.on('error', fn).

PS: The current behaviour of throwing in case of an error is not a good idea. It's not possible to catch this in a regular try catch due to its async behaviour. It would be better if just an error messages would be printed on the console.

Failed on HTTPS sites.

From @PhillippOhlandt on February 26, 2015 21:39

Hey I want to build myo control on my websites wich use https.

The websocket cannot be initiated.

Uncaught SecurityError: Failed to construct 'WebSocket': An insecure WebSocket connection may not be initiated from a page loaded over HTTPS.

Copied from original issue: stolksdorf/myo.js#23

two myo devices

Hello is there some way to configure two myo devices using myo js?

Code mistake in Experimental

In the experimental readme, the example for Myo Tap has myMyo.unlock() when it should have myMyo.lock(). It is currently

//Myo tap to lock and unlock!
myMyo.on('myo_tap', function(){
    if(myMyo.isLocked){
        myMyo.unlock();
    }else{
        myMyo.unlock();
    }
});

when it should be

//Myo tap to lock and unlock!
myMyo.on('myo_tap', function(){
    if(myMyo.isLocked){
        myMyo.unlock();
    }else{
        myMyo.lock();
    }
});

Also toggling the lock state is common enough that you might want to add a function to do it (to prevent mistakes like these.)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.