Tutorial: How to integrate GlovePie with an arbitrary device

Tutorials on how to create your own rigs, pics, movies, and everything that has to do with S-3D at home!
Post Reply
User avatar
brantlew
Petrif-Eyed
Posts: 2221
Joined: Sat Sep 17, 2011 9:23 pm
Location: Menlo Park, CA

Tutorial: How to integrate GlovePie with an arbitrary device

Post by brantlew »

I learned all this from scratch a while back while working on a project, and thought this research might be useful to you guys doing controllers out there.

GlovePie is basically a device bridge. It takes input signals from one device and translates them into output signals from a different device. That means that you can take lots of VR and game controllers and use them to control software that does not have native support for that particular device - like using a Wiimote to control a FPS game.

GlovePie has an extensive list of natively supported input devices. But what do you do if you are developing your own input device and you want to bridge it through GlovePie? Well either by luck or by design, GlovePie has a generic interface that you can use to generate input signals. GlovePie supports a little-known interface called OSC (Open Sound Control) that was (stangely enough) created for controlling sound equipment - parallel to MIDI, but is generic enough that it can be co-opted for other uses. GlovePie uses a network version of OSC that is built on top of UDP so it's easy to implement, and you can find open-source implementations of OSC for many languages. This tutorial uses the Bespoke OSC library that is built for C#.

http://www.bespokesoftware.org/wordpress/?page_id=69

In OSC you pass data as messages that are identified by a particular URL-like name. The protocol is not picky about the names so you can define just about any name you want and assign a data packet to it. So for example I might define a data message called "/head/yaw" or "/move/speed" or whatever is appropriate for your device. Then you fill that message with a value. Values can have a variety of types like floats or integers or even strings. The Bespoke API takes care of all the data packaging so you don't need to know the protocol details. You just call a "send" function with a message name and some data and the library will transmit the OSC message.

Here is some sample code to transmit an OSC message to GlovePie on the same machine.

Code: Select all

using System.Net;
using Bespoke.Common.Osc;

static class Program {
    static void Main() {

        OscPacket.LittleEndianByteOrder = false;     // crucial for correct Intel interpretation

        // Set the local address.  Since this is UDP we don't have to establish a connection.
        IPEndPoint myapp = new IPEndPoint(IPAddress.Loopback, 1944);
        IPEndPoint glovepie = new IPEndPoint(IPAddress.Loopback, 1945);

        // Send our message to GlovePie.  How simple is that !!
        OscMessage msg = new OscMessage(myapp, "/move/speed", 10.0f);
        msg.Send(glovepie);
    }
}
Brain-dead simple huh? So now we just need to intercept the message in a GlovePie script and translate it to another device.

Code: Select all

Osc1.ListenPort = 1945;
Osc1.listening = true;

var.move.speed = Osc1.move.speed;
Keyboard.W = (var.move.speed > 5);
There are a few caveats. OSC is only partially supported by GlovePie so some things do not work. Most importantly GlovePie (at least version 0.43) does not seem to support OSC Packets which are a collection of messages that are all received together. So if you need 2 values to strictly change together, then you will need to serialize the two values into a string and transmit them with one message instead of two separate messages.

That's about it. Hopefully some good head trackers or guns or free-motion controllers will come out of this. (anybody want to take a shot at the Sparkfun Razor? :) )
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by CyberVillain »

Like I said in my other thread, I've ordered the Sparkfun and will test this out. Probablt create a little system tray program. We probably want to be able to have an output curve like freetrack because that not something Glovepie will give us..
User avatar
brantlew
Petrif-Eyed
Posts: 2221
Joined: Sat Sep 17, 2011 9:23 pm
Location: Menlo Park, CA

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by brantlew »

A tray app is a good idea for a project like this. Haven't used free-track so I don't know what the curve is you are talking about.

In your other thread you mentioned your inexperience with hardware. I'm the same way. You just have to dive in at some point though. Anyways you would be surprised what you can accomplish these days with all the integrated and pluggable components out there. Hell I built an entire robot knowing next to nothing about electricity and without a soldering iron!

