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

0 Members and 1 Guest are viewing this topic.

Mace

  • $upporter
  • Contributor
  • *****
  • Posts: 77
  • Karma: 1
    • View Profile
Re: Myo Armband & VC
« Reply #15 on: February 12, 2015, 08:06:40 PM »
Success

e.Pose = "Gets the pose that the Myo detected".

Code: [Select]
UdpClient udpClient = new UdpClient("255.255.255.255", 33000);
            String strToSend = "VC.TriggerEvent&&"+e.Pose;
            Byte[] sendBytes = Encoding.ASCII.GetBytes(strToSend);

Works a treat! 
You my friend are a god among men.

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Myo Armband & VC
« Reply #16 on: February 14, 2015, 11:55:47 AM »
@Mace -- I'm actually curious to know more about what you have in mind for Myo + VC.

I don't know much about the product. The obvious use to me would be the ability to turn the microphone on/off and duck volume using something like fist closed (vc start listening/duck volume) & fingers spread (vc off/restore volume) or whatnot, but did you have other things in mind?

Apart from the five poses (if I understand it correctly), does the API allow you to make use of other types of Myo events -- something like, relative position of the hand in space (i.e. coordinates), or other types of gestural feedback?

... Also, if there's any chance of a video demo once you've got some basic functionality happening, I'd be interested to see how the two are working for you.
« Last Edit: February 14, 2015, 12:21:32 PM by jitterjames »
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)

Mace

  • $upporter
  • Contributor
  • *****
  • Posts: 77
  • Karma: 1
    • View Profile
Re: Myo Armband & VC
« Reply #17 on: February 14, 2015, 10:10:00 PM »
My idea is to use the Myo mostly as navigation. eg: left, right, up, down, select, etc

The Myo has 5 standard gestures, but each gesture can be used as 'single gesture' or a 'held gesture' then each of those can have Orientation data attached, being Roll, Pitch, Yaw.

For example: "Hold Fist 6".  6 representing a 0-9 value of a point in a circle. So 6 could represent roll, attach that to a volume control and end up with ,"While holding Fist, roll left or right to turn volume up or down."

Then from there, expand the theory, Example:
Roll 5 = neutral
"While holding Fist 5, do nothing."

Roll 6 = scroll right
"While holding Fist, roll to the right (5 changes to 6), scroll right."

Roll 7 = fast scroll right
"While holding Fist, roll further to the right (6 changes to 7), fast scroll right."

That's the basic idea i have in mind. Then send what data i need to VC via UDP as an event, given each event can have a payload, attach Roll, Pitch, Yaw as a payload.

So far all working well as single examples to test my concept.
But my limited knowledge of C# is making compiling into one application a serious challenge. On that note, if anyone knows about C# and has a spare hour to mess about,I would appreciate some assistance.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Myo Armband & VC
« Reply #18 on: February 15, 2015, 11:42:48 AM »
So far all working well as single examples to test my concept.
But my limited knowledge of C# is making compiling into one application a serious challenge. On that note, if anyone knows about C# and has a spare hour to mess about,I would appreciate some assistance.

Usually you just need to click "build" (F6) and then go grab the files from the bin folder.

I'm not sure what you mean by "into one application".

Anyway if you need help I'm sure I can find some time to come take a look using TeamViewer.

Mace

  • $upporter
  • Contributor
  • *****
  • Posts: 77
  • Karma: 1
    • View Profile
Re: Myo Armband & VC
« Reply #19 on: February 15, 2015, 08:00:02 PM »
I've updated you're DropBox.

The file MainApplication.cs is what I've been working on. everything else is straight from the repository.

Everything is working fine now, if you wanted to take a look and see if there are any code improvements, would be good.

I'm still getting my head around formatting the packet to send to VC:

Code: [Select]
Byte[] packetData =  Encoding.ASCII.GetBytes("Holding" + e.Myo.Pose + _roll + _pitch + _yaw);
Gives me : HoldingFist652

text = Holding
e.Myo.Pose = Fist     (Fist is event data gathered from pose events)
_roll = 6
_pitch = 5           (652 is event data gathered from Orientation events)
_yaw = 2

What i'd like to achieve is "652" delivered as payloads for VC to use. With 'Fist' being the event.
I'm  bit stuck on getting it all to send as payload with a mix of words and numbers.

So, that's about where i'm up to, on the home straight.

Quote
Anyway if you need help I'm sure I can find some time to come take a look using TeamViewer.
If i don't have any luck i'll take you up on your offer.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Myo Armband & VC
« Reply #20 on: February 15, 2015, 09:13:17 PM »
http://voxcommando.com/mediawiki/index.php?title=API_Application_Programming_Interface#Triggering_Events
and
http://voxcommando.com/mediawiki/index.php?title=Actions#TriggerEvent

You just need to put double ampersands between the payloads.

But rather than sending everything to VoxCommando, I think you should process the data as much as possible in your program and only trigger events when you actually want something to happen.  Otherwise VC will be too busy processing events constantly and it will impact it's overall performance.  The nice thing about having a separate program is that you don't have to worry about slowing down VC by doing processing on the myo data.  If you were making a plugin that ran in VC then you would need to worry about making sure that all the myo feedback was being handled in its own thread so as not to disturb the main VC thread.
« Last Edit: February 15, 2015, 09:15:43 PM by jitterjames »

Mace

  • $upporter
  • Contributor
  • *****
  • Posts: 77
  • Karma: 1
    • View Profile
Re: Myo Armband & VC
« Reply #21 on: February 15, 2015, 09:15:13 PM »
well I've solve most of those issues with:

Code: [Select]
string strtosend = string.Format("VC.TriggerEvent&&Holding {0}&&{1}&&{2}&&{3}", e.Myo.Pose, _roll, _pitch, _yaw);
                Byte[] packetData = Encoding.ASCII.GetBytes(strtosend);

Now VC can read properly.
Next, how do i get
Code: [Select]
<ifParams>{1}&amp;&amp;6-7</ifParams> to work wit a range of numbers? eg: 6 7 8 9

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<!--VoxCommando 2.1.3.6-->
<command id="837" name="Holding Fist " enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <if ifBlockDisabled="False" ifNot="False">
    <ifType>(A)Contains(B)</ifType>
    <ifParams>{1}&amp;&amp;6-7</ifParams>
    <then>
      <action>
        <cmdType>OSD.AddText</cmdType>
        <params>
          <param>Success</param>
        </params>
        <cmdRepeat>1</cmdRepeat>
      </action>
    </then>
    <else>
      <action>
        <cmdType>VC.StopMacro</cmdType>
        <params />
        <cmdRepeat>1</cmdRepeat>
      </action>
    </else>
  </if>
  <event>Holding Fist</event>
</command>

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Myo Armband & VC
« Reply #22 on: February 15, 2015, 09:18:21 PM »
Please see my previous post first, but you can do this:

Code: [Select]
if     a contains b            6,7,8,9    {1}

Mace

  • $upporter
  • Contributor
  • *****
  • Posts: 77
  • Karma: 1
    • View Profile
Re: Myo Armband & VC
« Reply #23 on: February 15, 2015, 09:20:57 PM »
Isn't it nice when someone works stuff out for them self, right when you're typing the answer for them.


Quote
But rather than sending everything to VoxCommando, I think you should process the data as much as possible in your program and only trigger events when you actually want something to happen.  Otherwise VC will be too busy processing events constantly and it will impact it's overall performance.  The nice thing about having a separate program is that you don't have to worry about slowing down VC by doing processing on the myo data.  If you were making a plugin that ran in VC then you would need to worry about making sure that all the myo feedback was being handled in its own thread so as not to disturb the main VC thread.

I think I've sort most of this. I've filtered out the gestures that's not needed and slowed the stream data feed rate for orientation. I'm hoping that whats left is just information i need.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Myo Armband & VC
« Reply #24 on: February 15, 2015, 09:29:31 PM »
Quote
Isn't it nice when someone works stuff out for them self, right when you're typing the answer for them.

Yeah, I love that...   :biglaugh

Well you may also need to keep track of some variables in order to keep track of state changes.

For now what you are doing is relatively easy because you only need to think about what you want it to do.  The hard part would be to create something more flexible where a user can customize what they want to keep track of and when to fire an event.

It's always more fun to start with the proof of concept stuff first to make stuff that actually works the way you want it to.

Mace

  • $upporter
  • Contributor
  • *****
  • Posts: 77
  • Karma: 1
    • View Profile
Re: Myo Armband & VC
« Reply #25 on: February 15, 2015, 09:36:50 PM »
Ahh missed reading one little sentence:
Quote
(A)Contains(B)
Takes two parameters. This is usually used to evaluate strings. Evaluates to 'true' if the text of parameter B appears in (is a substring of) the text of parameter A.
Note that this is case sensitive.

Code: [Select]
if     a contains b            6,7,8,9    {1} Makes all the difference.

Quote
Well you may also need to keep track of some variables in order to keep track of state changes.

For now what you are doing is relatively easy because you only need to think about what you want it to do.  The hard part would be to create something more flexible where a user can customize what they want to keep track of and when to fire an event.
Well beyond my abilities for now, that's why we have you. :)

Quote
It's always more fun to start with the proof of concept stuff first to make stuff that actually works the way you want it to.
So much fun. And when it does actually work, it's like little fireworks of excitement.

Mace

  • $upporter
  • Contributor
  • *****
  • Posts: 77
  • Karma: 1
    • View Profile
Re: Myo Armband & VC
« Reply #26 on: February 15, 2015, 10:08:41 PM »
Here's the next question, and this is where it gets really interesting.

Is it possible to have VC continuously run a command until a stop command is given?

Example:
Code: [Select]
if     a contains b            6,7,8,9    {1}is logic for Holding Fist and rotating.  6,7,8,9 being variables of how much rotation.
Can VC see an event 'Hold Fist' with payload 7, run command and keep running it until a new command? Either a 'Rest' gesture to stop or a change in gesture?
Or does repeating command work ok?
Come to think of it, i think my code will just send VC every event anyway. Hmm i wonder if i can program to only send a change in gesture.....
More reading to do.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Myo Armband & VC
« Reply #27 on: February 16, 2015, 08:37:21 AM »
You can use command looping but try to avoid it.

Note that you can also send other actions to VoxCommando, not just events.

Mace

  • $upporter
  • Contributor
  • *****
  • Posts: 77
  • Karma: 1
    • View Profile
Re: Myo Armband & VC
« Reply #28 on: February 16, 2015, 09:28:51 AM »
oh that sounds interesting.

Where do i find more on that?

nime5ter

  • Administrator
  • Hero Member
  • *****
  • Posts: 1999
  • Karma: 61
    • View Profile
    • Getting Started with VoxCommando
Re: Myo Armband & VC
« Reply #29 on: February 16, 2015, 09:56:40 AM »
On the API page linked to above.
TIPS: POST VC VERSION #. Explain what you want VC to do. Say what you've tried & what happened, or post a video demo. Attach VC log. Link to instructions followed.  Post your command (xml)