Gimbal Lock, Pause Roll/Yaw when device is held 80-90° up

Official forum for open source FreePIE discussion and development.
Post Reply
moukrea
One Eyed Hopeful
Posts: 13
Joined: Wed Jan 20, 2016 4:28 am

Gimbal Lock, Pause Roll/Yaw when device is held 80-90° up

Post by moukrea »

Hi! I've got an issue with my TrackIR (emulated from Android) to Shared Memory Tracker script... I experience "Gimbal lock" when I held my device 90° up or down (Looking at the sky/feet) I guess it's not a big deal, but I'd like to avoid it.

To do so, I was thinking about "pausing" Roll & Yaw when the device goes above 80° up or down, then start again when it goes lower than 80°.

Here's the script I use:

Code: Select all

def update():
	global Yaw
	global Pitch
	global Roll
	global Xaxis
	global Yaxis
	global Zaxis
	
	Yaw = -trackIR.yaw / 55.0
	Pitch = trackIR.pitch / 55.0
	Roll = trackIR.roll / 120.0
	Xaxis = trackIR.x / 5.0
	Yaxis = trackIR.y / 5.0
	Zaxis = trackIR.z / 5.0
	
	vireioSMT.yaw  = Yaw - centerYaw
	vireioSMT.pitch = Pitch - centerPitch
	vireioSMT.roll = Roll - centerRoll
	vireioSMT.x = Xaxis - centerXaxis
	vireioSMT.y = Yaxis - centerYaxis
	vireioSMT.z = Zaxis - centerZaxis
	
if	starting:
    centerYaw = 0 
    centerPitch = 0
    centerRoll = 0
    centerXaxis = 0
    centerYaxis = 0
    centerZaxis = 0 
    Yaw = 0
    Pitch = 0
    Roll = 0
    Xaxis = 0
    Yaxis = 0
    Zaxis = 0
    trackIR.update += update

if	keyboard.getPressed(Key.K):
	centerYaw = Yaw 
	centerPitch = Pitch
	centerRoll = Roll
	centerXaxis = Xaxis
	centerYaxis = Yaxis
	centerZaxis = Zaxis
I was thinking of something like:

Code: Select all

if	trackIR.pitch > 80:
	Roll = Pause
	Yaw = Pause

if	trackIR.pitch < -80:
	Roll = Pause
	Yaw = Pause
Of course , it gives me the error "name "Pause" is not defined"

I though about using "centerRoll" and "centerYaw" which works, but is kinda messed up when going back to original position. So what I'd like to do is to freeze Yaw & Roll when looking above 80° up and down, then start sensing back these two imputs when going in-between 80/-80°...

Any ideas? Thanks a lot
konstantin_lozev
Cross Eyed!
Posts: 192
Joined: Fri Jul 04, 2014 1:43 am

Re: Gimbal Lock, Pause Roll/Yaw when device is held 80-90° u

Post by konstantin_lozev »

Not sure what you want to achieve actually with that "Pause"...
Can you not do:

Code: Select all

if trackIR.pitch > 80:
	Pitch = trackIR.pitch/55.0
On Gymbal lock - is it coming from the trackIR values? I think you could try and fix that by going with FreePIE directly and using relative changes, e.g. from the raw gyro readings.
moukrea
One Eyed Hopeful
Posts: 13
Joined: Wed Jan 20, 2016 4:28 am

Re: Gimbal Lock, Pause Roll/Yaw when device is held 80-90° u

Post by moukrea »

What I would like to do there is to stop listening Yaw and Roll when the device Pitch (android or DIY sensor, emulating TrackIR) is above 80° or bellow -80°

Meaning there won't be any rotation (Yaw and Roll) possible in this conditions, avoiding values to get crazy and move the camera in all directions

Then, start listen again to Yaw and Roll while Pitch is between +80/-80

I tried something like this (I know this is silly, among other tries... nothing worked anyway)

Code: Select all

enabledYaw = Yaw
enabledRoll = Roll
	
if  trackIR.pitch > 80:
	enabledYaw = not enabledYaw
	enabledRoll = not enabledRoll
I kinda get now ideas on to solve this... I though it would be easy to "pause" one or two imput under the condition of another one
Post Reply

Return to “FreePIE”