FreePIE bytes format
-
- One Eyed Hopeful
- Posts: 8
- Joined: Tue Oct 28, 2014 2:02 pm
FreePIE bytes format
Hey,
This is my first post here, so apologies if there are any mistakes.
Well recently I've been trying to integrate freePIE's android IMU into game engines. My current target is blender game engine, which uses python.
First of all, I'm an absolute newbie when it comes to networking in any language, though I could get python to read freePIE's orientation data from the IMU just fine, but in bytes.
I've started a thread on Blender artists forum, and the answer was that I needed to know what's being sent over/it's format in order to be able to encode it.
That's basically the question. What is the possible way to turn raw bytes into a string so I can extract the orientation matrix/accelerometer data?
Thanks!
This is my first post here, so apologies if there are any mistakes.
Well recently I've been trying to integrate freePIE's android IMU into game engines. My current target is blender game engine, which uses python.
First of all, I'm an absolute newbie when it comes to networking in any language, though I could get python to read freePIE's orientation data from the IMU just fine, but in bytes.
I've started a thread on Blender artists forum, and the answer was that I needed to know what's being sent over/it's format in order to be able to encode it.
That's basically the question. What is the possible way to turn raw bytes into a string so I can extract the orientation matrix/accelerometer data?
Thanks!
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
Re: FreePIE bytes format
There is no need for you to rewrite FreePIE, use the FreePIE_IO plugin
https://github.com/AndersMalmgren/FreeP ... /IO-Plugin
With that the user can use any of the plugins in FreePIE with your software
https://github.com/AndersMalmgren/FreeP ... /IO-Plugin
With that the user can use any of the plugins in FreePIE with your software
-
- One Eyed Hopeful
- Posts: 21
- Joined: Fri Oct 17, 2014 1:50 am
Re: FreePIE bytes format
You mean replace the FreePIE PC App by your python script on blender, and receive information from an android device directly ?
If yes, yo can see how the source code interprets the received data:
https://github.com/AndersMalmgren/FreeP ... in.cs#L103
If yes, yo can see how the source code interprets the received data:
https://github.com/AndersMalmgren/FreeP ... in.cs#L103
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
Re: FreePIE bytes format
Going directly against the UDP packages sent by the Android App is going against what FreePIE stands for.
Pyhton can load C dlls, so please use that method and people can use any input supported by FreePIE.
http://blenderartists.org/forum/showthr ... hon-script
Pyhton can load C dlls, so please use that method and people can use any input supported by FreePIE.
http://blenderartists.org/forum/showthr ... hon-script
-
- One Eyed Hopeful
- Posts: 8
- Joined: Tue Oct 28, 2014 2:02 pm
Re: FreePIE bytes format
Well I did try the DLL method previously but I wanted the process to be automated to a certain point.
Maybe I'm missing something and that you can get the data directly from the IO plugin without having to run freePIE with a script that writes a slot in the IO DLL ?
Maybe I'm missing something and that you can get the data directly from the IO plugin without having to run freePIE with a script that writes a slot in the IO DLL ?
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
Re: FreePIE bytes format
Well thats the whole point, to run FreePIE in the background so users can use any tracker.
-
- One Eyed Hopeful
- Posts: 21
- Joined: Fri Oct 17, 2014 1:50 am
Re: FreePIE bytes format
Then maybe you can launch FreePIE from pyhon ...Jackii wrote:Well I did try the DLL method previously but I wanted the process to be automated to a certain point.
¿ Are there command line options to tell FreePIE to exec an script on launch ?
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
-
- One Eyed Hopeful
- Posts: 8
- Joined: Tue Oct 28, 2014 2:02 pm
Re: FreePIE bytes format
I'm a bit lost with reading slot data from IO, here's my current tiny code:
It outputs c_float(0.0), with valid slots and with other unused slots a writing violation error.
Code: Select all
import ctypes
yaw = ctypes.c_float(0.0)
pitch = ctypes.c_float(0.0)
roll = ctypes.c_float(0.0)
path = "C:/Program Files (x86)/FreePIE/freepie_io.dll" #temporary, just for testing
lib = ctypes.CDLL(path)
test = lib.freepie_io_6dof_read(0, 0, yaw, pitch, roll);
print(yaw)
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
-
- One Eyed Hopeful
- Posts: 8
- Joined: Tue Oct 28, 2014 2:02 pm
Re: FreePIE bytes format
Which one? I've already tried to replicate the one on the IO's page but it's changing nothing in the variables as the code I've pasted above.CyberVillain wrote:Can this c++ example help?
edit: I did it! Well sort of.... I got it to read the yaw data perfectly, though it's not reading the rest..
My code:
Code: Select all
from ctypes import*
yaw = c_float()
pitch = c_float()
roll = c_float()
path = "C:/Program Files (x86)/FreePIE/freepie_io.dll" #temporary, just for testing
lib = CDLL(path)
test = lib.freepie_io_6dof_read(0, 1, byref(yaw), byref(pitch), byref(roll));
print(yaw.value, pitch.value, roll.value)
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
Re: FreePIE bytes format
Missed the link sorry
https://github.com/AndersMalmgren/FreeP ... est/main.c
edit: The problem is that it takes a struct
https://github.com/AndersMalmgren/FreeP ... est/main.c
edit: The problem is that it takes a struct
Code: Select all
typedef struct freepie_io_6dof_data
{
float yaw;
float pitch;
float roll;
float x;
float y;
float z;
} freepie_io_6dof_data;
Code: Select all
int32_t freepie_io_6dof_read(uint32_t index, uint32_t length, freepie_io_6dof_data *output);
-
- One Eyed Hopeful
- Posts: 8
- Joined: Tue Oct 28, 2014 2:02 pm
Re: FreePIE bytes format
Worked!
Thanks CyberVillain!
Thanks CyberVillain!
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
Re: FreePIE bytes format
Glad I could help, what will you use it for in Blender?
edit: Read the first post, didnt know they had a engine, I thought it was a render program only
edit: Read the first post, didnt know they had a engine, I thought it was a render program only
-
- One Eyed Hopeful
- Posts: 8
- Joined: Tue Oct 28, 2014 2:02 pm
Re: FreePIE bytes format
Blender game engine is a relatively powerful game engine with visual scripting and python along with GLSL node shaders and a super fast workflow for prototyping.
You're not the first person by any means to not know that Blender has a built in game engine.
I'm using freePIE for smartphone VR using the Trinus Gyre.
Edit: here's a quick video of it working with the Trinus Gyre in a simple demo game I made: http://youtu.be/1ybe3t7XSnU
You're not the first person by any means to not know that Blender has a built in game engine.
I'm using freePIE for smartphone VR using the Trinus Gyre.
Edit: here's a quick video of it working with the Trinus Gyre in a simple demo game I made: http://youtu.be/1ybe3t7XSnU
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
-
- One Eyed Hopeful
- Posts: 8
- Joined: Tue Oct 28, 2014 2:02 pm
Re: FreePIE bytes format
Tracking latency is almost nothing in both cases of wireless and USB tethered. Though it sometimes stutters in wireless. The streaming latency is the one that's relatively high at high resolutions and deeper color channels.
Edit: Since there's a "send raw data" option in the android IMU, is there a way to access that from FreePIE and write it into the IO DLL?
Edit: Since there's a "send raw data" option in the android IMU, is there a way to access that from FreePIE and write it into the IO DLL?
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden
Re: FreePIE bytes format
Today its not, but I have gotten the request before, I can fix it for next version.
-
- One Eyed Hopeful
- Posts: 8
- Joined: Tue Oct 28, 2014 2:02 pm
Re: FreePIE bytes format
Great! looking forward.
Though how would it be like? android[0].gyro[0] instead of android[0].googleyaw for instance?
Though how would it be like? android[0].gyro[0] instead of android[0].googleyaw for instance?
-
- Petrif-Eyed
- Posts: 2166
- Joined: Mon Jun 22, 2009 8:36 am
- Location: Stockholm, Sweden