dorukeker/gyronorm.js

Acceleration is not consistent between iOS and Android

zcfan opened this issue · 3 comments

zcfan commented

I found iOS and Android acceleration value has different sign, and it seems gravityNormalized option only correct accelerationWithGravity(gm.gx/gm.gy/gm.gz) but not acceleration(gm.x/gm.y/gm.z).

I made a plot for this situation to clarify my idea:

img_175f121d5bfc-1

Those two green box shows that the gm.y and gm.z in iOS and Android are negative to each other.

Change line 350 - 355 to following could give consistent value, but I'm not sure I understand this library completely. I would like to make this a PR if you this's a correct fix.

// Normalize gravity
if (_gravityNormalized) {
  snapShot.dm.gx *= _gravityCoefficient;
  snapShot.dm.gy *= _gravityCoefficient;
  snapShot.dm.gz *= _gravityCoefficient;
}
// Change above to:
if (_gravityNormalized) {
  snapShot.dm.gx *= _gravityCoefficient;
  snapShot.dm.gy *= _gravityCoefficient;
  snapShot.dm.gz *= _gravityCoefficient;
  snapShot.dm.x *= _gravityCoefficient;
  snapShot.dm.y *= _gravityCoefficient;
  snapShot.dm.z *= _gravityCoefficient;
}

Yep! you are correct please make the PR and I will merge.
Thanks!
D.

zcfan commented

@dorukeker Actually I found that gravityNormalized option can't be set by user at all, it's always true. Will make a PR later 😂

Thanks! I merged the PRs