Page 1 of 9

Razer hydra emulation

Posted: Thu Jul 18, 2013 4:05 pm
by CyberVillain
We are working on Razer hydra emulation. Xyz Position worked right away in the hell heli demo. But rotation didn't work in any of the demos we tried.

Would love feedback from peple that use the sixense sdk. Are you using the rotation matrix or the quet array?
Which methods do you call to set it up? Any of the filter methods?

Re: Razer hydra emulation

Posted: Fri Jul 19, 2013 1:28 pm
by Croccy22
Not got an answer for you as don't have a hydra. But do have a question as always.

When you say Hydra emulation are you talking about being able to write? So then any game that supported the hydra we could emulate it using any other tracker supported by freepie?

When you say you have X,Y,Z working already is that pitch/yaw/roll or do you mean actual position?

It is pitch yaw and roll emulation I am VERY interested in. If I could take the values from my AHRS Imu and write it to an emulated Hydra I would potentially be a very happy person :P

Matt.

Re: Razer hydra emulation

Posted: Fri Jul 19, 2013 4:13 pm
by CyberVillain
Yes the goal is to have full emulation of Hydra SDK. XYZ position is working, not rotation. Strange thing is that I use the SDK util functions to convert yaw, pitch, roll into quat and mat format so should be same as the real hardware

Re: Razer hydra emulation

Posted: Sat Jul 20, 2013 9:24 am
by CyberVillain
I cant get past the mesage "Point left controller at base and pull trigger" in the Tuscany Hydra demo.

Can someone with a Hydra please let me know which yaw, pitch, roll values you get when holding the controler ponted to the base, im guessing I need to have something near correct values here for the Tuscany demo to accept my input

You can check the values using FreePIE, or if you are a dev use the sixense.dll SDK

Re: Razer hydra emulation

Posted: Sat Jul 20, 2013 12:11 pm
by Croccy22
I have posted over in the Minecrift thread to see if someone can grab the log files from your app. I know quite a few of them have Hydras in that thread.

I almost got one myself the other day but seems pointless getting the old one with the new version on the horizon.

Matt.

Re: Razer hydra emulation

Posted: Sat Jul 20, 2013 12:26 pm
by CyberVillain
I got this thread going,

http://www.mtbs3d.com/phpBB/viewtopic.php?f=120&t=18279

So if you have a Hydra please download my program that logs the data from the Sixense SDK

Re: Razer hydra emulation

Posted: Sun Jul 21, 2013 12:42 pm
by CyberVillain
Ok, got emulation to work, will upload test binaries later tonight

Re: Razer hydra emulation

Posted: Sun Jul 21, 2013 2:48 pm
by CyberVillain
Got some binaries for you guys to test

Extract to FreePIE install folder. Replace the sixense.dll in the game folder with sixense_fake.dll (Rename it to sixense.dll)

You can now emulate Hydra hardware from FreePIE
Let me know how it goes

Re: Razer hydra emulation

Posted: Mon Jul 22, 2013 4:56 am
by CyberVillain
I've tested it with Sixense Tuscany demo, Heli demo, and Alone in the rift Demo and all thre works well. But it would be great if some more can try this out before I merge into the master branch

Re: Razer hydra emulation

Posted: Mon Jul 22, 2013 7:27 am
by Croccy22
Have just posted in your other thread but won't be needed now :)

Awesome work on getting this to function. I will test this out with Minecrift as soon as I get home and let you know if it works. If it does then you will be at the top of my christmas card list!!! :D.

Matt.

Re: Razer hydra emulation

Posted: Mon Jul 22, 2013 7:40 am
by Croccy22
Just to wet my appetite. What did you actually do with the above demos? What did you emulate the Hydra with?

My plan is to emulate one of the hydras in minecrift with my AHRS Imu for headtracking, and then maybe emulate the second hydra with a Wiimote for walking controls. Is that the sort of thing that is now possible?

Matt.

Re: Razer hydra emulation

Posted: Mon Jul 22, 2013 8:34 am
by CyberVillain
all axis and buttons are emulatable so its up to you what you want to do with it. But offcourse those demos that have two hands are pretty hard to make usable without a hydra. But position tracking in the heli Rift demo works pretty well with a PS Eye and Freetrack

Re: Razer hydra emulation

Posted: Mon Jul 22, 2013 9:34 am
by Croccy22
are the two controllers named as hydra[1] and hydra[2]?

Re: Razer hydra emulation

Posted: Mon Jul 22, 2013 10:49 am
by Croccy22
Is there any reference guide anywhere? Shouold I be able to use hydra[0].roll = ahrsImu.roll for example?

