It is currently Mon Apr 22, 2019 12:22 am



Reply to topic  [ 8 posts ] 
 Andorid>Mouse script aleatory jumps! :S 
Author Message
Cross Eyed!
User avatar

Joined: Thu May 16, 2013 1:02 am
Posts: 108
Reply with quote
Hi, i'm using a script to emulate the mouse with the android sensors, it works really well, but it makes jumps in some aleatory positions(I think is aleatory beacuse it changes every time i close freepie, or it depends on how close is the cursor from the end of the desktop at the moment the program start runing or somethin like that), that happen when you try to rotate or looking too up/down (even if you only rotate a few, it works better with the phone turned back)

This is the script:
Code:
def update():
   yaw = -android.googleYaw
   pitch = android.googlePitch
   
   deltaYaw = filters.delta(yaw)
   deltaPitch = filters.delta(pitch)   
   
   mouse.deltaX = deltaYaw*multiply
   mouse.deltaY = deltaPitch*multiply

if starting:
   multiply = 200
   android.update += update


Any ideas of what is causing this?, because other than that the script is really good, I get a better tracking than other scripts as freetrack or vireioSMT (the latter works great too, but loses calibration and have some latency).


Thu May 23, 2013 3:56 pm
Profile
Cross Eyed!
User avatar

Joined: Thu May 16, 2013 1:02 am
Posts: 108
Reply with quote
anyone? :(


Tue May 28, 2013 9:00 am
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2160
Location: Stockholm, Sweden
Reply with quote
If it was only yaw then I would say the problem is when the compass goes from +180 to -180 the delta value sent to mouse will be huge at this point. But you say its also a problem with pitch? Same problem both with Google yaw and yaw?

_________________
FreePIE
My blog


Tue May 28, 2013 9:36 am
Profile
Cross Eyed!
User avatar

Joined: Thu May 16, 2013 1:02 am
Posts: 108
Reply with quote
I don't know for sure if the pitch jumps too, it simly does something strange on the edges, but not that aleatory jumps which unables me to turn around in yaw. I only can use the google yaw, for some reason if I use only yaw etc I never get good results, the last time i tested with only yaw,pitch and roll (without google) the pitch and roll fusion their valors, i mean, if i move the smartphone for pitch it change a bit the roll valor too :S


Tue May 28, 2013 10:11 am
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2160
Location: Stockholm, Sweden
Reply with quote
Please check if the jump happens at the magnetic north only. I helped another user with this problem, but cant find that script.
If it only happens when passing the magnetic north its becasue the value goes from +180 to -180 the delta value sent into the mouse emulation will then be 360 degress making it jump

edit: look here viewtopic.php?f=139&t=16286&p=104765&hilit=delta#p99613

_________________
FreePIE
My blog


Tue May 28, 2013 4:57 pm
Profile
Cross Eyed!
User avatar

Joined: Thu May 16, 2013 1:02 am
Posts: 108
Reply with quote
seems to be the solution, but i get "expected an indented block" with this:

Quote:
def update():
global yaw
global roll
global pitch
yaw = android.googleYaw + math.pi
roll = android.googleRoll
pitch = android.googlePitch


if starting:
yaw = 0
roll = 0
pitch = 0
enabled = False
android.update += update

deltaYaw = filters.delta(yaw)
deltaPitch = filters.delta(pitch)
deltaRoll = filters.delta(roll)

if math.fabs(deltaYaw) >= math.pi:
deltaYaw = 0

if (enabled):
mouse.deltaX = -deltaYaw*600
mouse.deltaY = -deltaRoll*1000


toggle = keyboard.getPressed(Key.Z)

if toggle:
enabled = not enabled


Tue May 28, 2013 5:28 pm
Profile
Petrif-Eyed

Joined: Mon Jun 22, 2009 8:36 am
Posts: 2160
Location: Stockholm, Sweden
Reply with quote
Python is picky about indention you need to keep the tabs for it to work

Code:
def update():
   global yaw
   global roll
   global pitch
   yaw = android.googleYaw + math.pi
   roll = android.googleRoll
   pitch = android.googlePitch


if starting:
   yaw = 0
   roll = 0
   pitch = 0
   enabled = False
   android.update += update

deltaYaw = filters.delta(yaw)
deltaPitch = filters.delta(pitch)
deltaRoll = filters.delta(roll)

if math.fabs(deltaYaw) >= math.pi:
   deltaYaw = 0

if (enabled):
   mouse.deltaX = -deltaYaw*600
   mouse.deltaY = -deltaRoll*1000


toggle = keyboard.getPressed(Key.Z)

if toggle:
   enabled = not enabled

_________________
FreePIE
My blog


Wed May 29, 2013 2:30 am
Profile
Cross Eyed!
User avatar

Joined: Thu May 16, 2013 1:02 am
Posts: 108
Reply with quote
Thanks! that works really well, now i changed it to use te pitch as "Y" and added a line for use the roll with vireio shared memory, now i have a realy good script, with this i had a very functional head tracking for my future DIY rift (it has very low lag, not perfect but very good latency) with my smartphone, thanks a lot for all, you do a huge work for this community :)


Wed May 29, 2013 4:55 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 8 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by STSoftware.