Nexus 7 Freepie Script

Official forum for open source FreePIE discussion and development.
Vunk
One Eyed Hopeful
Posts: 8
Joined: Wed Jan 30, 2013 12:49 pm

Nexus 7 Freepie Script

Post by Vunk »

Hi
Im completely new to hmds etc but have been inspired by the oculus rift which look amazing and have been reading the forum for a while. I am trying to bulid my first hmd based on the excellent tutorial by Rod Furlan. While waiting for my lenses to arrive I decided to try to get the basics working on my nexus 7. I will hopefully upgrade to a lcd hdmi panel in the near future as I have found a great uk supplier with a resolution up to 1920x1080, 60-72 hz refresh rate and 6ms response rate, the downside is the weight. I have splashtop 2 and tridef working well but im stuggling with freepie. I have the android app installed and the pc streamer but the scripts im using dont seem to be working that well. I have tried to modify the script but im having a hard time getting the nexus 7 headtracking working with the screen facing me as needed in my setup. It works to an extent with the nexus 7 being held like a tv remote. I have noticed that Parity has made a great version of what im trying to make and his freepie script looks perfect in his demo youtube video. Any help would be much appreciated, thanks.
User avatar
Parity
Two Eyed Hopeful
Posts: 56
Joined: Mon Oct 01, 2012 12:55 pm

Re: Nexus 7 Freepie Script

Post by Parity »

Hey.

My script is acutally very simple. Key point is the correct and successful sensor-fusion.
I got my Nexus working that way with great support from the users "mahler" and "CyberVillain".

You will need the FreePIE application for your Nexus that supports rotation-vector-analysis.
CyberVillain uploaded this one: http://www.mtbs3d.com/phpBB/download/file.php?id=1742

Using that and FreePIE on the PC, the script can be very simple like:

Code: Select all

delta_yaw = filters:delta(android.GoogleYaw)
delta_roll = filters:delta(android.GoogleRoll)

mouse.DeltaX = delta_yaw*factorx
mouse.DeltaY = delta_roll*factory
I work with factorx=600 and factory=1000 but you can adjust that to your specific application.

You can also add an toggle to be able to keep control over your PC :)

Code: Select all

delta_yaw = filters:delta(android.GoogleYaw)
delta_roll = filters:delta(android.GoogleRoll)

if(keyboard:getPressed(Key.L)) then
   enabled = not enabled
end

if enabled then
mouse.DeltaX = delta_yaw*factorx
mouse.DeltaY = delta_roll*factory
end
Hope that helps, feedback is appreciated.
The FullHD-panel, you mentioned: What is the size of it? larger than 7" will not be suitable for a HMD, as no lenses will be able to warp all the pixels into your FOV...

Parity
Vunk
One Eyed Hopeful
Posts: 8
Joined: Wed Jan 30, 2013 12:49 pm

Re: Nexus 7 Freepie Script

Post by Vunk »

Hi Parity
That is a great help :D , I will give it a try tonight and definitely let you know how I get on, it was driving me mad. The panel I mentioned is 7" so should be perfect but it is actually a HDMI monitor so the weight is 500-550grams. I'm not sure if it could be dismantled and just use the screen etc to save weight. They also do some other cheaper screens but this one looks the best, the link is http://smalllcd.co.uk/product_info.php? ... 711f5a1351

The contrast and brightness also looks great to me. They have emailed me a full spec if you would like it? My two main issues are cost and weight, at £200 am I better off just buying the rift developer kit? The 1080p screen is appealing though :D
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Nexus 7 Freepie Script

Post by CyberVillain »

Nice to hear that Google fusion is working good for you Parity, which Youtube clip are you talking about? Like to see it :D
User avatar
Parity
Two Eyed Hopeful
Posts: 56
Joined: Mon Oct 01, 2012 12:55 pm

Re: Nexus 7 Freepie Script

Post by Parity »

@Vunk: Watch out, that panel you linked there is only 1024x600 resolution. Don't buy it for a Rift-like-build. The device can handle 1920x1080 input signal, but that doesn't increase the pixels on the panel.

@Cybervillian

