Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
EnTerr
Roku Guru

How to map accelerometer readings to screen coordinates?

Don't know where to ask this question, since the people that ever had to do that likely can be counted on the fingers (or finger) of one hand. But my mind is drawing a blank on this and it should be a relatively simple transform, so let me lay down the problem and hopefully someone will help me being less dumb.

So here is the setup - assume i get reading of 3 floats x, y, z, each between -1 and 1. Those are components of the gravity vector in the coord. system of the remote. It lays on the table, i get (0, 0, 1); flipped face-down, (0, 0, -1); standing vertical, (0, -1, 0) and so on. Simple enough.

Question is, how do i map the readings to the TV screen, so that i can use the remote to guide a pointer/cursor on screen? Gut feeling is telling me maybe map the cartesians to spherical coord system and shoehorn the two angles but i feel really uncertain.

Pointers?
0 Kudos
7 REPLIES 7
RokuJoel
Binge Watcher

Re: How to map accelerometer readings to screen coordinates?

Where are you getting the data from the remote? Is this in Marmalade?

- Joel
0 Kudos
EnTerr
Roku Guru

Re: How to map accelerometer readings to screen coordinates?

"RokuJoel" wrote:
Where are you getting the data from the remote? Is this in Marmalade?

Yes and yes.

I described it generally enough though, in case someone that had programmed for Wiimote or robotics has a ready answer. Currently i am face-planting because of what i call the "yaw tragedy of accelerometers" (can't detect movement around vertical axis)
0 Kudos
RokuJoel
Binge Watcher

Re: How to map accelerometer readings to screen coordinates?

Here are the types of data I'm aware the remote supports, but I"m not sure how this translates to Marmalade motion parameters or if it has a gyro or not:

abs position
rel position
accel
accel no gravity
ang veloc
quaternions

- Joel
0 Kudos
EnTerr
Roku Guru

Re: How to map accelerometer readings to screen coordinates?

Seems promising but all i get in Marmalade is the acceleration vector x, y and z (Lua API, C++ API) and using only that there is a problem detecting horizontal movement (when pointing remote at the screen, vertical movements are mostly rotation around X axis and that gets detected well - where horizontal movement is mostly rotation around the vertical Z axis and that cannot be sensed at all; off top of my head i think is arctan(x, y), where x=y=0; the indeterminate form 0/0 = anything).

It would be tempting to say "oh, the remote just cannot do that" but i did a simple test with "Angry Birds" and it can. Setup: lay the remote on horizontal surface to eliminate unintentional tilts and shakes, facing the TV. Press OK and gingerly rotate left and right in the horizontal plane, observe on screen that gets read very well (stretching the sling left or right).

So it can be done and it has been done. Question is, how?
0 Kudos
destruk
Binge Watcher

Re: How to map accelerometer readings to screen coordinates?

Did you ask the marmalade people how to do it? I don't think AngryBirds was made with marmalade.
0 Kudos
RokuJoel
Binge Watcher

Re: How to map accelerometer readings to screen coordinates?

Angry Birds is pure NDK, not Marmalade SDK.

To answer your question, yes it has a gyro. As I understand it, you'll want to use the Absolute Position info from the remote.

- Joel
0 Kudos
EnTerr
Roku Guru

Re: How to map accelerometer readings to screen coordinates?

"RokuJoel" wrote:
Here are the types of data I'm aware the remote supports, but I"m not sure how this translates to Marmalade motion parameters or if it has a gyro or not:

abs position
rel position
accel
accel no gravity
ang veloc
quaternions

Hmm, how do i get my tentacles on the documentation for this?! Still can't find it...
0 Kudos