Is the sixense.dll you uploaded 32bit only? It appears sixense have a 64 bit library too.

how do you "calibrate" the hydras?

Thanks, Matt.

Re: Razer hydra emulation

Posted: Mon Jul 22, 2013 12:53 pm
by CyberVillain
32bit only, all though I havent seen any game using Hydra compiled in x64? (Only game I know of from top of my head that is x64 is Crysis 1)
Sorry no guide yet

Yes

hydra[0].roll = ahrsImu.roll should work (Cant remeber from top of my head if ahrs software uses radian?)
You dont need to calibrate them since there is no hydra to calibrate, my code just tell the game that they are calibrated and ready. Some games does interal calibration like the Sixense tuscany demo, but it just means that it uses the values to find a center.

As a reference I used this super small script to get past the Calibration in Sixense Tuscany demo

Code: Select all

hydra[0].trigger = mouse.leftButton
hydra[1].trigger = mouse.rightButton

hydra[1].yaw = -android.yaw
hydra[1].roll = -android.pitch
hydra[1].pitch = -android.roll

Re: Razer hydra emulation

Posted: Mon Jul 22, 2013 2:00 pm
by Croccy22
I GOT IT WORKING!!!!!!!!

I replaced the sixense.dll from minecrift with your dll and used the following script:

Code: Select all

def update():
    global yaw
    yaw = math.radians(-ahrsImu.yaw)
    global pitch
    pitch = math.radians(ahrsImu.pitch)
    global roll
    roll = math.radians(ahrsImu.roll)

if starting:
    centerYaw = 0
    centerPitch = 0
    centerRoll = 0
   
    yaw = 0
    pitch = 0
    roll = 0
    ahrsImu.update += update

hydra[0].yaw  = yaw - centerYaw
hydra[0].pitch = pitch - centerPitch
hydra[0].roll = roll - centerRoll

if keyboard.getKeyDown(Key.Z):
    centerYaw = yaw
    centerPitch = pitch
    centerRoll = roll
    
if keyboard.getKeyDown(Key.O):
   hydra[0].trigger = 1
   
if keyboard.getKeyDown(Key.P):
   hydra[1].trigger = 1
Minecraft is now working with my DIY Rift with full headtracking!!! THANKYOU SO MUCH!!

I may well have a play with using a PS Move to do the body tracking as that is now supported too.

Can you suggest any improvements to my script. Only thing I am unsure about is I think My keyboard bit leaves the hydra triggers pressed down?

Also Minecraft is one of those games that is 64bit!! It uses 64bit java and so to start with I couldn't get anything to work. In the end I uni-installed the 64bit java and re-installed minecraft to force it to use 32bit java and it now works perfectly. I guess it would be nice to have a 64bit variant just so I have access to extra memory. Not sure how much work this would be? There is a sixense_x64.dll in minecrift.

Might have to look at some other programs that utilise the Hydra now. But think I will just be happy playing Minecraft for a while :)

Matt.

Re: Razer hydra emulation

Posted: Mon Jul 22, 2013 2:22 pm
by Croccy22
Ok,

I do have one problem though and I will try my best to explain it. In minecraft if I look forward and then look up and down it works as expected. However if I look 90 degrees to the left and look up/down instead of the pitch changing, the camera rolls instead?

I am too tired to work this out tonight so i'm going to sleep on it. The pitch is obviously working as it works when you look forward. I am wondering if it is a difference in how the hydras work compared to the ahrsImu. Due to how exact it is (looking forward pitch works 100%, looking 90deg left roll is 100%, look 45deg left and pitch is 50% and roll is 50%) I guess an equation here could solve the issue but I would be more interested to know why the issue exists in the first place.

Matt.

PS. 32bit java in minecraft does cause a small issue when it comes to texture packs as Java can't access enough memory. So a 64bit version would be really useful in this case.

Re: Razer hydra emulation

Posted: Mon Jul 22, 2013 2:40 pm
by CyberVillain
We could add a x64 dll too. I hope, i will see if its just a matter of chaning target from x86 to x64

About the triggers just do

Code: Select all

hydra[0].trigger = keyboard.getKeyDown(Key.O)
I didnt notice anything strange when using a android, will have to look intio that more..

Re: Razer hydra emulation

Posted: Mon Jul 22, 2013 2:42 pm
by mabrowning
CyberVillain wrote:We are working on Razer hydra emulation. Xyz Position worked right away in the hell heli demo. But rotation didn't work in any of the demos we tried.

Would love feedback from peple that use the sixense sdk. Are you using the rotation matrix or the quet array?
Which methods do you call to set it up? Any of the filter methods?
rotation matrix.
I do use the filter.
I use sixense_init(), then the ControllerManager to handle calibration. Then, getLatestData() in the polling loop.

Re: Razer hydra emulation

Posted: Mon Jul 22, 2013 4:00 pm
by CyberVillain
mabrowning wrote:
CyberVillain wrote:We are working on Razer hydra emulation. Xyz Position worked right away in the hell heli demo. But rotation didn't work in any of the demos we tried.

Would love feedback from peple that use the sixense sdk. Are you using the rotation matrix or the quet array?
Which methods do you call to set it up? Any of the filter methods?
rotation matrix.
I do use the filter.
I use sixense_init(), then the ControllerManager to handle calibration. Then, getLatestData() in the polling loop.
You use the matrix to the quat from the struct? Thats untested :D But I use the sixense api to transform from Eueler to matrix

Re: Razer hydra emulation

Posted: Mon Jul 22, 2013 4:37 pm
by CyberVillain
Heres a x64 build

Re: Razer hydra emulation

Posted: Mon Jul 22, 2013 5:29 pm
by WiredEarp
This sounds great CyberVillain! One of the big issues facing me is that when using resistor modded Hydras, is that I can no longer use demos like SixenseTuscany, as they pop up that 'aim at base and pull trigger' dialog, or have other calibration methods that require button pressing. Could I use this to 'push' these buttons etc, so I could use my modded Hydra in these applications?

Re: Razer hydra emulation

Posted: Mon Jul 22, 2013 5:40 pm
by CyberVillain
WiredEarp wrote:This sounds great CyberVillain! One of the big issues facing me is that when using resistor modded Hydras, is that I can no longer use demos like SixenseTuscany, as they pop up that 'aim at base and pull trigger' dialog, or have other calibration methods that require button pressing. Could I use this to 'push' these buttons etc, so I could use my modded Hydra in these applications?
Hm no, not with current version. You cant read/write at the same time but maybe I can fix that.
Will see what I can do!

Re: Razer hydra emulation

Posted: Mon Jul 22, 2013 6:09 pm
by Croccy22
I may be way off here but when I do hydra. Yaw = ahrsimu. Yaw the result are backwards. Looking left turns camera in game right.

Could this be what is throwing everything out? In my script I compensate by doing -ahrsimu. yaw but not sure if this is correct?

Matt.

Re: Razer hydra emulation

Posted: Mon Jul 22, 2013 11:51 pm
by WiredEarp
Hm no, not with current version. You cant read/write at the same time but maybe I can fix that.
Will see what I can do!
Sweet! If this could be cracked, it would open up all the existing demos to be used with modified Hydras, opening up lots of options for Hydra guns and P5 gloves (I have 2 P5 gloves just itching to pick up stuff in SixenseTuscany!). I was actually just about to buy another Hydra and do a couple of Palmer type mods to it, to get around the calibration problem...

Re: Razer hydra emulation

Posted: Tue Jul 23, 2013 3:19 am
by CyberVillain
Croccy22 wrote:I may be way off here but when I do hydra. Yaw = ahrsimu. Yaw the result are backwards. Looking left turns camera in game right.

Could this be what is throwing everything out? In my script I compensate by doing -ahrsimu. yaw but not sure if this is correct?

Matt.
Is the support in Minecraft confirmed with a real Hydra? I tested it with the Tuscany hydra demo and that works with my android, I just had to negate the values. Please try the tuscany demo and report back so we can rule out the possiblity that its a problem with Minecraft
WiredEarp wrote: Sweet! If this could be cracked, it would open up all the existing demos to be used with modified Hydras, opening up lots of options for Hydra guns and P5 gloves (I have 2 P5 gloves just itching to pick up stuff in SixenseTuscany!). I was actually just about to buy another Hydra and do a couple of Palmer type mods to it, to get around the calibration problem...
Will see what I can do right away. give me a hour or so
edit: FreePIE does not have p5 support, but I would love if someone that owns one does fix it. I know there is a library for it that 2EyeGuy here at the forum did for Glovepie

Re: Razer hydra emulation

Posted: Tue Jul 23, 2013 3:50 am
by CyberVillain
k Wired, try this binary. Put it in the plugins folder of FreePIE. Copy the sixense_fake.dll from earlier post to your game or rift demo (Not the X64 version unless its a x64 game).

Its untested since I dont have a Hydra, but I tried it with my fake dll and then I could read and write the to and from the fake dll

edit: By the way, you need to copy all the values from the real hydra to the fake hydra. Also I dont know how it will work with hemisphere calibration. But you will have to test :D

With copy i mean like

Code: Select all

hydra[0].yaw = hydra[0].yaw
This might look strange, but would this does is copy data from the real hydra to the fake hydra

Re: Razer hydra emulation

Posted: Tue Jul 23, 2013 5:35 am
by Croccy22
CyberVillain wrote:
Croccy22 wrote:I may be way off here but when I do hydra. Yaw = ahrsimu. Yaw the result are backwards. Looking left turns camera in game right.

Could this be what is throwing everything out? In my script I compensate by doing -ahrsimu. yaw but not sure if this is correct?

Matt.
Is the support in Minecraft confirmed with a real Hydra? I tested it with the Tuscany hydra demo and that works with my android, I just had to negate the values. Please try the tuscany demo and report back so we can rule out the possiblity that its a problem with Minecraft
WiredEarp wrote: Sweet! If this could be cracked, it would open up all the existing demos to be used with modified Hydras, opening up lots of options for Hydra guns and P5 gloves (I have 2 P5 gloves just itching to pick up stuff in SixenseTuscany!). I was actually just about to buy another Hydra and do a couple of Palmer type mods to it, to get around the calibration problem...
Will see what I can do right away. give me a hour or so
edit: FreePIE does not have p5 support, but I would love if someone that owns one does fix it. I know there is a library for it that 2EyeGuy here at the forum did for Glovepie
I've not played around with the Tuscany demo too much. How would I set it up to test the Roll/Pitch/Yaw. Obviosuly is minecraft it is easy to see as the hrdra controls head tracking. But can you get the hydra to control headtracking in Tuscany or does it only control the hands? Might it be that it is difficult to see if it is working properly in Tuscany?

I have asked on the minecrift thread to see if anyone has tried a real hydra with it to confirm if minecrift is working properly.

I have a read a little bit about Eular angles and from what I can see it needs to apply roation on x axis first, then y axis, then z? (That may and probably is completely wrong!!). But it appears that either minecraft or freePIE is not applying the rotations in the correct order. I take it that it doesn't make any difference in FreePIE which order you change yaw/pitch/roll in a script? So I don't think my script is at fault. Also the values from my RazerIMU seem to be as expected when looking at them using diagnostics.watch. For example no matter what way my imu is pointing, the pitch roll do not do anything different.

Matt.

Re: Razer hydra emulation

Posted: Tue Jul 23, 2013 6:43 am
by CyberVillain
Its the hands you control in that demo just verify that the rotations seems correct. We use the sixense sdk to convert to matrix so they should do it correctly (or atleast the fake dll outputs same format as the real sdk)

Re: Razer hydra emulation

Posted: Tue Jul 23, 2013 7:03 am
by WiredEarp
k Wired, try this binary. Put it in the plugins folder of FreePIE. Copy the sixense_fake.dll from earlier post to your game or rift demo (Not the X64 version unless its a x64 game).
Its untested since I dont have a Hydra, but I tried it with my fake dll and then I could read and write the to and from the fake dll
edit: By the way, you need to copy all the values from the real hydra to the fake hydra. Also I dont know how it will work with hemisphere calibration. But you will have to test :D
With copy i mean like

Code:
hydra[0].yaw = hydra[0].yaw
This might look strange, but would this does is copy data from the real hydra to the fake hydra
Wow, that was quick! Thank you so much CyberVillain - Im downloading it now but won't be able to test it till tomorrow night at the earliest unfortunately.
FreePIE does not have p5 support, but I would love if someone that owns one does fix it. I know there is a library for it that 2EyeGuy here at the forum did for Glovepie
Re the P5 support, I actually wrote a basic driver for mine a couple of months back. It doesn't support the LED's (since I only ever had terrible results with them) - it just returns the finger bend positions etc (so I could integrate it with my Hydra). The existing P5DLL's etc kept crashing for me, due to my glove being faulty on a finger (found this out eventually). I'd love to help with a FreePIE driver for them, but I just dont think i'll get the chance to learn enough about FreePIE to do it, since I'm concentrating on testing/making various foot input devices currently (I was originally going to write a Hydra driver for FreePIE, but brantlew got sick of waiting and did it :). That is, unless I could do a quick bodge by copy pasting an existing module, changing the names, and inserting my code in there? That way, I wouldn't need to spend much time learning how FreePIE all works...

Re: Razer hydra emulation

Posted: Tue Jul 23, 2013 9:20 am
by CyberVillain
FreePIEs plugin mechanism is really easy. Basicly just a matter of implementing IPlugin (Or inherit the base class Plugin if its a core plugin).

https://github.com/AndersMalmgren/FreeP ... evelopment

Re: Razer hydra emulation

Posted: Tue Jul 23, 2013 9:31 am
by Croccy22
CyberVillain wrote:Its the hands you control in that demo just verify that the rotations seems correct. We use the sixense sdk to convert to matrix so they should do it correctly (or atleast the fake dll outputs same format as the real sdk)
One thing I think I mentioned earlier was that I have to put in a negative yaw value for it to work. Could this be the cause of the issue. The Razor AHRS apparently output a right handed coordinate system (Don't actually know what that means but hey ho!) I'm just wondering If the values being passed through are the wrong orientation as to what the hydra expects. I will do some more testing when I get home but this is all so close to working perfectly.

The minecrift thread has confirmed that inecrift works as expected with a real hydra.

So the problem is somewhere between the values being retrieved from my IMU which is reporting in Degrees? and the values being fed into the Hydra from FreePIE after a Deg to Rad conversion.

Matt.

Re: Razer hydra emulation

Posted: Tue Jul 23, 2013 1:13 pm
by Croccy22
Do you have the source code for the fake sixense.dll?

mabrowning thinks it is because of the way the ahrsIMU gets its yaw/pitch/roll values and they are being applied in the wrong way to the hydra. He has suggested changes to the Eular angles thingymajig and has told me what to try but for this I would need to be able to recompile the dll.

Thanks, Matt.

Re: Razer hydra emulation

Posted: Tue Jul 23, 2013 1:41 pm
by CyberVillain
I think i showed him the relevant parts already, but the source can be found here

https://github.com/AndersMalmgren/FreeP ... /Emulation

Re: Razer hydra emulation

Posted: Tue Jul 23, 2013 2:31 pm
by Croccy22
Sorry to keep bugging you (It's really appreciated). What environment do I need set up to be able to recompile this library? I have visual studio 2012 express installed on my pc but it just whinges that it is only for creating windows store apps.

Can I compile with this or do I need to download something different?

Matt.

Re: Razer hydra emulation

Posted: Tue Jul 23, 2013 2:47 pm
by CyberVillain
You need to download the sixense SDK create a win32 C++ project and reference the files.

Re: Razer hydra emulation

Posted: Wed Jul 24, 2013 11:35 am
by Croccy22
Thanks for sending the project to me. I have now changed the code to what mabrowning suggested in the minecrift thread and it is now working perfectly!!

Thankyou so much for doing this plugin. I need to have a look around now and see what else I can get to work with it, but it was totally worth it just for minecrift :)

Thanks, Matt.

Re: Razer hydra emulation

Posted: Wed Jul 24, 2013 1:36 pm
by nateight
Exciting stuff, CyberVillain! Count me as another user who has been searching for P5 emulation, only in the other direction - I'd love to take something like a Hydra and script up a way to control this P5 Sandbox. GlovePIE, for all it owes to the P5, never enabled emulation of a P5 (2EyeGuy may be able to fix that, but I've already pestered him about it enough).

I'd still take Wiimote support over anything else, though. :P You'll get there, just keep plugging away - and thanks! :D

Re: Razer hydra emulation

Posted: Wed Jul 24, 2013 3:13 pm
by CyberVillain
Thanks :) hydra is easy to fake because they have a library that is included like a dll. Its just a matter of chaning the dll to a fake one. P5 does not have this so its harder. Which games today support the p5 natively?

Yes I'm pushing my brother to complete the Wii support. Its a problem with calibrating the mplus, if you want to try it out he has a branch for it

https://github.com/maxmalmgren/FreePIE/ ... te-support

Re: Razer hydra emulation

Posted: Wed Jul 24, 2013 4:36 pm
by nateight
CyberVillain wrote:Which games today support the p5 natively?
Today? Hell, even at its peak the P5 had a pitiful software library, it's another link in the "consumers don't want VR; don't bother making VR software" chain. Someone around here wanted to play Black & White without owning a P5, and I actually have a copy of Die By The Sword I'd be willing to wrestle with DOS to play, but it's a long-dead device. P5 emulation would be a neat perk, but if it were super easy to implement, I have to imagine it would already be a feature of GlovePIE.

Troubles with MotionPlus handshaking seem all too common; everything I've heard about it makes it sound like there are multiple error states and some dark magic occurs to get anything properly linked up. Start a thread about it if you guys have reached a dead end. There are a surprising number of Wiimote experts lurking around here who might be able to help - I was somewhat shocked to learn cybereality was on the WiiYourself! mailing list, but then I remembered who I was dealing with. :lol: