Question about apply global based quaternion value for bone

I am trying to apply IMU data for bone to realise simple motion capture function

I am currently use 2 poses for static calibration and converted the IMU data to human body coordinate system

when I try to apply IMU data to specific bone, I realised that bone has it’s local axis and the rotation is based on it’s parent. I am lack of relative math knowledge so I am confused about how to do next

Do I need to convert IMU data from global space to bone’s space and apply converted quaternion to bone or something else

Thank you

Hello @momo florida blue ,
Yes, you need to convert the IMU data from global space to the bone’s local space . Apply the converted quaternion to the bone to ensure accurate motion capture. This involves transforming the global rotation data to the bone’s coordinate system.

Best Regards,
Ellen Hogan

Thank you for the reply

after calibration, the IMU sensor’s axis has been converted in to human body axis and zero pose is when human standing naturally

I used code below to convert quaternion from global to bone’s local

const parentBoneWorldQuaternion = new THREE.Quaternion();
bone?.parent?.getWorldQuaternion(parentBoneWorldQuaternion);
const parentBoneQuaternionInverse = parentBoneWorldQuaternion?.clone()?.invert();
const local = parentBoneQuaternionInverse?.clone()?.multiply(imuGlobal);

the model and rig as in above screenshot.

From my understanding, the correct convertGlobalToLocal function should make sure when we apply (w=1, x=y=z=0) quaternion based on global axis for all bone, the model’s pose should match the zero pose of human in real world

I use the bone’s local quaternion by using bone.quaternion and converted IMU’s local quaternion based on same pose to calculate an offset quaternion used to calibrate model and IMU

but my algorithm seems only work for parts of the bone, so I am confused if it’s due to rig issue or am I thinking in a wrong way

Hi! I am working on something similar now.

Were you able to move forward with your problem?

Sorry for the late reply, I have some progress but for the foot bone, it doesn’t work.

from my understanding, we need to calibrate the IMU sensor and get a rotation matrix to make sure the data read from sensor is based on a global coordinate system (after apply this rotation matrix)

and second step is to make sure the sensor’s global coordinate system matches the 3d model’s

then we can apply new IMU data to each individual bone by using

scene.attach(bone)
bone.quaternion.copy(q)
parentBone.attach(bone)