Coder Social home page Coder Social logo

myolib's Introduction

myolib

Coverage Status Build Status

This is an Android library to communicate with Myo devices.

It was created for a research project at the mHealth - Uniklinik RWTH Aachen deparment. The projected required receiving sensor data (Gyro, Accl., EMG) from multiple Myo devices simultaneously, which was not possible at that time (August 2015) through the official Android SDK for Myo from Thalmic Labs.

Contributions are welcome. If you submit pull-requests please adhere to the projects current coding style. If you are using this library, i would love mention your project here, feel free to contact me.

Setup

Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Include this in your apps build.gradle file:

dependencies {
        implementation 'com.github.d4rken:myolib:0.0.5'
}

Examples

Utilizing callbacks

MyoConnector connector = new MyoConnector(getContext());
connector.scan(5000, new MyoConnector.ScannerCallback() {
    @Override
    public void onScanFinished(List<Myo> myos) {
        Myo myo = myos.get(0);
        myo.connect();
        myo.writeUnlock(MyoCmds.UnlockType.HOLD, new Myo.MyoCommandCallback() {
            @Override
            public void onCommandDone(Myo myo, MyoMsg msg) {
                myo.writeVibrate(MyoCmds.VibrateType.LONG, null);
            }
        });
    }
});

Receiving sensor data

/**
 * ...
 */
Myo myo = myos.get(0);
myo.connect();
EmgProcessor emgProcessor = new EmgProcessor();
myo.addProcessor(emgProcessor);
emgProcessor.addListener(new EmgProcessor.EmgDataListener() {
    @Override
    public void onNewEmgData(EmgData emgData) {
        Log.i("EMG-Data", Arrays.toString(emgData.getData()));
    }
});

Advanced use

BaseMyo baseMyo = new BaseMyo(getContext(), bluetoothDevice);
baseMyo.connect();
ReadMsg readMsg = new ReadMsg(Battery.BATTERYLEVEL, new MyoMsg.Callback() {
    @Override
    public void onResult(MyoMsg msg) {
        byte[] result = ((ReadMsg) msg).getValue();
    }
});
baseMyo.submit(readMsg);

Advanced advanced use

BaseMyo baseMyo = new BaseMyo(getContext(), bluetoothDevice);
baseMyo.connect();
WriteMsg writeMsg = new WriteMsg(
        UUID.fromString("00001800-0000-1000-8000-00805f9b34fb"),
        UUID.fromString("00002A00-0000-1000-8000-00805f9b34fb"),
        null,
        new byte[]{ /*....*/},
        new MyoMsg.Callback() {
            @Override
            public void onResult(MyoMsg msg) {
                if(msg.getGattStatus() == BluetoothGatt.GATT_SUCCESS)
                    Log.i("MYOAPP", "Data written!");
            }
        }

);
baseMyo.submit(writeMsg);

Example app

License

This library is licensed under Apache 2.0, see LICENSE

If you use "Android Myo library by darken" for your publication, please cite the following publication:

  • Kutafina E, Laukamp D, Jonas SM. Wearable Sensors in Medical Education: Supporting Hand Hygiene Training with a Forearm EMG. Stud Health Technol Inform. 2015;211:286-91.

myolib's People

Contributors

d4rken avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

myolib's Issues

EMG data

hello can i use specific EMG data to play a sound or present a picture
can you help me

no sensor data appears in the sample app

when the exampleapp find the myo, it shows the myo, battery and firmware version but no sensor data, can you help me in fixing that?

Value: null
Identifier: 0000180f-0000-1000-8000-00805f9b34fb:00002a19-0000-1000-8000-00805f9b34fb
05-08 16:07:35.481 9122-9413/eu.darken.myolib.exampleapp V/MyoLib:BaseMyo:CA:0C:05:1F:16:F6: Processed: d5060001-a904-deb9-4748-2c7f4a124842:d5060201-a904-deb9-4748-2c7f4a124842
05-08 16:07:35.487 9122-9122/eu.darken.myolib.exampleapp I/ViewRootImpl: ViewRoot's KeyEvent { action=ACTION_DOWN, keyCode=KEYCODE_BACK, scanCode=0, metaState=0, flags=0x48, repeatCount=0, eventTime=114433812, downTime=114433812, deviceId=-1, source=0x101 } to DecorView@5b47354[MainActivity]
05-08 16:07:35.538 9122-9138/eu.darken.myolib.exampleapp W/BluetoothGatt: onCharacteristicRead() - Device=CA:0C:05:1F:16:F6 handle=23 Status=0
05-08 16:07:35.539 9122-9138/eu.darken.myolib.exampleapp V/MyoLib:BaseMyo:CA:0C:05:1F:16:F6: rtt: 60ms | SUCCESS | ReadMsg

Thanks in advance.

Myo orientation on arm in ON_SYNCED callback

The classifier event myohw_classifier_event_arm_unsynced = 0x02 contains a rotation/orientation value of the Myo on the users arm.

It's not specified in the Myo Bluetooth protocol but in the debugger it can clearly be observed that the event contains byte[6] of data. The undocumented data is current "WarmUpState" and the previously mentioned rotation/orientation.

There is some more information in another Myo library project for OSX.
Here and here.

A comment there states:

/// Retrieve the estimated rotation of Myo on the user's arm after a sync.
/// The values specifies the rotation of the myo on the arm (0 - logo facing down, pi - logo facing up)

I did not get any meaningful values around 0 or pi during tests though.

BluetoothDevice

In your description of Advance use, while trying to access the battery level, we must present the bluetooth device in constructor of BaseMyo. Can you please explain where can i get this BluetoothDevice?

BaseMyo baseMyo = new BaseMyo(getContext(), **bluetoothDevice**);
baseMyo.connect();
ReadMsg readMsg = new ReadMsg(Battery.BATTERYLEVEL, new MyoMsg.Callback() {
    @Override
    public void onResult(MyoMsg msg) {
        byte[] result = ((ReadMsg) msg).getValue();
    }
});
baseMyo.submit(readMsg);

No connection can be established

I made a simple android app, that uses your library and the code on the front page to get a Callback when the device is connected. Unfortunately, this never happens, the app does not find a myo device. It is powered on and also connected to the phone via bluetooth.
Any help would be greatly appreciated!

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.