[Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Talk about Head Mounted Displays (HMDs), augmented reality, wearable computing, controller hardware, haptic feedback, motion tracking, and related topics here!
mars3554
One Eyed Hopeful
Posts: 24
Joined: Sat May 21, 2011 4:12 pm
Location: Minnesota

[Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by mars3554 »

[youtube-hd]http://www.youtube.com/watch?v=vVrflj30LGY[/youtube-hd]

Required Skills:
Light Soldering, Programming with virtual com ports and sockets, Critical Thinking

Required Hardware
IMU: http://www.sparkfun.com/products/10736" onclick="window.open(this.href);return false;
Programming and Data Cable: http://www.sparkfun.com/products/9717" onclick="window.open(this.href);return false;
6 pin header for the cable: http://www.sparkfun.com/products/10527" onclick="window.open(this.href);return false; (no soldering) otherwise: http://www.sparkfun.com/products/116" onclick="window.open(this.href);return false;

[EDIT by cybereality: get this instead http://www.sparkfun.com/products/9873" onclick="window.open(this.href);return false; as per this comment http://www.mtbs3d.com/phpBB/viewtopic.p ... 912#p68912" onclick="window.open(this.href);return false; ]

Required Software
Python 2.7.2: http://www.python.org/getit/releases/2.7.2/" onclick="window.open(this.href);return false;
PySerial: http://pyserial.sourceforge.net/" onclick="window.open(this.href);return false;
Code: http://www.varesano.net/projects/hardware/FreeIMU#v0.4" onclick="window.open(this.href);return false; (scroll down to FreeIMU library)

Block Diagram overview:
Sparkfun Razer --[UART]--> Python --[UDP Loopback]--> GMOD lua script

This will get you as far as sending UDP packets to yourself. I don't know how many ppl are interested in GMOD or
lua scripting so I'll leave that part out for now.

1. download and install the freeimu library
2. save and download the .pde code below to your arduino
3. check that you are receiveing UART data using the serial monitor button in the arduino IDE.
4. With pyserial and python installed, close the arduino IDE and run the python program below.
5. Use your own program to catch the packets.

Alternatively, I'm sure libraries exist for other languages that allow you to interface with sockets and COM ports.
I am using python because I like it and the code is really short.
Last thing: In the video, the head tracking is not done through mouse or joystick input. I am directly commanding
the neck joint inside of the game.

I hope that more competent coders than myself will look into GMOD's lua scripting. Joint manipulation down to the finger is possible
and there is example code. I am not skilled with lua scripts and there is little in documentation.

rename it to whatever.pde

Code: Select all

#include <ADXL345.h>
#include <HMC58X3.h>
#include <ITG3200.h>

//#define DEBUG
#include "DebugUtils.h"

#include "FreeIMU.h"
#include "CommunicationUtils.h"
#include <Wire.h>

#define ToRad(x) (x*0.01745329252)  // *pi/180
#define ToDeg(x) (x*57.2957795131)  // *180/pi

int raw_values[9];
//char str[512];
float ypr[3]; // yaw pitch roll
float val[9];

// Set the FreeIMU object
FreeIMU my3IMU = FreeIMU();

void setup() { 
  Serial.begin(9600);
  Wire.begin();
  
  delay(5);
  my3IMU.init(); // the parameter enable or disable fast mode
  delay(5);
}

void loop() { 
  
  my3IMU.getYawPitchRoll(ypr);
  //roll pitch yaw format
  Serial.print(ypr[2]);
  Serial.print(",");
  Serial.print(ypr[1]);
  Serial.print(",");
  Serial.print(ypr[0]);
  Serial.println();

  delay(5);
}

rename to whatever.py

Code: Select all

# UDP client example
import socket
import serial
import time
ser = serial.Serial(port='COM14',baudrate=9600, timeout=1)
client_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
port=5003
counter=0
print '---IMU Serial IPC Link---'
time.sleep(3)

try:
        while 1:
                counter = counter + 1
                data = ser.readline()
                client_socket.sendto(data, ("localhost",port))
                time.sleep(0.020)
                if (counter >= 30):
                        print data
                        counter = 0
                
except KeyboardInterrupt:
        client_socket.close()
        ser.close()
        print 'Disconnected...'
        
client_socket.close()
ser.close()

Last edited by mars3554 on Mon Nov 07, 2011 6:35 pm, edited 1 time in total.
User avatar
cybereality
3D Angel Eyes (Moderator)
Posts: 11407
Joined: Sat Apr 12, 2008 8:18 pm

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by cybereality »

Wow! This is really awesome man!

I know a lot of people are going to be interested in a solution like this, for use with the HMZ-T1.
mars3554
One Eyed Hopeful
Posts: 24
Joined: Sat May 21, 2011 4:12 pm
Location: Minnesota

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by mars3554 »

cybereality wrote:Wow! This is really awesome man!

I know a lot of people are going to be interested in a solution like this, for use with the HMZ-T1.
Haha thanks, That's exactly what I'll be doing once I get mine. I'm working on a wireless board so I can stand up and turn around without wrapping myself in cables. I'm hoping to get the price down from what sparkfun (over)charges.
pierreye
Sharp Eyed Eagle!
Posts: 377
Joined: Sat Apr 12, 2008 9:45 pm

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by pierreye »

Cool! How do you program that the game will recognize 0 degree pitch = horizontal level?
mars3554
One Eyed Hopeful
Posts: 24
Joined: Sat May 21, 2011 4:12 pm
Location: Minnesota

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by mars3554 »

pierreye wrote:Cool! How do you program that the game will recognize 0 degree pitch = horizontal level?
In the old days, programming mods for the hl/hl2 engine required you to recompile everything and then test.
Since lua has been implemented into garry's mod, mostly everything is "hooked". I'm not going to pretend to know
what that means but the end effect is that you can run text style scripts in the game in real time and then alt+tab out,
edit some code, then rerun the script in game. Things like where the eye socket and arms and legs are pointed can be changed
this way.

It looks something like this (lua script)

Code: Select all

				lockedViewAng.r = -ControlNodes[2]
				lockedViewAng.p = -ControlNodes[1]-45
				lockedViewAng.y = -ControlNodes[3]
tl;dr the roll, pitch, and yaw, is "set". Instead of emulating a mouse, there's a variable that holds the direction of where the player is looking. That variable is over written every frame by my function.
User avatar
brantlew
Petrif-Eyed
Posts: 2221
Joined: Sat Sep 17, 2011 9:23 pm
Location: Menlo Park, CA

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by brantlew »

Nice.

The sparkfun definitely seems like the best choice for 360 degree head tracking - regardless of price.
pierreye
Sharp Eyed Eagle!
Posts: 377
Joined: Sat Apr 12, 2008 9:45 pm

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by pierreye »

@mars3554 - Thanks for the explanation. Looks like only way to get 1:1 mapping is to hook into their code or API. Unless there is a DirectX command that we can tap to get absolute position in the game we can only emulate relative position.
User avatar
cybereality
3D Angel Eyes (Moderator)
Posts: 11407
Joined: Sat Apr 12, 2008 8:18 pm

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by cybereality »

@pierreye: If the tracker is good enough, you can achieve close to 1:1 with relative movement. This is how I did it with my mouse emulator. The video should be up shortly, but I was able to play for around 10 minutes with little to no drift in pitch. Of course, absolute will always be better, but that is not to say that relative can't work.
mars3554
One Eyed Hopeful
Posts: 24
Joined: Sat May 21, 2011 4:12 pm
Location: Minnesota

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by mars3554 »

pierreye wrote:@mars3554 - Thanks for the explanation. Looks like only way to get 1:1 mapping is to hook into their code or API. Unless there is a DirectX command that we can tap to get absolute position in the game we can only emulate relative position.
I think you are correct. I had the advantage of having access to those resources but 99% of the games out there do not give you that privilege.

That said, I do think it's possible to do it without permission by using the same method that aimbot developers use. I have personally never taken one apart
but I don't see any other way to move the aiming vector to a different position accurate enough to get headshots consistently.
cybereality wrote:@pierreye: If the tracker is good enough, you can achieve close to 1:1 with relative movement. This is how I did it with my mouse emulator. The video should be up shortly, but I was able to play for around 10 minutes with little to no drift in pitch. Of course, absolute will always be better, but that is not to say that relative can't work.
That is interesting. I'm wondering if there is any errors accumulated from the game engine and OS side. The Mouse or device might send data but the OS might skip it. The OS might get the data from the mouse but the game engine will skip it. If the error rate is very low, then a user might not even be able to notice the offset error in a 2 hour session of gaming.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by CyberVillain »

This sounds very interesting I'm a very experienced C# programmer but not very good at algebra. How much work would it be to convert the input from the COM to xyz rotation and xyz translation values? If I have that data I could easily write a DirectX joystick emulator (I've done this part before).

I guess you will need a reset hotkey so that you can tell the API where zero is, but shouldnt be that hard.
mars3554
One Eyed Hopeful
Posts: 24
Joined: Sat May 21, 2011 4:12 pm
Location: Minnesota

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by mars3554 »

CyberVillain wrote:This sounds very interesting I'm a very experienced C# programmer but not very good at algebra. How much work would it be to convert the input from the COM to xyz rotation and xyz translation values? If I have that data I could easily write a DirectX joystick emulator (I've done this part before).

I guess you will need a reset hotkey so that you can tell the API where zero is, but shouldnt be that hard.
you wont get any translational values, the imu is purely rotational. it doesnt know where your head is but knows what direction its looking. the values are comma seperated in roll,pitch,yawn format. the units are in degrees.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by CyberVillain »

mars3554 wrote:
CyberVillain wrote:This sounds very interesting I'm a very experienced C# programmer but not very good at algebra. How much work would it be to convert the input from the COM to xyz rotation and xyz translation values? If I have that data I could easily write a DirectX joystick emulator (I've done this part before).

