Issues with HTC Vive Tracker Position

Issues with HTC Vive Tracker Position

nharis7
Participant Participant
1,042 Views
4 Replies
Message 1 of 5

Issues with HTC Vive Tracker Position

nharis7
Participant
Participant

Hi Everyone,

I am working with HTC Tracker to get position of the tracker and then to set it on the my model. I can get tracker value by using getWorldMatrix and it gives me a matrix. And I used its values to set it to my model translation but the issue is when I use setTransformNodeTranslation to set values of tracker to my model it also set value to my rotation pivot. Due to that it does not match to my desired position. 

If there is a way of workaround then please let me know Or any suggestions will be highly appreciated.

Thanks.

0 Likes
1,043 Views
4 Replies
Replies (4)
Message 2 of 5

sinje_thiedemann
Autodesk
Autodesk

Hi,

I suggest keeping the model transform and the tracking transform separate. Add a separate Matrix Transform node to the scenegraph, as parent of your model node, and set the transformation of the tracker to that Matrix Transform node.

You can check whether this will give the desired effect by moving the matrix transform node manually with Transform manipulator or editor.

If this does not help, please explain in more detail (maybe with a sketch or screenshot) how the expected result should look like/behave.

Kind regards

Sinje

0 Likes
Message 3 of 5

nharis7
Participant
Participant

Thank you for the response. I am already doing what you suggested but I really want a proper solution. I don't understand why my rotation pivot value changes when I use setTransformNodeTranslation on the object node. If my rotation pivot values do not change then my issue maybe fixed. It's just my opinion.

 

And one more thing if you have any idea of how to get rotation angles values from world matrix which is 4x4 then please share it with me.

 

Thanks

Best Regards

0 Likes
Message 4 of 5

sinje_thiedemann
Autodesk
Autodesk

Separate tracking and model transformation is a proper solution in my opinion.

 

Regarding the pivot: The pivot values in Object space should stay the same when changing the translation of the same node. In World space not, because the pivot moves together with the node, it is not fixed in the world. But this is the same when adding a parent node above and moving that, the pivot of the child node will move (in the world) together with the translation of the parent. It is hard to tell from a distance what is happening in your case.


Extracting rotation: If you do want to set the complete transformation (translation and rotation) anyway, just set the matrix as it is to the node:

trackerNode.setTransformMatrix( tracker0.getWorldMatrix(), False)

The trackerNode must be a "Matrix Transform" created in GUI with Create > Matrix Transform, or with Python createNode("Transform").

If you specifically need the rotation angles as well, the easiest way should be to call getRotation() on the trackerNode afterwards.

 

Method "getWorldMatrix" for the tracker is actually from the API v1 which is deprecated for VR since 2020.1.

 

If you're not working with an existing legacy script but are in the process of creating a new one, I suggest switching to the API v2 for VR.

 

The example for attaching a node to a tracker in API v2 recommends using a constraint. Constraints are only available in API v2 and pure scripting functionality, constraints cannot be managed in GUI yet.
Since 2021.3 it is possible to work with transformations in API v2. I guess you can then also query the matrix of the device with device.getNode().getWorldTransform().

 

Kind regards

Sinje

Message 5 of 5

nharis7
Participant
Participant

Hi Sinje,

Thanks for your detailed response and in your second reply this is what I am already doing through my scripts. So, there is not a way to do all this without getting a parent node. But if there is a way to do this without adding a parent node do let me know because I don't want to add a parent node every time. I just want to set a rotation pivot of the object and then it should follow my tracker on that rotation but rotation pivot values are kept changing with translation. Anyway thanks for help but if you have something else for me do share with me.

Greetings

Haris

0 Likes