http://teledev.blogspot.com/2011/07/diy ... art-1.html

But I'm glad we have the real hardware guys on this forum to tackle some of the difficult HMD mods and such. It's cool that we can all pool software and hardware skills to accomplish these things quickly.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by CyberVillain »

Yeah, what would the hardware guys do without us software guys and vice versa :D


In freetrack you have an I/O curve (Input on one axis and Output on the other), you have 3 points that you can move around to change the curve, then at runtime the input created from moving the head is sent through the curve algorithm and the output is calibrated to that. This way you can for example have extra sensitiveness in the center but still go the full 90 or more degrees without leaving eyes of the screen. This is not as useful for us that have HMD's (Well i dont have one yet but cant wait for my HMZ), but its a must for monitor users.. Its probably pretty good for us two, in Arma 2 for example you can go almost 360 degrees, you cant do that without turning your body, so then we can calibrate to have close to 1:1 mapping from 0-85 degrees, and leave the last 5 or so degrees for everything over 90 degrees... etc

The first version will only forward the data to Glovepie ;)

edit: cool bot by the way :D
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by CyberVillain »

Just tried your example out, worked very well.. Now I just have to wait for the sparkfun to arrive
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by CyberVillain »

I reversed engineered the freetrack server code so I will let the user output both OSC or freetrack (In my case only for Arma2 support)
User avatar
brantlew
Petrif-Eyed
Posts: 2221
Joined: Sat Sep 17, 2011 9:23 pm
Location: Menlo Park, CA

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by brantlew »

Cool. I'm looking forward to see how this all comes together.
pierreye
Sharp Eyed Eagle!
Posts: 377
Joined: Sat Apr 12, 2008 9:45 pm

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by pierreye »

Can anyone point me to the right product to get? I'm looking at sparkfun with wireless connection either through bluetooth or rf to the PC.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by CyberVillain »

Sparkfun has a bluetooth option for their 9DOF IMU, if that once emulates a comport just like the USB does it will work out of the box with my upcoming sparkfun software
pierreye
Sharp Eyed Eagle!
Posts: 377
Joined: Sat Apr 12, 2008 9:45 pm

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by pierreye »

I checked sparkfun.com and see that IMU had been discontinue. Found the IMU board on eBay but not sure if this is compatible?

http://www.ebay.com/itm/Ardupilot-Polol ... 2c612445ca" onclick="window.open(this.href);return false;
User avatar
brantlew
Petrif-Eyed
Posts: 2221
Joined: Sat Sep 17, 2011 9:23 pm
Location: Menlo Park, CA

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by brantlew »

The replacement Razor (SEN-10736) seems to still be available.

http://www.sparkfun.com/products/10736
User avatar
brantlew
Petrif-Eyed
Posts: 2221
Joined: Sat Sep 17, 2011 9:23 pm
Location: Menlo Park, CA

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by brantlew »

CyberVillain wrote:Like I said in my other thread, I've ordered the Sparkfun and will test this out. Probablt create a little system tray program. We probably want to be able to have an output curve like freetrack because that not something Glovepie will give us..
Just curious what connector you ordered with it. I can't tell whether that Basic Breakout (DEV-09873) will plug directly into it or needs a separate pin connector and solder?? Same with the Bluetooth Mate.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by CyberVillain »

I bought the http://www.sparkfun.com/products/9717" onclick="window.open(this.href);return false;, its all you need as far as I understand :D
Edit: lied there, you also need the 0.1" pins to solder to the bord, but i have those already
This cable has almost the same pinout and functionality as our FTDI Basic Breakout board; you can use it to program your Arduino Pro, Pro Mini and Lilypad, etc. For use with those boards, align the black and green wires of the FTDI cable with the 'BLK' and 'GRN' labels on the PCB.
But now I've also read this a bit further down
Originally, the cable was designed to have 3.3V VCC, however something was lost in translation between SparkFun and our supplier and we got stuck with a whole bunch of FTDI cables that have a slight mix up in wiring. These have 5V VCC, and 3.3V I/O. The 5V Vcc output shouldn't be a problem unless this cable is being used to power a sensitive circuit such as a sensor.
?? What does this mean?
User avatar
brantlew
Petrif-Eyed
Posts: 2221
Joined: Sat Sep 17, 2011 9:23 pm
Location: Menlo Park, CA

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by brantlew »

