1

IMU が組み込まれているこの Myo アームバンドがあり、Python では、希望する参照フレームでロール ピッチ ヨーを取得したいと考えています。コンピューターと同じ位置でうまく機能しますが、たとえばテーブルの反対側に移動すると、反対のピッチ値が得られます。このガイドに従ってみました: http://developerblog.myo.com/quaternions/

#Setting a center with the conjugation of the first set of Quaternions

centre = libmyo.Quaternion(myo.orientation[0], myo.orientation[1], myo.orientation[2], myo.orientation[3]).conjugate()


while True:

    obj = libmyo.Quaternion(myo.orientation[0], myo.orientation[1], myo.orientation[2], myo.orientation[3])

    #Multiplying the current Rotation with the centre

    frame =  obj.__mul__(centre).conjugate()

    x= frame[0]
    y= frame[1]
    z= frame[2]
    w= frame[3]

   roll = math.atan2(2*y*w - 2*x*z, 1 - 2*y*y - 2*z*z)
   pitch = math.atan2(2*x*w - 2*y*z, 1 - 2*x*x - 2*z*z)
   yaw = math.asin(2*x*y + 2*z*w)

   print(roll, pitch, yaw)
   time.sleep(0.2)

前もって感謝します

4

0 に答える 0