I guess you will need a reset hotkey so that you can tell the API where zero is, but shouldnt be that hard.
you wont get any translational values, the imu is purely rotational. it doesnt know where your head is but knows what direction its looking. the values are comma seperated in roll,pitch,yawn format. the units are in degrees.
was a bit tired when i read that :D offcourse it can only do rotation... cool, sounds easy enough.. So its ready to go with the USB virtual comport and the device itself, just plugit it in and connect to the com port using your language of choice?

edit: its this part that makes me ask, "check that you are receiveing UART data using the serial monitor button in the arduino IDE." IF it was purely com it wouldnt need a third party software to receive the data?
mars3554
One Eyed Hopeful
Posts: 24
Joined: Sat May 21, 2011 4:12 pm
Location: Minnesota

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by mars3554 »

CyberVillain wrote:
mars3554 wrote:
CyberVillain wrote:This sounds very interesting I'm a very experienced C# programmer but not very good at algebra. How much work would it be to convert the input from the COM to xyz rotation and xyz translation values? If I have that data I could easily write a DirectX joystick emulator (I've done this part before).

I guess you will need a reset hotkey so that you can tell the API where zero is, but shouldnt be that hard.
you wont get any translational values, the imu is purely rotational. it doesnt know where your head is but knows what direction its looking. the values are comma seperated in roll,pitch,yawn format. the units are in degrees.
was a bit tired when i read that :D offcourse it can only do rotation... cool, sounds easy enough.. So its ready to go with the USB virtual comport and the device itself, just plugit it in and connect to the com port using your language of choice?