CyberVillain wrote:?? What does this mean?
Apparently the TX and RX pins operate at the correct voltages so I think that's all you need for serial and maybe the GND. I don't know if you need to connect the power pin or not though? The Sparkfun has a separate regulated power connector which I assume it uses to power sensors and CPU so I'm not sure what the power pin is for. I would try it without the power pin first. That's an expensive piece of equipment to jam too much voltage into. Maybe some of the hardware guys can answer this question better?

Edit: Maybe it's just an alternate power supply so you can power the Sparkfun through the I/O cable in which case you don't need to connect it, but then would need to use a separate battery power supply. It sucks not being able to just use the USB power (they warn against using it with sensors).
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by CyberVillain »

Strange company, if it was my company I would have recalled the cables... I will ask mars3554 in his thread about this... If you look at mars youtube clip you can see that the 2 pin header at the front is not connected
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by CyberVillain »

btw pierreye, Im pretty certain that their bluetooth mate will work like the cable, it will emulate a comport.. But Im not 100% sure
bobv5
Certif-Eyed!
Posts: 529
Joined: Tue Jan 19, 2010 6:38 pm

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by bobv5 »

Hi.
This cable supplying the wrong voltage
http://www.sparkfun.com/products/9717" onclick="window.open(this.href);return false;
Should be ok with this device.
http://www.sparkfun.com/products/10736" onclick="window.open(this.href);return false;
on the sparkfun site it says
"3.5-16VDC input"
I had a quick look at the schematic for the imu, it has a built in regulator, so any sane voltage is probably ok.
"If you have a diabolical mind, the first thing that probably came to mind is that it will make an excellent trap: how do you get off a functional omni-directional treadmill?"
pierreye
Sharp Eyed Eagle!
Posts: 377
Joined: Sat Apr 12, 2008 9:45 pm

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by pierreye »

Thanks for the info. I'll try to experiment with wiimote pitch combine with gyro info first to see if I can get a more accurate pitch control.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by CyberVillain »

bobv5 wrote:Hi.
This cable supplying the wrong voltage
http://www.sparkfun.com/products/9717" onclick="window.open(this.href);return false;
Should be ok with this device.
http://www.sparkfun.com/products/10736" onclick="window.open(this.href);return false;
on the sparkfun site it says
"3.5-16VDC input"
I had a quick look at the schematic for the imu, it has a built in regulator, so any sane voltage is probably ok.
The IMU only regulate the voltage on the JST port, so if you connect that cable to the FTDI port you will fry the sensors.. :/
User avatar
BadKarma
One Eyed Hopeful
Posts: 17
Joined: Thu Feb 02, 2012 5:19 am
Location: The Netherlands
Contact:

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by BadKarma »

Hey guys, any progress in getting GlovePIE to work with the Razor? I'm doing a project where I'm integrating it for use with UDK to control the camera (FPS). So far, I've got a working Razor and created a simple protective container for it so it can be easily screwed on a Sony HMZ-T1, but I'm running into a brick wall when it comes down to writing a DLL file to communicate with UDK, hence I stumbled upon this thread and GlovePIE.

Anyway, hope you guys made a bit of progress! Going to test out GlovePIE myself and see what I can come up with :)
Imagination is more powerful than knowledge..
User avatar
brantlew
Petrif-Eyed
Posts: 2221
Joined: Sat Sep 17, 2011 9:23 pm
Location: Menlo Park, CA

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by brantlew »

Yeah, CyberVillain got that working. Not sure if GlovePie integration is released, but FreePie integration is available.

http://www.mtbs3d.com/phpBB/viewtopic.p ... 2&start=30

http://www.mtbs3d.com/phpBB/viewtopic.php?f=120&t=14483
User avatar
BadKarma
One Eyed Hopeful
Posts: 17
Joined: Thu Feb 02, 2012 5:19 am
Location: The Netherlands
Contact:

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by BadKarma »

