- Home /

# 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 :)

[1]: /storage/temp/25575-attachment.png

Hi Hitesh, I am starting to work with Unity. I have a Polhemus G4 and I want to apply tracking data to a model in my game. I have the G4 hardware and the Polhemus SDK installed. How should I go about this integration so that I am able to apply G4 tracking data to any 3d model in my game? I have integrated G4 using their own SDK in other C++ projects but I am not sure how to do this in Unity. Any help or advice will be appreciated or if you have a built G4 plugin you can share.

Hi, please, could you tell me how to get data from PiMgr to my own project in C++ VS 2008? Thanks!

,Hi, did anyone resolve how to get data from PiMgr to your own project, please?

**Answer** by Wotthe Dickins
·
Apr 26, 2014 at 05:20 PM

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!

Hi Wotthe, I set the G4 system to output positions and quaternians and then set these values(w, x, y, z) in Unity as:

quaternion.w = w; quaternion.x = y; quaternion.y = z; quaternion.z = x; gameObject.transform.rotation = quaternion;

But this still gives me that tilt. rotating the sensor same way for PiMgr though gives better rotation.

And sorry, I am not much aware about the unity3d inverse kinematics. May you please guide me a little on that?

Regards, Hitesh

**Answer** by Marlies123
·
May 16, 2014 at 01:42 PM

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 :D 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

Hi Marlies,

Thank you for your response. Can you please explain me about this quaternion of the rotation q_R? I am newbie for this field. I am a computer programmer and 3D is all new to me.

And I am doing a continuous reading of the P&O data from G4 and applying to the game object in Update method. so I am not looking for an export frm PiMgr.

Thanks, Hitesh

Hi,

you have first a rotation, with the quaternion q1, and the a second rotation, with the quaternion q2. The whole rotation will be done with q = q2*q1. I'm new in this field to, but I spent a lot of time to try to understand all the notations for orientation. So I'm not sure about the order of the multiplication, you will have to try. I'm thinking that you get the quaternion q1 from your system and the do a second rotation to come from the coordinates from the G4 to yours. So q2 is the rotation from (Y,-Z,X) to (X,Y,Z).

An other, maybe the simplest idea, would be to rotate the source ;) Just try it.

So you use the P&O directly from the USB connection? Do you use the RF Module or a direct connection? Because I noticed that there are a lot of data gaps, if you use the RF Module, although you are only 1.5m away from the PC.

Thanks you too Marlies

I am starting to work with Unity. I have a Polhemus G4 and I want to apply tracking data to a model in my game. I have the G4 hardware and the Polhemus SDK installed. How should I go about this integration so that I am able to apply G4 tracking data to any 3d model in my game? I have integrated G4 using their own SDK in other C++ projects but I am not sure how to do this in Unity. Any help or advice will be appreciated or if you have a built G4 plugin you can share.

Hi,

I am working to make a VR arm using Oculus Rift DK2 and Polhemus Fastrak or Polhemus Liberty for tracking. But unfortunately, I did not find how to extract data from Polhemus to Unity. So I will need some help for getting data from Polhemus to move the arms in Unity.

Thanks,

### Your answer

### Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.

### Follow this Question

### Related Questions

Anti-Gravity vehicle bounce-back? 1 Answer

How to Rotate Object around point only 90 Degree. 1 Answer

Choose starting point/angle for rotation with cos and sin 0 Answers

Reletive rotation problems. (C#) 2 Answers

Constant Rotation in 2D 0 Answers