I've been trying recently to setup my Opendive HMD to work with freetrack/ trackIR via Freepie.
So I found out that I have to use the .googleYaw, .googlePitch if I want to use the phone in the HMD for tracking. Ok, no problem.
Then I found out I have a Samsung phone. S3. So... big problems ahead. The .google readouts are extremely noisy even when the phone is resting, have inertia and worst of all bounce back after fast movements.
Utilising my leet programming skills (hint: none whatsoever) I managed to put together a 3-level filering "technique" that kinda works. It uses filters.simple. A LOT. Here goes:
Code: Select all
def update():
global yaw
yaw = -filters.simple((android[0].googleYaw), 0.75)/3
global pitch
pitch = -filters.simple((android[0].googleRoll), 0.5)/3
global lastYaw
global lastPitch
global yawShift
global pitchShift
global DeadBand
global FilterType
if (abs(filters.delta(yaw)) > DeadBand):
yawShift = yaw
lastYaw = filters.mapRange(abs(filters.delta(yawShift)), 0, 0.005, 0, 1)
FilterType = 1
else:
if (filters.delta(lastYaw) == 0):
if ((abs(abs(yawShift)-abs(yaw))) > DeadBand_max):
yawShift = yaw
lastYaw = 0.01
FilterType = 2
else:
lastYaw = 0.001
FilterType = 3
if (lastYaw > 1):
lastYaw = 1
if (abs(filters.delta(pitch)) > DeadBand):
pitchShift = pitch
lastPitch = filters.mapRange(abs(filters.delta(pitchShift)), 0, 0.005, 0, 1)
else:
if (filters.delta(lastPitch) == 0):
if ((abs(abs(pitchShift)-abs(pitch))) > DeadBand_max):
pitchShift = pitch
lastPitch = 0.01
else:
lastPitch = 0.001
FilterType = 3
if (lastPitch > 1):
lastPitch = 1
if starting:
centerYaw = 0
centerPitch = 0
DeadBand = 0.001
DeadBand_max = 0.001
yaw = 0
pitch = 0
yawShift = 0
pitchShift = 0
yawDiff = 0
pitchDiff = 0
lastYaw = 0
lastPitch = 0
FilterType = 0
android[0].update += update
freeTrack.yaw = filters.simple(yawShift, (1 - lastYaw)) - centerYaw
freeTrack.pitch = filters.simple(pitchShift, (1 - lastPitch)) - centerPitch
if keyboard.getKeyDown(Key.LeftControl) and keyboard.getPressed(Key.C):
centerYaw = yaw
centerPitch = pitch
centerRoll = roll
I tried reading about this Kalman filtering technique. I'm no programmer or math expert, so it took only a couple of sentences to make my head hurt. So I went with the above brute "simple" method instead. But as you imagine, the effect is not perfect - too slow due to excessive filtering.
So the question is: are you planning to implement better filtering techniques in freePIE? One that would possibly look like filters.Kalman(input, filter value)? or is that not that simple?
I read here that you are using Kalman to filter the other readout method (not raw data), is that possible to filter single values the same way?