I was trying to make headtracking with a psmove controller.
Of course there are some apps which seems to be working in that way, but they are limited to positional data via light bulb and ps eye camera. And I needed rotational data.
Also Freepie has feature to convert data to freetrack, but for some reason not all apps I've seen reads it (driver4vr for example). Also it's hard to tune for a newbies and has no filters, etc.
So I was searching for a way to send it to opentrack instead.
First I asked chatgpt to write me a script, but it was only half working (still it's awesome - it helped me to understand code a little bit).
Then I've found a post on that forum by Me4huk who posted a script for trackir, I edited it a little bit, tested with opentrack's UDP over network and voila - it's working.
I don't have a ps eye camera, so psmove sends only rotational data, but looks like positional data will also work.
In opentrack it's possible to use fusion input, so it's available to mix it with aruco, neuralnet and other sources.
In order to use it you will need psmove service(or psmoveserviceEX) and psmovefreepiebridge running.
In opentrack choose UDP over network input (or fusion with same setting).
If some axis doesn't work upon starting push recenter button.
I hope it helps somebody
Code: Select all
# based on code for trackir posted by Me4huk. edited by VerdeMsk
import socket
import struct
def update():
#numbers in brackets are multipliers. change them if there are too much or not enough rotation/position.
##could be also tuned in opentrack, but for some apps whitch reads only raw data tune it with these numbers instead.
#also you can swap all axis according to mounting of your psmove controller.
#roll is disabled initially, because I don't think it's useful. delete # if you need this axis to work.
yaw = (-freePieIO[0].yaw * 120)
pitch = (freePieIO[0].pitch * 120)
#roll = (freePieIO[0].roll * 1)
#x = (freePieIO[0].x * 10)
#y = (freePieIO[0].y * 10)
#z = (freePieIO[0].z * 10)
#if keyboard.getKeyDown(Key.C): y = 200
#else: y = freePieIO[0].y
#4242 in brackets is a number in opentrack's UDP over network port setting.
opentrack_UDPsender.sendto(struct.pack("dddddd", x, y, z, yaw, pitch, roll), ("localhost", 4242))
#SendOsc('localhost', 6666, "/glovepie/pithon", yaw, pitch, roll, x, y, z)
diagnostics.watch(yaw)
diagnostics.watch(pitch)
diagnostics.watch(roll)
diagnostics.watch(freePieIO[0].yaw)
diagnostics.watch(freePieIO[0].pitch)
diagnostics.watch(freePieIO[0].roll)
diagnostics.watch(x)
diagnostics.watch(y)
diagnostics.watch(z)
if starting:
global yaw, pitch, roll, x, y, z
x , y , z , yaw , pitch , roll = 0,0,0,0,0,0
opentrack_UDPsender = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
freePieIO[0].update += update