Author Topic: Myo Armband & VC  (Read 8305 times)

0 Members and 2 Guests are viewing this topic.

Mace

  • $upporter
  • Contributor
  • *****
  • Posts: 77
  • Karma: 1
    • View Profile
Myo Armband & VC
« on: February 11, 2015, 03:03:54 AM »
Greetings all,

Would be great to have a little plugin to use gestures from Myo Armband.
From what i've read it seems pretty straight forward to have the standard 5 movements work with VC, but i'm not that smart to work out how to do it.

Mace

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Myo Armband & VC
« Reply #1 on: February 11, 2015, 08:26:35 AM »
You're not fooling anyone Mace. I know you can figure it out.  Despite promises made a year ago the official SDK doesn't seem to include C# :(

...But... Why don't you check this out and see if you can get a sample working.

http://devleader.ca/2014/10/06/controlling-myo-armband-c/

After that I can help you with the next steps.

I recommend you start by installing visual studio express (fantastic and free) if you haven't already.

Mace

  • $upporter
  • Contributor
  • *****
  • Posts: 77
  • Karma: 1
    • View Profile
Re: Myo Armband & VC
« Reply #2 on: February 11, 2015, 06:48:01 PM »
Haha, you give far more credit than is due.

Yeh everything Myo is .lua

I know bugger all about C++, I'm a python guy!  But I'll take a stab at it.
That link has some great info, I'll see what I can mash up.

You do know that when all said and done, I'll just end up donating to the VC fund for you to make it for me anyway.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Myo Armband & VC
« Reply #3 on: February 11, 2015, 06:56:40 PM »
The link I posted should be for a c# wrapper, so you won't need to deal with c++.  I also want nothing to do with c++ thank you very much. :)

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Myo Armband & VC
« Reply #4 on: February 11, 2015, 07:00:11 PM »
You do know that when all said and done, I'll just end up donating to the VC fund for you to make it for me anyway.
Unfortunately there's not much I can do without the device.  I'm a "hands-on" programmer.  Which means I need to keep whacking away at it until it works, and that means I need something to whack!

Mace

  • $upporter
  • Contributor
  • *****
  • Posts: 77
  • Karma: 1
    • View Profile
Re: Myo Armband & VC
« Reply #5 on: February 11, 2015, 07:27:49 PM »
Guess I'll take a swing and see what I can wack!

Mace

  • $upporter
  • Contributor
  • *****
  • Posts: 77
  • Karma: 1
    • View Profile
Re: Myo Armband & VC
« Reply #6 on: February 12, 2015, 04:16:35 AM »
Dropped some stuff in your DropBox to have a look at if you felt energetic one day.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Myo Armband & VC
« Reply #7 on: February 12, 2015, 10:06:32 AM »
I'm not sure if I'm looking in the right place but I don't see anything new in my dropbox.

Mace

  • $upporter
  • Contributor
  • *****
  • Posts: 77
  • Karma: 1
    • View Profile
Re: Myo Armband & VC
« Reply #8 on: February 12, 2015, 05:04:51 PM »
Now it should be there.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Myo Armband & VC
« Reply #9 on: February 12, 2015, 05:36:36 PM »
Yes.  Is there something you would like me to do with those files?

Mace

  • $upporter
  • Contributor
  • *****
  • Posts: 77
  • Karma: 1
    • View Profile
Re: Myo Armband & VC
« Reply #10 on: February 12, 2015, 06:08:38 PM »
If you could somehow make it talk to VC would be great.

Any ideas how to use the output 'word' to activate a command? Since it's not coming from voice.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Myo Armband & VC
« Reply #11 on: February 12, 2015, 06:35:13 PM »
Are you able to test this with an actual device and get it to show that it is reacting to movements correctly?

If so then it should not be difficult to send events (or actions) to VC.  The simplest method would be to send a UDP message to VoxCommando.

After that it could be adapted to be a plugin but that would be more difficult.

Here is a sample code to send an event to VC with UDP.  It's ridiculously simple.

In this example I am sending the event "Myo.Test" and attaching optional payloads.  Payload {1} is up and Payload {2} is 5.

Note that we are "broadcasting" to the whole LAN by using an IP of 255.255.255.255, but you could also enter the IP of the machine running VC if you want.  33000 is the default port that VC listens on, set in options.

You don't have to send an event.  You can trigger an VC action.  More info on that here:
http://voxcommando.com/mediawiki/index.php?title=API_Application_Programming_Interface

Code: [Select]
using System;
using System.Net.Sockets;
using System.Text;
using System.Windows.Forms;

namespace simpleUdpExample
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            UdpClient udpClient = new UdpClient("255.255.255.255", 33000);
            Byte[] sendBytes = Encoding.ASCII.GetBytes("VC.TriggerEvent&&Myo.test&&up&&5");

            udpClient.Send(sendBytes, sendBytes.Length);

        }
    }
}

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Myo Armband & VC
« Reply #12 on: February 12, 2015, 06:39:05 PM »
actually I tested this using a form with a button on it, but here are the only lines you really need.

Code: [Select]
using System.Net.Sockets;


private void testUDP()
{
     UdpClient myClient= new UdpClient("255.255.255.255", 33000);
     Byte[] sendBytes = Encoding.ASCII.GetBytes("VC.TriggerEvent&&Myo.test&&up&&5");
     myClient.Send(sendBytes, sendBytes.Length);
}
« Last Edit: February 12, 2015, 07:28:15 PM by jitterjames »

Mace

  • $upporter
  • Contributor
  • *****
  • Posts: 77
  • Karma: 1
    • View Profile
Re: Myo Armband & VC
« Reply #13 on: February 12, 2015, 07:34:54 PM »
Hey that's pretty cool.

Only issue is:
Code: [Select]
private static void Myo_PoseChanged(object sender, PoseEventArgs e)
        {
            UdpClient udpClient = new UdpClient("255.255.255.255", 33000);
            Byte[] sendBytes = Encoding.ASCII.GetBytes("VC.TriggerEvent&&Myo.test&&up&&5");
            udpClient.Send(sendBytes, sendBytes.Length);
        }
Which works great.

Needs to be more like:
Code: [Select]
private static void Myo_PoseChanged(object sender, PoseEventArgs e)
        {
            UdpClient udpClient = new UdpClient("255.255.255.255", 33000);
            Byte[] sendBytes = Encoding.ASCII.GetBytes("VC.TriggerEvent&&{0}&&up&&5", e.Pose);
            udpClient.Send(sendBytes, sendBytes.Length);
        }
Which breaks.

Ok, not that big of a deal, i'll work it out later. My knowledge of C# awful bad.
Thanks heaps for the UDP idea  ;D

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Myo Armband & VC
« Reply #14 on: February 12, 2015, 07:41:59 PM »
something like:

Code: [Select]
String strToSend = "VC.TriggerEvent&&Myo.Pose&&"+e.pose.ToString();
Byte[] sendBytes = Encoding.ASCII.GetBytes(strToSend);

capitalization might be wrong, and I don't know what e.pose is actually so ToString() might not actually work but it gives you an idea.