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

2

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

The only palliative solution I found was to use DeviceOrientationEvent of JavaScript, which gives me the 0-360 angle, but I do not know where it gets that value and I do not even know if 0 ° is really 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 meaning of the user is also valid.

    
asked by anonymous 14.05.2018 / 05:17

0 answers