LoginSignup
29

More than 5 years have passed since last update.

posted at

updated at

加速度センサーの値を強度と角度に変換

加速度センサーの値が静止していると1Gを示します。
その時の加速度センサーの値を(x,y,z)として、重力のみを検出しているときに、センサーがどの角度に傾いているのか計算してみたいと思います。その前提として、加速度センサーの絶対値 aが、1のときであることを前提としています。
すなわち a = √(x^2+y^2+z^2) = 1G=9.8m/sのことです。

  • a = √(x^2+y^2+z^2)
  • Θx = atan(x /√(y^2+z^2)) * 180 / 3.14
  • Θy = atan(y /√(x^2+z^2)) * 180 / 3.14
  • Θz = atan(z /√(x^2+y^2)) * 180 / 3.14

この計算では、空間を次の方法で表現しています。

  • aは、加速度の絶対値
  • ΘxはYZ平面に対する角度
  • Θyの角度はZX平面に対する角度
  • Θx軸の角度はXY平面に対する角度

acc_graph1.png
acc_graph2.png
acc_graph3.png

この計算式を使って基板の角度を計算すると、重力が向いている方向を知ることが出来ます。

detail.png

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
29