edit: its this part that makes me ask, "check that you are receiveing UART data using the serial monitor button in the arduino IDE." IF it was purely com it wouldnt need a third party software to receive the data?
The cable I linked has an FTDI chip inside of it. It will convert the 6 female UART serial pins to a VCP port. With the VCP (virtual com port) drivers from http://www.ftdichip.com/Drivers/VCP.htm" onclick="window.open(this.href);return false; a virtual com port will be created when the device is plugged in. Inside the arduino IDE, there is a terminal where you can view data on different available com ports and at different baud rates.

I also forgot to mention, you will need a 6 pin header for the usb cable razor board interface. They are 0.1" spacing. If you don't want to solder pins, I think these will work http://www.sparkfun.com/products/10527" onclick="window.open(this.href);return false; otherwise: http://www.sparkfun.com/products/116" onclick="window.open(this.href);return false;

I know I link a lot of sparkfun stuff but feel free to use any vender you wish, eg digikey, mouser, newark, etc.

And yes, any language should work. I know java likes rxtx, python uses pyserial, and c++ does its own thing.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by CyberVillain »

OK so one SEN-10736 and one DEV-09717 ordered, lets hope I can make something out of this...
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by CyberVillain »

Mars, have you seen this on the page for the cable?
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 is your take on this?
User avatar
brantlew
Petrif-Eyed
Posts: 2221
Joined: Sat Sep 17, 2011 9:23 pm
Location: Menlo Park, CA

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by brantlew »

CyberVillain, I'm going to move the discussion onto this thread to increase visibility.
Previous thread: http://www.mtbs3d.com/phpBB/viewtopic.p ... 67&start=0
CyberVillain wrote: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
Yeah but at least those guys are "straight-shooters". They disclose everything about their components (warts and all) so you know exactly what to expect.