It may have to do with the device one is using. With the Nexus 7 I get the best results with google fusion and the FreePIE-apk using the rotation-vector you uploaded November 3rd. No other approach allowed me to use the tablet with the screen facing to me.

Video of the successful fusion (just simple vid, showing that it works very nice:

[youtube]http://www.youtube.com/watch?v=Ol1HqlJkNnA[/youtube][/quote]
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Nexus 7 Freepie Script

Post by CyberVillain »

Parity wrote:@Vunk: Watch out, that panel you linked there is only 1024x600 resolution. Don't buy it for a Rift-like-build. The device can handle 1920x1080 input signal, but that doesn't increase the pixels on the panel.

@Cybervillian

It may have to do with the device one is using. With the Nexus 7 I get the best results with google fusion and the FreePIE-apk using the rotation-vector you uploaded November 3rd. No other approach allowed me to use the tablet with the screen facing to me.

Video of the successful fusion (just simple vid, showing that it works very nice:

[youtube]http://www.youtube.com/watch?v=Ol1HqlJkNnA[/youtube]
[/quote]

Nice, latest build also uses still uses rotation vector, so should work with that too...
Vunk
One Eyed Hopeful
Posts: 8
Joined: Wed Jan 30, 2013 12:49 pm

Re: Nexus 7 Freepie Script

Post by Vunk »

Hi Parity
thanks for the warning, I didn't realise it wasn't native 1080p until you said :oops: The help you gave me with freepie was exactly what I needed and it is now working very well, especially with the PC plugged directly into the router. The latency seems really good. I need to upgrade my PC now as it can't take all these programs running together :D Thanks again.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Nexus 7 Freepie Script

Post by CyberVillain »

Parity wrote:

Code: Select all

delta_yaw = filters:delta(android.GoogleYaw)
delta_roll = filters:delta(android.GoogleRoll)

mouse.DeltaX = delta_yaw*factorx
mouse.DeltaY = delta_roll*factory
Just noticed that you must use a very old version of FreePIE Parity, we dropped LUA because of memory leaks 2-3 versions back :D

We now using Python instead
User avatar
Unclebob
Cross Eyed!
Posts: 173
Joined: Wed Mar 07, 2007 3:22 am
Location: Brighton UK

Re: Nexus 7 Freepie Script

Post by Unclebob »

A few unnecessary lines of code but this works and is relatively lag free using FREEPIE and a NEXUS7

def update():
yaw = android.googleYaw
roll = android.googleRoll
pitch = android.googlePitch

diagnostics.watch(yaw)
diagnostics.watch(roll)
diagnostics.watch(pitch)

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

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

if starting:
enabled = False
android.update += update

toggle = keyboard.getPressed(Key.Z)

if toggle:
enabled = not enabled

Change the RED figures to tweak for any game.

Hope this helps someone and thanks to all your work FREEPIE crowd. Works with a Nexus in stand up orientation. Tested on XP SP3 and 7 Pro.

Let me know how you get on

UB
UB

Don't try this at home folks....
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Nexus 7 Freepie Script

Post by CyberVillain »

Unclebob there are a few errors in that code so I fixed it up for you

Code: Select all

def update():
	global yaw
	global roll
	global pitch
	yaw = android.googleYaw
	roll = android.googleRoll
	pitch = android.googlePitch

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

diagnostics.watch(yaw)
diagnostics.watch(roll)
diagnostics.watch(pitch)

deltaYaw = filters.delta(yaw)
deltaPitch = filters.delta(pitch)
deltaRoll = filters.delta(roll)
   
if (enabled):
	mouse.deltaX = -deltaYaw*600
	mouse.deltaY = -deltaRoll*1000

toggle = keyboard.getPressed(Key.Z)

if toggle:
	enabled = not enabled
Also be sure to remove these lines when not testing

Code: Select all

diagnostics.watch(yaw)
diagnostics.watch(roll)
diagnostics.watch(pitch)
Because they will take some CPU
You do not have the required permissions to view the files attached to this post.
User avatar
Unclebob
Cross Eyed!
Posts: 173
Joined: Wed Mar 07, 2007 3:22 am
Location: Brighton UK

Re: Nexus 7 Freepie Script

Post by Unclebob »

Thanks Cyber

I got to mine through trail and error I am no coder just a tinker(er).

Very much appreciated.

Nice way to start a Sunday though. Pity I have a rugby international to watch this afternoon else I would be trying to get it work with Tridef or with Vireio.

Very cheap and easy DIY Rift if you have a 7 inch Android tablet

Game ==> Vireio or Tridef ==> Splashtop ==> Nexus in a box with 5cm lenses.

UB
UB

Don't try this at home folks....
Baristan6
Cross Eyed!
Posts: 111
Joined: Sat Dec 15, 2012 11:33 am

Re: Nexus 7 Freepie Script

Post by Baristan6 »

Just posted an early version of a Vireio/FreePie plugin in the Verio Perception forum if you are interested. http://www.mtbs3d.com/phpbb/viewtopic.p ... &start=120
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Nexus 7 Freepie Script

Post by CyberVillain »

@Baristan6, nice work!

A few notes, to make the plugin syntax more FreePIEish, you (Or the one that picks up the code) should move the sendData() method from the plugin global and call that from the DoBeforeNextExecute method of the plugin. Also change the setter Methods to setter Properties
Vunk
One Eyed Hopeful
Posts: 8
Joined: Wed Jan 30, 2013 12:49 pm

Re: Nexus 7 Freepie Script

Post by Vunk »

Thanks unclebob and cyber, that script is great :D I have my nexus 7 diy hmd working well now, portal is great fun and is very smooth via splash top. Now I am at the stage of actually playing games through it I have run into another little problem, if I turn my head to look behind me I get to a certain point and the view snaps to a different place. I have tried searching the forums and think it is to do with continuous yaw? It happens at the same point every time. I am using an Xbox controller so I can use that to turn as well but would love to be able to turn my head 360 is this possible? How would I add continuous yaw to the above script, I have tried but can't seem to get it working.

Thanks again.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Nexus 7 Freepie Script

Post by CyberVillain »

Yes, Google fusion is sending values from -3.14 to +3.14 (-180 to 180 deg). A quick fix would be to just do

Code: Select all

android.googleYaw + math.pi 
which will change the range from -3.14 - 3.14 to 0 - 6.28 (0 to 360 deg)

edit: Hmm that wont fix it though :D
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Nexus 7 Freepie Script

Post by CyberVillain »

CyberVillain wrote:Yes, Google fusion is sending values from -3.14 to +3.14 (-180 to 180 deg). A quick fix would be to just do

Code: Select all

android.googleYaw + math.pi 
which will change the range from -3.14 - 3.14 to 0 - 6.28 (0 to 360 deg)

edit: Hmm that wont fix it though :D
edit2: You need to implement ContinuesYaw since the android plugin is missing this feature.
Vunk
One Eyed Hopeful
Posts: 8
Joined: Wed Jan 30, 2013 12:49 pm

Re: Nexus 7 Freepie Script

Post by Vunk »

Thanks for getting back to me so quickly cyber. I tried the extra code you sent and you were right it didn't stop it happening. Can you give me any advice how to add continuous yaw or is it something that will get added to the android plugin in the future. You are a great help thanks.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Nexus 7 Freepie Script

Post by CyberVillain »

Vunk wrote:Thanks for getting back to me so quickly cyber. I tried the extra code you sent and you were right it didn't stop it happening. Can you give me any advice how to add continuous yaw or is it something that will get added to the android plugin in the future. You are a great help thanks.

The problem is that when it goes from 0 to 360 (or 360 to 0) it gets a huge delta that you send to the mouse plugin

Check if the delta is bigger than math.pi if it is substract math.pi, I think :D
I have to test it when I get home from work
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Nexus 7 Freepie Script

Post by CyberVillain »

There probably is a more elegant way of doing this, but this works for me atleast

Code: Select all

yaw = android.googleYaw + math.pi
deltaYaw = -filters.delta(yaw)

if math.fabs(deltaYaw) >= math.pi:
	deltaYaw = 0
Change your code to use this yaw delta value
Vunk
One Eyed Hopeful
Posts: 8
Joined: Wed Jan 30, 2013 12:49 pm

Re: Nexus 7 Freepie Script

Post by Vunk »

Thanks cyber :D
I have tried to put the new bits of code into the previous script but there does not seem to be any change, im sure its just me as im new to all of this. The script im using is:

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 (enabled):
mouse.deltaX = -deltaYaw*600
mouse.deltaY = -deltaRoll*1000


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

toggle = keyboard.getPressed(Key.Z)

if toggle:
enabled = not enabled


Thanks.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Nexus 7 Freepie Script

Post by CyberVillain »

you are doing

Code: Select all

if math.fabs(deltaYaw) >= math.pi:
deltaYaw = 0
too late, it must be done before assign the values to the mouse
Vunk
One Eyed Hopeful
Posts: 8
Joined: Wed Jan 30, 2013 12:49 pm

Re: Nexus 7 Freepie Script

Post by Vunk »

Thanks Cyber its now working perfectly with full 360 view, your a credit to the mtbs3d board :D
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Nexus 7 Freepie Script

Post by CyberVillain »

Thanks man, I'm just glad that someone is using FreePIE :D
PinkTyGRR
One Eyed Hopeful
Posts: 12
Joined: Tue Feb 12, 2013 2:54 pm

Re: Nexus 7 Freepie Script

Post by PinkTyGRR »

I've been reading through the freepie forums and am exited to try it out. problem is ive been scouring this forum for hours trying to fix something im sure is very simple but cant figure out. I have freepie, freetrack, and the freepie app for android installed and tried running this script

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

on the freepie app I have the target ip and target ports filled in, ticked send orientation (ive tried send raw data and both ticked as well) and every mode, ui, game, fastest, but nothing happens when i run the script and turn the app on. It doesnt seem to send anything to track ir either, although i cant tell if freetrack is needed at all in this script. any help would be much appreciated.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Nexus 7 Freepie Script

Post by CyberVillain »

HI PinkTyGRR,always start simple :D
What does this script output?

diagnostics.watch(android.googleYaw)

In the watch window?

Your above code is for mouse but you talk about Freetrack / Trackir?

When you have verified Android input with the above code please try

Code: Select all

def update():
	global yaw
	yaw = android.googleYaw
	global pitch
	pitch = android.googlePitch
	global roll
	roll = android.googleRoll

if starting:
	centerYaw = 0
	centerPitch = 0
	centerRoll = 0
	
	yaw = 0
	pitch = 0
	roll = 0
	android.update += update

freeTrack.yaw  = yaw - centerYaw
freeTrack.pitch = pitch - centerPitch
freeTrack.roll = roll - centerRoll

if keyboard.getKeyDown(Key.LeftControl) and keyboard.getPressed(Key.C):
    centerYaw = yaw
    centerPitch = pitch
    centerRoll = roll
PinkTyGRR
One Eyed Hopeful
Posts: 12
Joined: Tue Feb 12, 2013 2:54 pm

Re: Nexus 7 Freepie Script

Post by PinkTyGRR »

Thanks for the quick reply cybervillian! unfortunately android.googleyaw 0 is displayed and doesnt change no matter what setting i have my phone (galaxy s3). Same thing with my tablet when i try on that (transformer prime). if i press debug on either i see the numbers constantly changing in the android app depending on if i move it, but on my computer under the watch tab android.googleyaw never changes. I just cant figure out how to get the computer to read my mobile devices. turned off firewalls and anti-viruses, have the correct ip. I think i'll just try an uninstall and re-install and see if that changes anything. Thanks for all your help!
PinkTyGRR
One Eyed Hopeful
Posts: 12
Joined: Tue Feb 12, 2013 2:54 pm

Re: Nexus 7 Freepie Script

Post by PinkTyGRR »

reinstall didnt change anything. perhaps im missing a step. I start the freepie program, put in the new script diagnostics.watch(android.googleYaw) and run the script. then open the android freepie app, make sre target port and ip are correct, tick send orientation, select normal, and press on. yaw never changes from 0 on the watch screen on the desktop application.

i think im missing a step?
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Nexus 7 Freepie Script

Post by CyberVillain »

Very strange that should work, Sorry i cant be of more help, just double check ports, firewalls etc. It uses UDP so make sure you have opened up UDP traffic too
PinkTyGRR
One Eyed Hopeful
Posts: 12
Joined: Tue Feb 12, 2013 2:54 pm

Re: Nexus 7 Freepie Script

Post by PinkTyGRR »

thanks for the tip! i went ahead and double checked the port and I indeed had to open the port, after that i was able to use the mouse emulation from earlier in the post. Its basically the same as the one below except it doesnt use the + math.pi or
if math.fabs(deltaYaw) >= math.pi:
deltaYaw = 0
lines. for some reason without those lines it runs fine, but with those lines it doesnt run at all. i was hoping to use those be able to do a 360 in a game such as skyrim when streamed to my tablet and using the mouse emulation script.

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 (enabled):
mouse.deltaX = -deltaYaw*600
mouse.deltaY = -deltaRoll*1000


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

toggle = keyboard.getPressed(Key.Z)

if toggle:
enabled = not enabled
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Nexus 7 Freepie Script

Post by CyberVillain »

What error do you get?
PinkTyGRR
One Eyed Hopeful
Posts: 12
Joined: Tue Feb 12, 2013 2:54 pm

Re: Nexus 7 Freepie Script

Post by PinkTyGRR »

hm, not sure what i did differently but its working great now. sry for all the trouble, thanks for the time and help
Seawolf
One Eyed Hopeful
Posts: 6
Joined: Thu Jun 20, 2013 12:58 am

Re: Nexus 7 Freepie Script

Post by Seawolf »

hi, i'm new it this al vr stuff. i want to build my own version of oculus rift but first I want to check the nexus 7 hack. i've got problem because when i load any of yours code and trigered "z" key (or whatever is set) mouse cursor start epileptic dance on left top corner of screen. Any clue what i'm doing wrong?
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Nexus 7 Freepie Script

Post by CyberVillain »

start out just with

diagnostics.watch(android.googleYaw)
diagnostics.watch(android.googlePitch)
diagnostics.watch(android.googleRoll)

check that the values looks stable and nice (Its in radians)

Thats working?
Seawolf
One Eyed Hopeful
Posts: 6
Joined: Thu Jun 20, 2013 12:58 am

Re: Nexus 7 Freepie Script

Post by Seawolf »

When i put nexus on table and not touching, numbers are
diagnostics.watch(android.googleYaw) 2,78; 2,79; 2,80; 2,81 and still changeing, and still growing (rest of the numbers are almost impossible to read in all cases)
diagnostics.watch(android.googlePitch) 1,46 (rest of the numbers are almost impossible to read in all cases)
diagnostics.watch(android.googleRoll) oscilate between -2,81 and -2,86 (rest of the numbers are almost impossible to read in all cases)
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Nexus 7 Freepie Script

Post by CyberVillain »

when you say they are impossible to read is becasue it chanegs alot?
Seawolf
One Eyed Hopeful
Posts: 6
Joined: Thu Jun 20, 2013 12:58 am

Re: Nexus 7 Freepie Script

Post by Seawolf »

Changes like crazy, for example value is 2,81xxxxxxxxxxxxxxx, and every x constantly changes value
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Nexus 7 Freepie Script

Post by CyberVillain »

ok, but thats so small angels so shouldnt matter, strange, i cant really say why its acting like that..
Seawolf
One Eyed Hopeful
Posts: 6
Joined: Thu Jun 20, 2013 12:58 am

Re: Nexus 7 Freepie Script

Post by Seawolf »

On the nexus 7 i've installed apk from second post in this thread, on PC 0.6.277.0. Sensors in nexus are fine beacuse dive unity demo from android market work great
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Nexus 7 Freepie Script

Post by CyberVillain »

What script are you using?
Seawolf
One Eyed Hopeful
Posts: 6
Joined: Thu Jun 20, 2013 12:58 am

Re: Nexus 7 Freepie Script

Post by Seawolf »

I've been using every one with the same effect. Now i've tried to make some tweaking with tablet app (since i assume code must be good if work for others), and everything start to work perfectly when uncheck send raw data, so essentially this was causing problem (only raw data selected, and both selected doesn't work). Thank you for your effort to help :)
Post Reply

Return to “FreePIE”