Android

Official forum for open source FreePIE discussion and development.
User avatar
RescueGamer
Cross Eyed!
Posts: 108
Joined: Thu May 16, 2013 1:02 am

Re: Android

Post by RescueGamer »

Hi everyone, i have a question, it's possible to use an android smartphone to head tracking with the vireio shared memory tracker, using the trackIR to vireio plugin? how i can do that?, i need it for completing my oculus rift clon. Thanks a lot! :)
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Android

Post by CyberVillain »

RescueGamer wrote:Hi everyone, i have a question, it's possible to use an android smartphone to head tracking with the vireio shared memory tracker, using the trackIR to vireio plugin? how i can do that?, i need it for completing my oculus rift clon. Thanks a lot! :)
Why do you need TrackIR? Just do

android > vireioSMT for example

Code: Select all

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

if starting:
	android.update += update
edit: vireioSMT uses degrees and android redians so you need to todo

Code: Select all

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

if starting:
	android.update += update
User avatar
RescueGamer
Cross Eyed!
Posts: 108
Joined: Thu May 16, 2013 1:02 am

Re: Android

Post by RescueGamer »

So i only need this line for use the android sensor as shared memory tracker?, or some outputs line or something like that?
Thanks, really, i'm starting now with this and is a lot of information XD
Croccy22
Cross Eyed!
Posts: 140
Joined: Wed Feb 04, 2009 7:51 am

Re: Android

Post by Croccy22 »

CyberVillain wrote:
RescueGamer wrote:Hi everyone, i have a question, it's possible to use an android smartphone to head tracking with the vireio shared memory tracker, using the trackIR to vireio plugin? how i can do that?, i need it for completing my oculus rift clon. Thanks a lot! :)
Why do you need TrackIR? Just do

android > vireioSMT for example

Code: Select all

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

if starting:
	android.update += update
edit: vireioSMT uses degrees and android redians so you need to todo

Code: Select all

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

if starting:
	android.update += update

I too am trying to get this working. I have downloaded the vireioSMT.dll file and put it in the plugins directory. With the script you posted it works in LFD2 but there is hardly any movement. I have multiplied the values by 25 (Trial and Error) and this has got it somewhere close but is this the correct way to do this or is there another option I should be changing.

Also when I try the same thing in Skyrim I don't get any head tracking using exactly the same setup as I did for L4D2? Any ideas what could be wrong?

Thanks, Matt.
User avatar
RescueGamer
Cross Eyed!
Posts: 108
Joined: Thu May 16, 2013 1:02 am

Re: Android

Post by RescueGamer »

I used the script as posted here, but with only orientation marked on android app, and mirrors edge works well with it except for the rotation(which is strange) and some calibratiom loose. I have to try some changes too, anyone knows how to improve this? Or if its better using another script like android>freetrack?
EDIT: here I leave the modified script wich guives me te best head tracking (the only bad it has is some calibration loose, but for playing it's really god):

Code: Select all

def update():
   vireioSMT.yaw = math.degrees((android.googleYaw)/3)
   vireioSMT.pitch = math.degrees(android.googlePitch/3)
   vireioSMT.roll = math.degrees(android.googleRoll/3)
   diagnostics.watch(vireioSMT.yaw)
   diagnostics.watch(vireioSMT.pitch)
   diagnostics.watch(vireioSMT.roll)

if starting:
   centerYaw = 0
   centerPitch = 0
   centerRoll = 0
   
   yaw = 0
   pitch = 0
   roll = 0
   android.update += update
Try it, i'm still surprised :)

EDIT2: Another little update of the script, with this you don't have to invert the mouse look (at least in mirrors edge now you don't have to), and with this update, if you turn 90º on real life the game turns 90º, I can't measure it, but it works really well, this is perfect for a DIY Rift. Here is the script:

Code: Select all

def update():
   vireioSMT.yaw = math.degrees((android.googleYaw)/4)
   vireioSMT.pitch = math.degrees(-(android.googlePitch/4))
   vireioSMT.roll = math.degrees(android.googleRoll)
   diagnostics.watch(vireioSMT.yaw)
   diagnostics.watch(vireioSMT.pitch)
   diagnostics.watch(vireioSMT.roll)

if starting:
   centerYaw = 0
   centerPitch = 0
   centerRoll = 0
   
   yaw = 0
   pitch = 0
   roll = 0
   android.update += update
I'm new on this, so I can have a lots of errors and maybe I complicated things, but for the HDM I will build it's perfect XD
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Android