The more I think about it, I'm pretty sure the 3.3V pin on the Sparkfun is an (optional) unregulated power supply pin to run the sensors and CPU. But you can also power the device through the regulated power connector (3 AA batteries would be sufficient). It's just unfortunate that the cable power can't be used because it does simplify the setup. However if you're thinking about going BlueTooth, you're going to need a battey pack anyways.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by CyberVillain »

If you look at Mars youtube clip you it looks like a straight connection from the USB to the IMU, but we need his answer to be certain.. Mars where are youuu :D

I want to hook mine up tonight :D
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by CyberVillain »

I have a thread going on the sparkfun forum, nothing concrete yet though. I reallly hope mars reads this soon and can shed some light over it.. he doesnt mentioned anything about powering the chip in this thread so i guess i just let the pin on the cable do it, but i want confirmation before i hook up a expensive chip like this

http://forum.sparkfun.com/viewtopic.php ... 33#p137833" 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: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by brantlew »

I think you can safely just connect TX, RX, and GND pins and then supply power to the regulated power connector via a 3 AA battery pack from Radio Shack . A temporary solution until you integrate the BlueTooth
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by CyberVillain »

who, me? Im not going for a wireless solution (Your thinking about the guy who is doing a VR gun).. So I would rather use the cable only if possible, but I do not like risking the IMU just to test.. I hope Mars will see this anytime soon. OH well, going to the movies with my girl now so do time for playing anyway.. Hope i have an answer tomorrow so i can start playing
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by CyberVillain »

Got an answer from Sparkfun
The I/O on that cable is 3.3V, but the VCC pin is 5V. The microcontroller on the board can handle 5V just fine, but I don't think the sensors can. If you connect this directly to the FTDI port on the board you will most likely fry one or more of the sensors. If you plug the power into the connectors behind the JST connector (or the JST connector itself) you should be fine since this signal is regulated. Let me know if you have any other questions.
Why would i care if the internal voltage is 3.3 volt when they output 5 :D Anyway, I guess I can remove the 5V pin from the header and route that 5v to the JST pin which as a volt regulator

edit: But what i want is that SParkfun or my Swedish distributor supply me with a correct cable
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by CyberVillain »

when i connect the usb cable to the computer i get no reaction at all, and i get no voltage off the vcc pin, probably a faulty cable :/
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by CyberVillain »

Can a moderator change the first post in this thread and remove the link to the USB cable and add a link to this product

http://www.sparkfun.com/products/9873" onclick="window.open(this.href);return false;

The USB cable will fry the sensors on the board...
User avatar
brantlew
Petrif-Eyed
Posts: 2221
Joined: Sat Sep 17, 2011 9:23 pm
Location: Menlo Park, CA

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by brantlew »

CyberVillain wrote:Can a moderator change the first post in this thread and remove the link to the USB cable and add a link to this product

http://www.sparkfun.com/products/9873" onclick="window.open(this.href);return false;

The USB cable will fry the sensors on the board...

Oh crap did you fry your Sparkfun? Does that cable not downconvert from serial to TTL voltages?
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by CyberVillain »

brantlew wrote:
CyberVillain wrote:Can a moderator change the first post in this thread and remove the link to the USB cable and add a link to this product

http://www.sparkfun.com/products/9873" onclick="window.open(this.href);return false;

The USB cable will fry the sensors on the board...

Oh crap did you fry your Sparkfun? Does that cable not downconvert from serial to TTL voltages?
No, no.. I just dont wont anyone else yo fry theirs, if they only read the first post and go try it they will :D
I'm waiting on a replacement cable because mine was broken.. I hope to get it tomorrow
User avatar
cybereality
3D Angel Eyes (Moderator)
Posts: 11407
Joined: Sat Apr 12, 2008 8:18 pm

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by cybereality »

Ok, no prob. Made the edit.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by CyberVillain »

thanks CR
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by CyberVillain »

it is all hooked up now, but I got problems

I have downloaded this copy of the FreeIMU library

http://www.varesano.net/files/libraries ... 5_2110.zip

And i've included all the libs that the compiler complains about. Now my sketch file looks like this

Code: Select all

#include <ITG3200.h>

#include <MS561101BA.h>

#include <HMC58X3.h>

#include <bma180.h>

#include <Wire.h>

