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