Thanks brantlew! I only checked a few topics before posting, should've searched heh.. ;) FreePIE looks promising! Going to dive in today and share my progress on the casing for the Razor IMU / Sony HMZ-T1 :)

Cheers!
Imagination is more powerful than knowledge..
User avatar
BadKarma
One Eyed Hopeful
Posts: 17
Joined: Thu Feb 02, 2012 5:19 am
Location: The Netherlands
Contact:

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by BadKarma »

Alright, so far I've used the following code to see if I had any connection with FreePIE and my Razor IMU (I actually typed it over one of cyberreality's screenshot and replaced 'freeTrack' with the correct plugin name of the AHRS):

Code: Select all

diagnostics:debug("Yaw: "..ahrsImu:getYaw().." Pitch: "..ahrsImu:getPitch().." Roll: "..ahrsImu:getRoll())
It's giving me readings! :) nice and steady! And I'm using a bluetooth module to transmit the values from the IMU to my laptop!

Now (if only cyberreality would read this :D) I need to figure out how to use those yaw/roll/pitch values in FreePIE and control the mouse in UDK with these! I know Cyberreality used a nice low-pass filter but haven't been able to find it anywhere. Cyber, if you read this, could you help me out and post some of your FreePIE script here? I'd be more than eternally grateful :mrgreen:

EDIT: Just found the thread where this thread has been continued! Reading up now, so disregard anything that might've been answered there :)
Imagination is more powerful than knowledge..
User avatar
cybereality
3D Angel Eyes (Moderator)
Posts: 11407
Joined: Sat Apr 12, 2008 8:18 pm

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by cybereality »

BadKarma wrote:I know Cyberreality used a nice low-pass filter but haven't been able to find it anywhere. Cyber, if you read this, could you help me out and post some of your FreePIE script here? I'd be more than eternally grateful :mrgreen:
If you're asking about the algorithm I used on the Vuzix mouse emulator, I never posted the code. Basically what I did was set a maximum delta value I would accept, and I ignored any readings past this threshold. This was found by testing while wearing the 1200VR HMD and seeing the fastest I would normally move my head when gaming. Additionally I averaged out the last 3 readings to smooth things out a bit. This was all straight C++ code, but it should be easy to recreate in any language.
User avatar
BadKarma
One Eyed Hopeful
Posts: 17
Joined: Thu Feb 02, 2012 5:19 am
Location: The Netherlands
Contact:

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by BadKarma »

First of all, thanks for replying on such quick notice! And yes, I am asking about the algorithm. Any chance you might share the C++ code here? I'm no programmer by nature, but I'm sure I can (at least) try and recreate the algorithm for FreePIE? Might get rid of the nasty drift CyberVillain had run into before.. The thread I'm talking about is this one:
http://www.mtbs3d.com/phpBB/viewtopic.p ... 2&start=75
Imagination is more powerful than knowledge..
User avatar
brantlew
Petrif-Eyed
Posts: 2221
Joined: Sat Sep 17, 2011 9:23 pm
Location: Menlo Park, CA

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by brantlew »

A low pass filter will probably not solve drift. It will just reduce noise. Only if the noise is directional (higher spikes in one direction) could you hope to reduce drift.
User avatar
BadKarma
One Eyed Hopeful
Posts: 17
Joined: Thu Feb 02, 2012 5:19 am
Location: The Netherlands
Contact:

Re: Tutorial: How to integrate GlovePie with an arbitrary de

Post by BadKarma »

Thanks for clearing that up brantlew. I've just tested my razor imu with Left4Dead2 (after some serious calibrating using the AHRS firmware) and all the heavy drifting and locking back into a certain position has disappeared. Still some minor noise, barely visible (barely!) and only when i'm holding the IMU myself, so it might just be me being really excited about all this, haha... Was going to upload a video to show you guys, but ran into problems. Gonna try again tomorrow, see thread mentioned in my earlier post for results! ;)

- Cheers
Imagination is more powerful than knowledge..
Post Reply

Return to “Do it Yourself!”