Help with FreePIE script [deltaX for joystick]

Official forum for open source FreePIE discussion and development.
Post Reply
SilverGen447
One Eyed Hopeful
Posts: 1
Joined: Fri May 12, 2017 12:13 pm

Help with FreePIE script [deltaX for joystick]

Post by SilverGen447 »

So I originally made this post because I did not see filter.delta() in the reference or scripts and could not figure out it existed. Seeing as I cannot delete the post, I may as well make it useful.
If any mod is reading this, feel free to delete this if it has already been used. Otherwise, I would like help improving a code for Table top simulator.

PSA for anyone else who is brand new to FreePIE, filter.delta() is a thing.

I am using Freetrack with a wii remote for the IR led tracking on a vr head set, trying to get 5-6 DOF to smoothly work, and have a basic script written up.

Code: Select all

def update():
	yaw = filters.mapRange(trackIR.yaw, -90, 90, -vJoy[0].axisMax, vJoy[0].axisMax)
	pitch = filters.mapRange(trackIR.pitch, -90, 90, -vJoy[0].axisMax, vJoy[0].axisMax)
	roll = filters.mapRange(trackIR.roll, -90, 90, -vJoy[0].axisMax, vJoy[0].axisMax)
	xVal = filters.mapRange(trackIR.x, -90, 90, -vJoy[0].axisMax, vJoy[0].axisMax)
	yVal = filters.mapRange(trackIR.y, -90, 90, -vJoy[0].axisMax, vJoy[0].axisMax)
	zVal = filters.mapRange(trackIR.z, -90, 90, -vJoy[0].axisMax, vJoy[0].axisMax)
	vJoy[0].rx = filters.delta(yaw*100)
	vJoy[0].ry = filters.delta(pitch*100)
	vJoy[0].rz = filters.delta(roll*100)
	vJoy[0].x = filters.delta(xVal*100)
	vJoy[0].y = filters.delta(yVal*100)
	vJoy[0].z = filters.delta(zVal*100)
	diagnostics.watch(vJoy[0].x)
	diagnostics.watch(vJoy[0].y)
	diagnostics.watch(vJoy[0].z)
	diagnostics.watch(vJoy[0].rx)
	diagnostics.watch(vJoy[0].ry)
	diagnostics.watch(vJoy[0].rz)
	
if starting:
	trackIR.update += update
If possible, I would like help improving it, particularly smoothing out the motion (I have been editing the setting in FreeTrack, but maybe there is something a little more coding oriented.) There also seems to be a weird glitch where the axis x continuously moves right then I move back and forth in either direction.

Edit: I'm considering using the position readout again, but writing a script to move a virtual dot towards the position with the joystick at a certain rate until it is within the position given by FreeTrack, hopefully eliminating the drift issue. I've checked the script, FreeTrack, and the values and apparently the drift has no obvious cause. It will cause some input lag, but it might be worth it. Please let me know if it's been done before. This should make it smoother as well
Post Reply

Return to “FreePIE”