How to get sense of the device using gyroscope and accelerometer? Ionic 3

Asked

Viewed 200 times

3

I’m developing an application in Ionic 3, where I need to know what direction the user’s phone is pointing to, and then make the decision. I was trying to use the plugin Device Orientation, which returns a value in degrees (0 - 360) in which 0º is North, but many mobile phones (including mine) do not have magnetic sensor. I was reading that if I combine the data from the gyroscope and accelerometer, it would be possible to find the Azimuth axis that refers to the values in degrees. Only it’s being so much information (like Euler angles, angular velocity, mathematical formulas, etc.) that I don’t even know where to start.

The only palliative solution I found was to use the DeviceOrientationEvent Javascript, which gives me the angle of 0-360, but I don’t know where it takes this value and I don’t even know if 0º really is the north.

window.addEventListener('deviceorientation', (event) => {
  this.alpha= event.alpha;
  this.beta = event.beta;
  this.gamma = event.gamma;})

Anyway, if anyone knows of any other solution where I can know where the user’s sense is also valid.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.