Post by CyberVillain »

My tests with Hydra emulation made me aware of the need of support for multiple androids, so stay tuned for that :D
Yury_Ice
One Eyed Hopeful
Posts: 2
Joined: Thu Aug 15, 2013 12:29 am

Re: Android

Post by Yury_Ice »

hi all.
version of freepie plugin and apk file for android from 4 page (dated 07/03/2013) is the last one?
i need only that files and script to use my tablet as orientation sensor?

playin with nexus 7 (2013), trying to built wireless solution like shown here on forum. Very many information but there are no adequate instruction how to build that.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Android

Post by CyberVillain »

Hi Yuri, the latest version is in the FreePIE install folder. Checkout the many android samples on the FreePIE homepage. Please get back to me if you have any specific script questions.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Android

Post by CyberVillain »

New version of FreePIE (1.3.422) supports multiple Android devices. This required a change in data contract so you need to reinstall the APK from installfolder. (Even if you do not use the multiple devices feature).

You select a index on the phone from the FreePIE IMU software, that index can then be used from script like

Code: Select all

android[0].yaw
etc
default is zero so if you dont have multiple devices, just stick with zero
jangomoose
One Eyed Hopeful
Posts: 4
Joined: Fri Feb 07, 2014 5:33 pm

Re: Android

Post by jangomoose »

I'm flummoxed, have spent days trying to get my tablet or phone to connect with freepie and haven't succeeded.
On the tablet (nexus7 2013 android 4.4.2) and the phone (Galaxy S3 Android 4.1.2) debug info is displaying correctly, port set to 5555, correct IP address, tried with either "send orientation" or "send raw data" not both together, app crashes if I do that.

Run Script
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[0].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

No errors reported but nothing happens, even reset the router back to factory defaults, but nothing,
Anyone got any ideas? No doubt it is something simple I am not doing correctly.
Ta.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Android

Post by CyberVillain »

Code: Select all

android.googleYaw
should be

Code: Select all

android[0].googleYaw
This is because we now support mutiple phones, you also need to install latest version of the apk from the FreePIE folder (Once you have teh latest version of FreePIE).

Does the phone have conntact with the desktop PC using other software, like the Ping software there have been talks about earlier
jangomoose
One Eyed Hopeful
Posts: 4
Joined: Fri Feb 07, 2014 5:33 pm

Re: Android

Post by jangomoose »

Thanks for the speedy reply,
I did try the ping app mentioned earlier and that sends and receives fine.
Splashtop and Kainy also behave.

Have changed that bit of code, still with no joy though.

So, just to confirm what I am doing is correct?

Run Android app on phone. enter PC's IP address, in this case 192.168.1.6
port 5555
select Send orientation
click debug
Click ON.

Run script in Freepie
Press Z
Click on Watch window.

I have no doubt that i am missing something obvious!

EDIT: Cancel my last, appears I wasn't running the latest version of the Android App, all good now. Thanks
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Android

Post by CyberVillain »

Really glad to hear!
kill_dano
One Eyed Hopeful
Posts: 5
Joined: Thu Aug 14, 2014 3:33 pm

Re: Android

Post by kill_dano »

SO from what I understand the consensus here is that this is the good script:

But I can't get it working properly. I've tested a few games, like mirrors edge and LFD2. In Mirror's Edge the head tracking is really jittery and erradic and hyper sensitive. Not smooth at all. in LFD2, I have no movement at all. not even when using the mouse. Controller is disabled. See anything wrong with my script?

Code: Select all

def update():
	vireioSMT.yaw = math.degrees((android[0].googleYaw)/4)
	vireioSMT.pitch = math.degrees(-(android[0].googlePitch/4))
	vireioSMT.roll = math.degrees(android[0].googleRoll)
	diagnostics.watch(vireioSMT.yaw)
	diagnostics.watch(vireioSMT.pitch)
	diagnostics.watch(vireioSMT.roll)

if starting:
	centerYaw = 0
	centerPitch = 0
	centerRoll = 0
   
	yaw = 0
	pitch = 0
	roll = 0
	android[0].update += update
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Android

Post by CyberVillain »

New version, please try and see if it works for you
You do not have the required permissions to view the files attached to this post.
CyberVillain
Petrif-Eyed
Posts: 2166
Joined: Mon Jun 22, 2009 8:36 am
Location: Stockholm, Sweden

Re: Android

Post by CyberVillain »

Any problems with using latest version above?
Post Reply

Return to “FreePIE”