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.
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.
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.
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.
Sat Nov 05, 2011 10:32 pm
brantlew
Petrif-Eyed
Joined: Sat Sep 17, 2011 9:23 pm Posts: 2042 Location: Irvine, CA
@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.
@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.
_________________
Sun Nov 06, 2011 9:34 pm
mars3554
One Eyed Hopeful
Joined: Sat May 21, 2011 4:12 pm Posts: 24 Location: Minnesota
@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.
Sun Nov 06, 2011 10:30 pm
CyberVillain
Certif-Eyable!
Joined: Mon Jun 22, 2009 8:36 am Posts: 959 Location: Stockholm, Sweden
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.
Mon Nov 07, 2011 9:09 am
mars3554
One Eyed Hopeful
Joined: Sat May 21, 2011 4:12 pm Posts: 24 Location: Minnesota
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.
Mon Nov 07, 2011 1:21 pm
CyberVillain
Certif-Eyable!
Joined: Mon Jun 22, 2009 8:36 am Posts: 959 Location: Stockholm, Sweden
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 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?
Mon Nov 07, 2011 6:07 pm
mars3554
One Eyed Hopeful
Joined: Sat May 21, 2011 4:12 pm Posts: 24 Location: Minnesota
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 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 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.
Mars, have you seen this on the page for the cable?
Quote:
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?
Thu Jan 05, 2012 2:02 am
brantlew
Petrif-Eyed
Joined: Sat Sep 17, 2011 9:23 pm Posts: 2042 Location: Irvine, CA
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.
Thu Jan 05, 2012 9:14 am
CyberVillain
Certif-Eyable!
Joined: Mon Jun 22, 2009 8:36 am Posts: 959 Location: Stockholm, Sweden
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
I want to hook mine up tonight
Thu Jan 05, 2012 10:07 am
CyberVillain
Certif-Eyable!
Joined: Mon Jun 22, 2009 8:36 am Posts: 959 Location: Stockholm, Sweden
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
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
Thu Jan 05, 2012 12:22 pm
CyberVillain
Certif-Eyable!
Joined: Mon Jun 22, 2009 8:36 am Posts: 959 Location: Stockholm, Sweden
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
Thu Jan 05, 2012 12:57 pm
CyberVillain
Certif-Eyable!
Joined: Mon Jun 22, 2009 8:36 am Posts: 959 Location: Stockholm, Sweden
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 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
Fri Jan 06, 2012 6:16 am
CyberVillain
Certif-Eyable!
Joined: Mon Jun 22, 2009 8:36 am Posts: 959 Location: Stockholm, Sweden
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 I'm waiting on a replacement cable because mine was broken.. I hope to get it tomorrow
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:
// 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.
Wed Jan 11, 2012 1:00 pm
CyberVillain
Certif-Eyable!
Joined: Mon Jun 22, 2009 8:36 am Posts: 959 Location: Stockholm, Sweden
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?
Wed Jan 11, 2012 3:32 pm
CyberVillain
Certif-Eyable!
Joined: Mon Jun 22, 2009 8:36 am Posts: 959 Location: Stockholm, Sweden
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?
Wed Jan 11, 2012 4:10 pm
brantlew
Petrif-Eyed
Joined: Sat Sep 17, 2011 9:23 pm Posts: 2042 Location: Irvine, CA
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.
_________________
Wed Jan 11, 2012 10:33 pm
CyberVillain
Certif-Eyable!
Joined: Mon Jun 22, 2009 8:36 am Posts: 959 Location: Stockholm, Sweden
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...
Thu Jan 12, 2012 1:56 am
CyberVillain
Certif-Eyable!
Joined: Mon Jun 22, 2009 8:36 am Posts: 959 Location: Stockholm, Sweden
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
Thu Jan 12, 2012 2:25 am
brantlew
Petrif-Eyed
Joined: Sat Sep 17, 2011 9:23 pm Posts: 2042 Location: Irvine, CA
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.
Users browsing this forum: No registered users and 4 guests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum