Page 2 of 3

Re: Zeiss headtracker input/trackIR output?

Posted: Tue Jun 04, 2013 4:18 pm
by Mars
Trying to give it constant values did not work but it is getting late :-)

Using your script:

Code: Select all

def update(): 
   global yaw 
   yaw = zeiss.Yaw
   global pitch 
   pitch = zeiss.Pitch
   global roll 
   roll = zeiss.Roll

if starting:
   centerYaw = 0
   centerPitch = 0
   centerRoll = 0
   
   yaw = 0
   pitch = 0
   roll = 0
   zeiss.update += update
   
#if yaw < 0:
#  yaw = yaw + 360
#else: 
#  yaw = yaw

#if centerYaw < 0:
#  centerYaw = centerYaw + 360
#else: 
#  centerYaw = centerYaw

trackIR.yaw  = math.degrees(yaw - centerYaw)
trackIR.pitch =  math.degrees(pitch - centerPitch)
trackIR.roll =  math.degrees(roll - centerRoll)

diagnostics.watch(yaw)
diagnostics.watch(roll)
diagnostics.watch(pitch)

diagnostics.watch(centerYaw)
diagnostics.watch(centerPitch)
diagnostics.watch(centerRoll)

if (keyboard.getPressed(Key.Y)):
   centerYaw = yaw
   centerPitch = pitch
   centerRoll = roll
value of yaw from tracker ranges from:
starts looking 90deg right value with a value of 1.6
0.0 is straight ahead
< 3.14 is looking right upto 180 behind you
-1.6 is looking left i.e 270 deg
< -3.14 pans left until 180deg behind you

Forgot to add that the axis is reversed too.

Re: Zeiss headtracker input/trackIR output?

Posted: Wed Jun 05, 2013 12:55 am
by CyberVillain
But that is right then -1.57 rad = -90 deg = look left. Same for all TIR games

Just put a minus sign on the axis that are reversed and you are set?

Re: Zeiss headtracker input/trackIR output?

Posted: Wed Jun 05, 2013 12:01 pm
by Mars
The view is not centered at start but is offset 90deg to the right with the tracker held in the position that should give a view straight ahead.

Using the script you posted earlier (or others), centering the view will centre the view but its then that the jumping view (when panning left with the yaw axis not reversed, right when reversed) will start.

Does that make things clearer? Apologies if i did not explain whats going on well enough last night.

Re: Zeiss headtracker input/trackIR output?

Posted: Wed Jun 05, 2013 3:55 pm
by Mars
Ok, the penny has dropped, the degree angles are for how much degrees of movement TIR is tracking and not an ingame value of movement.

This script works:

Code: Select all

def update(): 
   global yaw 
   yaw = zeiss.Yaw * ratio
   global pitch 
   pitch = zeiss.Pitch
   global roll 
   roll = zeiss.Roll
   
if starting:
   maxAngle = math.radians(180)
   axisRange = math.radians(360)
   ratio = axisRange / maxAngle
   centerYaw = 0
   centerPitch = 0
   centerRoll = 0   
   yaw = 0 
   pitch = 0
   roll = 0 
   zeiss.update += update   

trackIR.yaw  = -math.degrees(yaw - centerYaw) *  0.75 #1:1 headtracking
trackIR.pitch =  math.degrees(pitch - centerPitch)
trackIR.roll =  math.degrees(roll - centerRoll)

diagnostics.watch(zeiss.Yaw)
diagnostics.watch(zeiss.Pitch)
diagnostics.watch(zeiss.Roll)
diagnostics.watch(ratio)
diagnostics.watch(yaw)
diagnostics.watch(pitch)
diagnostics.watch(roll)
diagnostics.watch(centerYaw)
diagnostics.watch(centerPitch)
diagnostics.watch(centerRoll)

if (keyboard.getPressed(Key.Y)):
 centerYaw = yaw
 centerPitch = pitch
 centerRoll = roll
The view was offset because the axis range being fed to the game was larger than it was expecting and it tried to interpolate hence the jumping view.

Re: Zeiss headtracker input/trackIR output?

Posted: Thu Jun 06, 2013 4:49 am
by CyberVillain
Glad it worked out! :D

So you are happy with the Zeiss plugin? Should i push it to the master branch?

Re: Zeiss headtracker input/trackIR output?

Posted: Thu Jun 06, 2013 12:03 pm
by Mars
Yeah, its working great so far. Looks like I've contributed to an opensource project for the first time hehe.

Thank you for all the assistance!

Re: Zeiss headtracker input/trackIR output?

Posted: Thu Jun 06, 2013 12:25 pm
by CyberVillain
:D

Re: Zeiss headtracker input/trackIR output?

Posted: Sat Jun 08, 2013 2:44 am
by Mars
Finally got to the bottom of the centering issue. Previous script would work initially but after it had been centered a few times the view would start jumping again. This script really does work so posting here for anyone who has the same issue:

Code: Select all

def update(): 
   global yaw 
   yaw = zeiss.Yaw 
   global pitch 
   pitch = zeiss.Pitch * ratio 
   global roll 
   roll = zeiss.Roll * ratio
   
if starting:
   maxAngle = math.radians(180)
   axisRange = math.radians(360)
   ratio = axisRange / maxAngle
   centerYaw = 0
   centerPitch = 0
   centerRoll = 0 
   yaw = 0
   pitch = 0
   roll = 0
   zeiss.update += update   

TIRyaw = -math.degrees(yaw + centerYaw)
if TIRyaw > 180:
 TIRyaw = -(360-TIRyaw)
if TIRyaw < -180:
 TIRyaw = -360-TIRyaw  
  
TIRpitch = math.degrees(pitch + centerPitch)
TIRroll = math.degrees(roll + centerRoll)

trackIR.yaw = TIRyaw
trackIR.pitch = TIRpitch
trackIR.roll = TIRroll

diagnostics.watch(zeiss.Yaw)
diagnostics.watch(zeiss.Pitch)
diagnostics.watch(zeiss.Roll)
diagnostics.watch(ratio)
diagnostics.watch(yaw)
diagnostics.watch(pitch)
diagnostics.watch(roll)
diagnostics.watch(centerYaw)
diagnostics.watch(centerPitch)
diagnostics.watch(centerRoll)
diagnostics.watch(TIRyaw)
diagnostics.watch(TIRpitch)
diagnostics.watch(TIRroll)

if (keyboard.getPressed(Key.Y)):
 centerYaw = 0-zeiss.Yaw
 centerPitch = 0-zeiss.Pitch
 centerRoll = 0-zeiss.Roll 

Re: Zeiss headtracker input/trackIR output?

Posted: Mon Jun 10, 2013 12:40 am
by InrealMike
Hey Guys,

I've been away on business trips the last few days/weeks.
I'll try and catch up asap on how far you've gotten and see if I can help.

Re: Zeiss headtracker input/trackIR output?

Posted: Mon Jun 10, 2013 12:54 am
by InrealMike
Ok, I just read all the posts.
Seems like I am too late and you were able to get everything to work :)

Should there be any more questions, just post here or send me a PM.

Glad you got it working. I will download and test as soon as I get a chance. Any recommendation for a game I should test with?

Re: Zeiss headtracker input/trackIR output?

Posted: Mon Jun 10, 2013 1:45 am
by CyberVillain
Hi.
Yes, according to Mars its working :D
He removed setbootloader though to get it to work. I do not know if that is correct? And more sadly I do not get a device not found error after removing that.

Re: Zeiss headtracker input/trackIR output?

Posted: Mon Jun 10, 2013 2:08 am
by InrealMike
I just downloaded and compiled the Zeiss Branch of FreePIE

I have no games installed atm, but I see the data streaming in. Nice work Mars!

About the Bootloader-problem:

Code: Select all

        public static bool SetBootloaderMode(bool activationMode, out int error)
        {
            var result = Tracker_SetBootloaderMode(false);
            error = GetLastError();

            return result;
        
This function tries to reset the tracker from bootloader to normal operational mode (Tracker_SetBootloaderMode(false) ). But since it isn't in Bootloader mode, you get the error "Device not found".

To check if the Device is present, I would try to read out the firmware version. If this fails, then no device is connected. I will try and implement this.

Re: Zeiss headtracker input/trackIR output?

Posted: Mon Jun 10, 2013 2:27 am
by CyberVillain
Forgot to delete the Zeiss branch, its the master branch thats up to date. sorry for that

Re: Zeiss headtracker input/trackIR output?

Posted: Mon Jun 10, 2013 2:53 am
by InrealMike
I don't have GIT running on this system so unfortunately I cannot merge, but I will post my modifications here:

in the Api.cs:

replace the "SetBootloaderMode" function with:

Code: Select all

public static bool CheckForTracker(out int error)
        {
            uint Firmware = 0;
            var result = GetFirmware(ref Firmware);
            error = GetLastError();

            return result;
        }
and in the ZeissPlugin.cs replace:

Code: Select all

            result = Api.SetBootloaderMode(false, out error);
            if (!result)
            {
                throw new Exception(string.Format("Error while setting bootloader mode: {0}", Api.GetError(error)));
            }
with

Code: Select all

    
            result = Api.CheckForTracker(out error);
            if (!result)
            {
                throw new Exception(string.Format("Error while setting checking for Tracker: {0}", Api.GetError(error)));
            }
This causes an exception to be thrown when no Tracker is connected, and everything works fine if it is.

Re: Zeiss headtracker input/trackIR output?

Posted: Mon Jun 10, 2013 2:57 am
by CyberVillain
Thanks will fix that when I get home, cant access github through the company proxy.
From the script you will access your tracker through a named called cinemizer, is that a ok name with you?

edit: Btw, is the polling thread implemented ok? Mostly the this part Im wondering about

Code: Select all

if (!(Api.WaitNextFrame())) Thread.Sleep(10);

Re: Zeiss headtracker input/trackIR output?

Posted: Mon Jun 10, 2013 3:16 am
by InrealMike
sure, the name cinemizer is fine. I think more people will know what is meant by "cinemizer", than something like "inreal".

I just realized, checking if a headtracker is connected during initialization is not really necessary, since the SDK will just wait anyways if no Tracker is connected, and start working correctly as soon as it finds one. So basically The "CheckForTracker" stuff could also be removed. Unless you think it makes more sense to alert the user, that no tracker is connected.

I was also wondering about this part:

Code: Select all

if (!(Api.WaitNextFrame())) Thread.Sleep(10);
I will have a closer look at this and get back to you.

Re: Zeiss headtracker input/trackIR output?

Posted: Mon Jun 10, 2013 3:28 am
by InrealMike
I checked back with one of the software engineers;

Code: Select all

if (!(Api.WaitNextFrame())) Thread.Sleep(10);
should be changed to

Code: Select all

if (!Api.WaitNextFrame()) continue;
Since the function itself already has a timeout of 100ms.

The rest of the code could be done a bit "cleaner", but it definitely is ok and works.
I myself am an Hardware-engineer, so writing nice code is not my greatest strength :)

Re: Zeiss headtracker input/trackIR output?

Posted: Mon Jun 10, 2013 3:30 am
by CyberVillain
InrealMike wrote:sure, the name cinemizer is fine. I think more people will know what is meant by "cinemizer", than something like "inreal".

I just realized, checking if a headtracker is connected during initialization is not really necessary, since the SDK will just wait anyways if no Tracker is connected, and start working correctly as soon as it finds one. So basically The "CheckForTracker" stuff could also be removed. Unless you think it makes more sense to alert the user, that no tracker is connected.

I was also wondering about this part:

Code: Select all

if (!(Api.WaitNextFrame())) Thread.Sleep(10);
I will have a closer look at this and get back to you.
Yeah, thats true, I can leave that out then so that it support connecting the tracker while running FreePIE.

about the Api.WaitNextFrame code I took that piece of code from the C# sample in the SDK

edit: aha, so Inreal is the company behind the tracker? Will the Api work with other trackers than whats inside the Carl Zeiss Cinemizer?

Re: Zeiss headtracker input/trackIR output?

Posted: Mon Jun 10, 2013 3:39 am
by InrealMike
CyberVillain wrote: edit: aha, so Inreal is the company behind the tracker? Will the Api work with other trackers than whats inside the Carl Zeiss Cinemizer?
Yes, that's correct. It was developed by Inreal. There are some vague plans about releasing a non "cinemizer-specific" or generic Tracker. But nothing concrete at the moment. We'll have to see how the cinemizer Tracker works out and if there is enough demand for a generic one. If we do, the API will be quite similar.

Re: Zeiss headtracker input/trackIR output?

Posted: Mon Jun 10, 2013 4:09 am
by CyberVillain
InrealMike wrote:
CyberVillain wrote: edit: aha, so Inreal is the company behind the tracker? Will the Api work with other trackers than whats inside the Carl Zeiss Cinemizer?
Yes, that's correct. It was developed by Inreal. There are some vague plans about releasing a non "cinemizer-specific" or generic Tracker. But nothing concrete at the moment. We'll have to see how the cinemizer Tracker works out and if there is enough demand for a generic one. If we do, the API will be quite similar.
If you do we will gladly support it!

Re: Zeiss headtracker input/trackIR output?

Posted: Mon Jun 10, 2013 12:55 pm
by Mars
Hi guys,

Been busy enjoying the joys of 1:1 headtracking and 3D (actually having to move your head to look behind you is really a very slow process, TrackIR is really a cheat ;-)).

Only problem I've encountered, and which InrealMike may be able to shed some light on, is that the tracker will sometimes initiate (even if its in the same position as the last time it initated correctly) with the yaw centre reported by the tracker will be offset 90 deg to what it should be i.e. 0 for directly ahead.

This screws the freePie script as larger or inverted angles get fed to the game through the TrackIR interface. This problem only started happening yesterday so was not apparent when I posted the script above. Is it possible to send the tracker a reorientate command through FreePIE?

Re: Zeiss headtracker input/trackIR output?

Posted: Tue Jun 11, 2013 3:35 am
by InrealMike
Hey Mars,

That seems strange to me. The tracker only initiates and calibrates once, after it gets power from the USB.
Never during operation a re-initialization takes place. After that it delivers absolute coordinates.

I suspect some kind of math error. I havent looked into the TrackIR interface or what kind of values it suspects. Are there any specs on that?

Re: Zeiss headtracker input/trackIR output?

Posted: Tue Jun 11, 2013 4:50 am
by CyberVillain
Its somewhat up to the games, most games support -90 to +90 degrees
where 0 is center, -90 left and +90 right

Some games support -180 to +180

Re: Zeiss headtracker input/trackIR output?

Posted: Tue Jun 11, 2013 3:26 pm
by Mars
As on 99% of occasions, problem was behind the keyboard. The suspected maths error was correct:

Code: Select all

def update(): 
   global yaw 
   yaw = math.degrees(zeiss.Yaw)
   global pitch 
   pitch = math.degrees(zeiss.Pitch) * ratio
   global roll 
   roll = math.degrees(zeiss.Roll) * ratio
   
if starting:
   maxAngle = 180
   axisRange = 360
   ratio = axisRange / maxAngle
   centerYaw = 0
   centerPitch = 0
   centerRoll = 0 
   yaw = 0
   pitch = 0
   roll = 0
   zeiss.update += update   

TIRyaw =  yaw - centerYaw
if TIRyaw > 180:
 TIRyaw = -(360-TIRyaw)
if TIRyaw < -180:
 TIRyaw = -360-TIRyaw 
  
TIRpitch = pitch - centerPitch
TIRroll = roll - centerRoll

trackIR.yaw = -TIRyaw
trackIR.pitch = TIRpitch
trackIR.roll = TIRroll
if TIRyaw > 90 or TIRyaw < -90:
 trackIR.x = -TIRroll
else:
 trackIR.x = TIRroll

diagnostics.watch(zeiss.Yaw)
diagnostics.watch(zeiss.Pitch)
diagnostics.watch(zeiss.Roll)
diagnostics.watch(ratio)
diagnostics.watch(yaw)
diagnostics.watch(pitch)
diagnostics.watch(roll)
diagnostics.watch(centerYaw)
diagnostics.watch(centerPitch)
diagnostics.watch(centerRoll)
diagnostics.watch(TIRyaw)
diagnostics.watch(TIRpitch)
diagnostics.watch(TIRroll)

if (keyboard.getPressed(Key.Y)):
 centerYaw = math.degrees(zeiss.Yaw)
 centerPitch = math.degrees(zeiss.Pitch)
 centerRoll = math.degrees(zeiss.Roll)
Maths was never my best subject!

Re: Zeiss headtracker input/trackIR output?

Posted: Wed Jun 19, 2013 12:30 am
by InrealMike
Hey Mars,

great that you got it to work! So my intuition was right :)
I haven't had time to test it with a game yet. I'll try to get around doing that this week...

Re: Zeiss headtracker input/trackIR output?

Posted: Tue Aug 20, 2013 3:57 pm
by Mars
Still having trouble with the script where after some time, (approx 15-30 minutes) and repeated recentering, the yaw will go screwy, jumping from for e.g. -57 to 201.

Can anyone suggest a better method?

Freepie script in its current form:

Code: Select all

def update(): 
   global yaw 
   yaw = cinemizer.yaw 
   global pitch 
   pitch = math.degrees(cinemizer.pitch) * ratio
   global roll 
   roll = math.degrees(cinemizer.roll) * ratio
   mouse.deltaX = filters.deadband(joystick[0].sliders[1], deadZone) / deltaFactor # Map mouse x to G940 ministick
   mouse.deltaY = filters.deadband(joystick[0].sliders[0], deadZone) / deltaFactor # Map mouse y to G940 ministick
   
if starting:
   deadZone = 200
   deltaFactor = 500
   maxAngle = 180
   axisRange = 360
   ratio = axisRange / maxAngle
   centerYaw = 0
   centerPitch = 0
   centerRoll = 0 
   yaw = 0
   pitch = 0
   roll = 0
   cinemizer.update += update   

TIRyaw =  math.degrees(yaw - centerYaw)
if TIRyaw > 180:
 TIRyaw = -(360-TIRyaw)
if TIRyaw < -180:
 TIRyaw = -360-TIRyaw 
  
TIRyaw = TIRyaw / ratio  
TIRpitch = pitch - centerPitch
TIRroll = roll - centerRoll

trackIR.yaw = -TIRyaw
trackIR.pitch = TIRpitch
trackIR.roll = TIRroll

#couples side to side movement to Cinemizer roll / fake lateral positional tracking
if TIRyaw > 90 or TIRyaw < -90: 
 trackIR.x = -TIRroll
else:
 trackIR.x = TIRroll

diagnostics.watch(cinemizer.yaw)
diagnostics.watch(cinemizer.pitch)
diagnostics.watch(cinemizer.roll)
diagnostics.watch(ratio)
diagnostics.watch(yaw)
diagnostics.watch(pitch)
diagnostics.watch(roll)
diagnostics.watch(centerYaw)
diagnostics.watch(centerPitch)
diagnostics.watch(centerRoll)
diagnostics.watch(TIRyaw)
diagnostics.watch(TIRpitch)
diagnostics.watch(TIRroll)
diagnostics.watch(mouse.deltaX)
diagnostics.watch(mouse.deltaY)

if (keyboard.getPressed(Key.Y)):
 centerYaw = cinemizer.yaw
 centerPitch = cinemizer.pitch
 centerRoll = cinemizer.roll

Re: Zeiss headtracker input/trackIR output?

Posted: Fri Aug 30, 2013 2:21 pm
by Mars
Yipeee!!!

Finally fixed the yaw center going bananas. After some googling, turns out I needed the following:

Code: Select all

TIRyaw =  math.degrees(yaw - centerYaw)
TIRyaw = TIRyaw + (TIRyaw<0)*360
if TIRyaw > 180:
 TIRyaw = -(360 - TIRyaw)

Re: Zeiss headtracker input/trackIR output?

Posted: Fri Aug 30, 2013 5:01 pm
by CyberVillain
ah. continues rotation :D

You could achive the same doing

Code: Select all

TIRyaw =  math.degrees(filters.continousRotation(yaw - centerYaw))

Re: Zeiss headtracker input/trackIR output?

Posted: Sat Aug 31, 2013 12:09 pm
by Mars
LOL I shall try that! It's been driving me nuts!

Now I just need to get Il-2 1946 to see the Cinemizer Headtracking to TrackIR output. Works fine in ROF but not Il-2. As far as I can remember il-2 1946 was not using the encrypted TIR interface as it was one of the first TrackiR enhanced games (used to to have a TrackIR v1). Using FacetracknoIR, I need to use the dummy trackIR exe option for it work, is that part of the problem?

Edit: Read the FSX post after posting my reply. Shall try the renaming freepie.exe to trackIR.exe trick.

Re: Zeiss headtracker input/trackIR output?

Posted: Tue Sep 10, 2013 3:22 pm
by Mars
Finally got around to trying the cinemizer headtracker with Il-2 1946. Doesn't work even with the rename freepie.exe trick. Works in the other early TIR supporting game I have (Battle of Britain 2). Not sure whats going on here. Checked the registry to check that the NPclient.dll path was being set correctly to the freepie folder and it is.

TrackIRfixer does not show il-2 as one of the encrypted games, as it should being one of the earliest TIR supporting games.

Re: Zeiss headtracker input/trackIR output?

Posted: Wed Sep 11, 2013 12:24 am
by CyberVillain
Have you tried with Freetrack or Glovepie to confirm that it's a freepie problem only?

Re: Zeiss headtracker input/trackIR output?

Posted: Wed Sep 11, 2013 1:19 pm
by Mars
Works fine with FacetrackNoIR 1.7 using the freetrack tracker

Re: Zeiss headtracker input/trackIR output?

Posted: Thu Sep 12, 2013 11:10 am
by CyberVillain
Can you please enable loggin in the plugin setting and paste the log here?

Re: Zeiss headtracker input/trackIR output?

Posted: Thu Sep 12, 2013 2:21 pm
by Mars
I cleared the log out before I ran Il-2 as I had enabled it previously when running ROF. Log was still empty after running Il-2. As a check I then ran il-2 using FTNIR and TIR 6dof tracking worked. I then ran ROF and data was recorded in the log again.

Il-2 is not even seeing freepies emulated TIR output it seems.

Re: Zeiss headtracker input/trackIR output?

Posted: Thu Sep 12, 2013 4:03 pm
by CyberVillain
Looks like its not loading the correct dll then.. Whats the games full title? I can download it and test

Re: Zeiss headtracker input/trackIR output?

Posted: Fri Sep 13, 2013 12:23 am
by Mars
il-2 Sturmovik 1946 patched to 4.11m (added support for TIR 6dof).

Re: Zeiss headtracker input/trackIR output?

Posted: Fri Sep 13, 2013 12:54 am
by CyberVillain
Mars wrote:il-2 Sturmovik 1946 patched to 4.11m (added support for TIR 6dof).
ah okey so there is no Demo i can test? :/
Only tip i can give right now is to figure out why its not loading the dll in the FreePIE folder

Re: Zeiss headtracker input/trackIR output?

Posted: Sun Sep 15, 2013 10:41 am
by Mars
Found a workaround but you won't like it ;) :

Headtracker > FreePIE > Freetrack > GlovePIE > TrackIR

Re: Zeiss headtracker input/trackIR output?

Posted: Mon Sep 16, 2013 1:07 am
by CyberVillain
Mars wrote:Found a workaround but you won't like it ;) :

Headtracker > FreePIE > Freetrack > GlovePIE > TrackIR
I would really like to know why the game does not try to use the FreePIE npclient.dll
I know that glovepie starts a exe called trackir.exe

Maybe the game does not just look on the exe filename but its size or something, can you try start that exe manually, run freepie and the script with TrackIR logging. Check if anyhting ends up in the log. Oh and yeah, check the registry that it points to the FreePIE dll

Re: Zeiss headtracker input/trackIR output?

Posted: Mon Sep 16, 2013 3:25 pm
by Mars
GlovePIE does not have a fake trackir.exe, FTNIR does but not the version of GlovePIE i'm using (v0.43).

I tried using FTNIR's dummy exe but that will not run unless FTNIR is already running.