Rotation issue when applying live streaming mocap data from Polhemus G4

I am working on a Virtual Reality project where I am reading the motion data from Polhemus G4 tracker and apply this data to a game object (an Avatar) in Unity. Polhemus send 6 data values(3 for position xyz and 3 for rotation azimuth, elevation & roll)

The Unity (X,Y,Z) co-ordinates corresponds to the (Y, -Z, X) of the Polhemus.
I am able to apply the data values correctly but end up with an issue in rotation. When I hold the Polhemus Sensor in vertical position (Attached image), my Avatar appears laid horizontally.
I did a work-around for this by applying some boresighting in Polhemus APIs. I am looking for a better way if this is possible through Unity?

Also when I rotate the sensor left/right holding it same in vertical position, my Avatar gives huge tilt and start leaning horizontally. I tried both for Euler & Quaternions.
I am using the following code for rotation:

gameObject.transform.localRotation = Quaternion.Euler(new Vector3(0, y, 0))*Quaternion.Euler(new Vector3(x, 0, 0))*Quaternion.Euler(new Vector3(0, 0, -z));

I am sure there are people who have already done these things in Unity. Please help me to get through this one.

Thanks in advance :slight_smile:

hi HiteshSharma,
You could be experiencing gimball lock - you mention quaternians, but did you try setting the G4 system to output positions and quaternians rather than positions and eulers?
There’s a command through the polhemus sdk to switch.
I’ve just spent ages with the 8 sensor Liberty system, but went for a stand alone engine rather than unity3d, did consider though… out of interest, did you use unity3d inverse kinematics?
good luck!

Hey,

I’m working at the moment with the G4 too. Could you explain me, who you connect the G4 with your own system. As I understood it, the application PiMgr do a further filtering and the floor compensation. I saw in the PiMgr a option to export data. Do you use this option. I never did this before so I’m inexperienced. Poorly I have to work with Windows and found no information to create a pipeline with Windows.

So, no I will answer your question :smiley: I’m not sure, if changing the order of the quaternions is the right way. You have a rotation from the coordinate system of the G4 to your reference system. So I would calculate the quaternion of the rotation q_R. Then the multiplication of the output quaternion and q_R gives you the orientation you wanna have. You have to think about the order of the multiplication.

I hope that helps you.
Best Marlies