#include <CommunicationUtils.h>
#include <FreeIMU.h>
Get this compiler error
C:\Program Files (x86)\arduino-1.0\libraries\MS561101BA\MS561101BA.cpp: In member function 'long unsigned int MS561101BA::getConversion(uint8_t)':
C:\Program Files (x86)\arduino-1.0\libraries\MS561101BA\MS561101BA.cpp:144: error: call of overloaded 'write(int)' is ambiguous
C:\Program Files (x86)\arduino-1.0\libraries\Wire/Wire.h:55: note: candidates are: virtual size_t TwoWire::write(uint8_t)
C:\Program Files (x86)\arduino-1.0\hardware\arduino\cores\arduino/Print.h:49: note: size_t Print::write(const char*)
Looks like there are two write methods and it does not know which one to use.... Whats wrong?

Thanks..

If you wanna try you can download the Arduino IDE, install the freeimu library and compile (You do not need the board to do this)
User avatar
brantlew
Petrif-Eyed
Posts: 2221
Joined: Sat Sep 17, 2011 9:23 pm
Location: Menlo Park, CA

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by brantlew »

Didn't download code, but I suspect a #define variable would probably clear it up, but you might have to dig around to find it. You might look at the definition of uint8_t for starters.

Another more direct method would be to just modify to source code to directly cast that variable or the object that's calling it.

Code: Select all

// cast the parameter to clear the ambiguity
object->write((uint8_t)var);

// or cast the object to force the correct method call
((TwoWire*)object)->write(var);
If that's the only ambiguous occurrence then you're golden - but don't be surprised if there are dozens in which case you might have to search for #define(s)

Hope that helps.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by CyberVillain »

Fixed it! I am now receving data :D

Will write a quick C# test consoleprogram.. give me an hour and I have a youtube video up :D
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by CyberVillain »

User avatar
brantlew
Petrif-Eyed
Posts: 2221
Joined: Sat Sep 17, 2011 9:23 pm
Location: Menlo Park, CA

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by brantlew »

Looks great! Can't wait to get my hands on one of these. Maybe you are seeing tracker noise and just need to put a smoothing filter on it. Is it bridged through GlovePie or another interface?

Also when you get a chance can you look to see if the spatial translation (X, Y, Z) tracking works at all or does it look like garbage?
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by CyberVillain »

Its a problem with my Freetrack emulation, if i send a static float on all 3 axis i still get jumpy behaviur.. Strange thing is when I include the freetrackclient.dll in a testproject it looks good, and Arma2 uses the same dll to read freetrack data so I do not know where they read the wrong data from :/

Hmm, theres only 3DOF? I cant get translation values of this one can I?
User avatar
brantlew
Petrif-Eyed
Posts: 2221
Joined: Sat Sep 17, 2011 9:23 pm
Location: Menlo Park, CA

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by brantlew »

It should have the sensors on-board to estimate translation. Maybe FreeIMU only supports orientation. Bummer.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by CyberVillain »

I do not think freeemu supports it oit of the box.. maybe you can take the data from the 9 sensors and do the math yourself?
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by CyberVillain »

There is some huge drift, I do not know if its my copy or if all suffer from it :/
User avatar
cybereality
3D Angel Eyes (Moderator)
Posts: 11407
Joined: Sat Apr 12, 2008 8:18 pm

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by cybereality »

Not bad for a first test.

You can try putting a sort-of low-pass filter on the readings. I did that for the Vuzix tracker I made. Basically set a maximum delta value with something reasonable and then ignore anything over this amount. It should be the fastest you could expect a user to move during one frame (could be around 10-20 degrees). I found this to pretty much eliminate those kinds of random jitters.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by CyberVillain »

YEah, I have a low pass filter... Its something else, maybe its the float precision or something, Arma2 maybe want a lower precision or something. If i use the real freetrack server everything works, but if I use my freetrack server emulator it does not work.. If I send hard coded values with low number of decimals it works, like 0.1, if i send 0.00001 or something like that I get the stutter.. So its not related to the sensordata, its something in my way of simulating Freetrack...
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by CyberVillain »

I've also written a little freetrackclient test program that uses the standard freetrackclient.dll (same as Arma2) and that works. So its a combination of some code in Arma2 and C# floats thats strange.. I think :P
User avatar
brantlew
Petrif-Eyed
Posts: 2221
Joined: Sat Sep 17, 2011 9:23 pm
Location: Menlo Park, CA

Re: [Video] Diy HeadTracking - Sparkfun Razor, Python, Gmod,

Post by brantlew »

Any possibility its a byte ordering issue? I've stumbled across weird crap like this a lot working in Java where the byte ordering is enforced as little-endian as opposed to x86 native. Had same problem with OSC and GlovePie.
Post Reply

Return to “General VR/AR Discussion”