1

I have this Myo armband which has a IMU built in, and in python I want to get the roll-pitch-yaw in my desired frame of reference. It works well in the same position with the computer, but if I e.g. move to the opposite side of the table I will get opposite pitch values. I have tried following this guide: 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)

Thanks in advance

giggitygoat
  • 99
  • 2
  • 11
  • It's hard to understand what you want in which coordinate system. Try to elaborate. Figures might help. Btw, are you sure you want Euler angles? Except for interaction with users, they are one of the worst representations for rotations you can have. – Nico Schertler Dec 10 '16 at 15:44
  • I want to be able to tell the person using the armband to place the arm next to the computer and then start the program, because I want to know when the user is e.g raising his hand. [link](http://imgur.com/a/ISA0u), this is two pictures of the terminal with me doing the same movement with my hand, from two sides of the table. – giggitygoat Dec 10 '16 at 16:40
  • So you need some kind of reference orientation? Then save this reference orientation at the beginning and multiply its inverse to the left of the current rotation. – Nico Schertler Dec 10 '16 at 16:42
  • Yes, and right now that only works in the same position – giggitygoat Dec 10 '16 at 16:57
  • 1
    Ah, you are already doing that in some way (although as I said, you should multiply `centre` to the left of `obj`. And I don't understand this `.conjugate` there. What do you expect? There is no way to know which side the arm is on unless you have some priors on how the user can move the arm. If the user changes positions, you obviously need to adapt the center. – Nico Schertler Dec 10 '16 at 17:06
  • Thank you very much! I simply changed the order of multiplication and removed the conjugate on the frame, and also removed the euler angles. – giggitygoat Dec 11 '16 at 03:54

0 Answers0