Jump to content

Mapping Of 3D object to Gyro Data from Device (calibration)


Abdullah
 Share

Recommended Posts

Background: I am a newbie in game development I'm creating motion sensor game Air Table Tennis on Babylon.JS in which user can control the paddle of table tennis with his/her smartphone. I am using gyroscope/rotational data of mobile in the form of Quaternion to avoid Gimble Lock and sending the data to server(nodeJS). So Gyro data is coming from mobile through node JS.

Problem: So, I am using Quaternion, But I am unable to map my paddle as my device. (paddle is not exactly in the position where my mobile is currently now, although moving on x,y,z axix give me correct result). So my question is how to calibrate/Map 3D object same as my mobile device?

@wighawag@RaananW@Deltakosh Sir kindly help me, I'll be very thank ful.

Thanks in Advance

Link to comment
Share on other sites

Hiya Abby!  ;)  It has only been 85 minutes... be patient, my friend.  I have NO mobile devices at all... so this issue is difficult for me to troubleshoot.

Just relax - maybe do less person-pinging, and perhaps make us a very simple testing playground... no paddles, no table, just a plane or box, with devOrient active.  Maybe some showAxes arrows, too. 

Add-on some Text2d or html continuous-readouts (display) of current box.rotationQuaternion.  You could also TRY to display current values of the device's orientation, but I'm not sure how.

Create a "deviceOrientation testing laboratory" for yourself and helpers - using all that ping-energy that you seem to have.  ;)

On the mesh, this is a .rotationQuaternion AND a .position problem, yes?  Or, just .position?  Does mesh .position "jump", the first time, when device is tilted?  Does it jump for both rotation and position?  Interesting challenge.

Also, you CAN buy Uncle Wingnut a really nice "pad" if you wish.  :)  I would certainly allow that.  No phone or camera necessary, just a high-powered touch-active notepad computer, and maybe some extra battery packs and charger.  heh.

Be patient, if possible.  Folks with mobile devices will be waking from the weekend partying, soon.  thx.

Link to comment
Share on other sites

16 hours ago, Wingnut said:

Hiya Abby!  ;)  It has only been 85 minutes... be patient, my friend.  I have NO mobile devices at all... so this issue is difficult for me to troubleshoot.

Just relax - maybe do less person-pinging, and perhaps make us a very simple testing playground... no paddles, no table, just a plane or box, with devOrient active.  Maybe some showAxes arrows, too. 

Add-on some Text2d or html continuous-readouts (display) of current box.rotationQuaternion.  You could also TRY to display current values of the device's orientation, but I'm not sure how.

Create a "deviceOrientation testing laboratory" for yourself and helpers - using all that ping-energy that you seem to have.  ;)

On the mesh, this is a .rotationQuaternion AND a .position problem, yes?  Or, just .position?  Does mesh .position "jump", the first time, when device is tilted?  Does it jump for both rotation and position?  Interesting challenge.

Also, you CAN buy Uncle Wingnut a really nice "pad" if you wish.  :)  I would certainly allow that.  No phone or camera necessary, just a high-powered touch-active notepad computer, and maybe some extra battery packs and charger.  heh.

Be patient, if possible.  Folks with mobile devices will be waking from the weekend partying, soon.  thx.

:) Thank you for yor response  

Link to comment
Share on other sites

Hi guys.  Not many deviceOrientation users responding to this, eh?  Sorry, Abdullah.  You have been struggling with this for a long time.  This makes me sad.

I was hoping @davrous (or others) would bring us some calibration code, as it seems that he works-with deviceOrientation often.

Ok, let's try some things.  https://www.audero.it/demo/device-orientation-api-demo.html

That works ok with your device?

Now let's go here... https://www.w3.org/TR/orientation-event/

See the LAST code example at the bottom?  That appears to be an alpha/beta/gamma-to-quaternion convertor.  Potentially useful, soon.  You MAY need to change the 'return' line to...  return new BABYLON.Quaternion(w, x, y, z);   or perhaps... return new BABYLON.Quaternion(x, y, z, w);  *sigh*  Quaternion "orders" suck.  :)  You might even need to use the BJS Quat yaw/pitch/roll setter.

MAYBE... the initial Quaternion DIFFERENCE can be obtained via a Quaternion.subtract.  SO, you would place your devOr device in a stationary position, likely flat on table.  Then convert ITS current alpha/beta/gamma values... to Quaternion, using the convertor function on that page.  Then use mesh.rotationQuaternion.subtract(convertedQuat), and then store that result.  Call it var quatOffset if you wish.

Now, every time you get a new devOr event, convert the new alpha/beta/gamma values to Quaternion result (with the convertor). 

Next, do var adjustedQuat = result.add(quatOffset).

Then set mesh.rotationQuaternion = result;

I'm ALMOST COMPLETELY GUESSING about this.  It MIGHT work, but, likely not.  Who knows?  Worth a try, maybe.  I have been known to "get lucky" sometimes.  :D  (No no, not THAT kind of "get lucky".  hehe.  It's been SO LONG (time), that I completely forgot what THAT kind of "get lucky" even feels-like/looks-like (or smells-like).

You would think... as often as we use DevOr for controlling scene items... that there would be a nice tutorial about this.  Not sure why that doesn't exist on-web or in BJS docs.  It COULD BE because all these devOr devices have not yet standardized their systems... so each is slightly different.  Perhaps THAT is why we have not seen a comprehensive tutorial on this subject.  (A single tutorial would not apply to all situations/devices.)

As a final desperate idea, examine the code in our deviceOrientation camera inputs. I suspect there is some code in there... that installs alpha/beta/gamma... into a CAMERA rotation Quaternion.  Not exactly noob-friendly activity... sorry.

I BEG of fellow forum helpers... to TRY to make this operation smoother for users.  Abdullah is certainly not the first forum user to struggle with this.  Thanks for info, DK, but... you know... can you or others help us with some links to learn-from? 

Can we depend-upon Quat.add() and .subtract()? 

Does the order of BJS quats... differ from the Quats generated by the convertor mentioned above?  (thus our q.add() and q.subtract() will fail on those?)

ANY pointers to smoother trails... is highly welcomed.  Thanks!

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...