Setting Pos and Hpr with VRPN tracker data

I’m having trouble getting orientation data from an intersense cube connected through VRPN. Roll and heading were swapped and pitch was inverted without any modifications to the matrix, but it’s seems that no matter what I do for swapping and negating, something else goes wrong with the orientation. Position shows up correctly in the bottom of the matrix, but I’m not sure how to handle the 3x3 in the top left of the self.tracker0 matrix. I have tried multiplying it by a transform (YupRight to ZupRight(pandas?) ) but orientation is still wrong… Is there some other transform I can apply to correct the Hpr data? Thanks :slight_smile:

from pandac.PandaModules import *

class World(DirectObject):
	def __init__(self):

		self.vrpnclient = VrpnClient('')
		self.tracker0 = TrackerNode(self.vrpnclient,"")
		base.dataRoot.node().addChild(self.tracker0)

		taskMgr.add(self.update,"updateTask")


	def update(self,task):

		self.vrpnclient.poll()
		newMat = self.tracker0.getTransform()
		base.cam.setMat(newMat)

Maybe you can switch the coordinate system to match your input. For example:

from pandac.PandaModules import loadPrcFileData
loadPrcFileData('', 'coordinate-system yup')

(this must go before your other code)
Of course this changes the coordinate system for your whole program, but that might not be a bad thing if you are used to working in a Y-up coordinate space.

Looks like that did the trick, after negating the heading and pitch everything works perfectly! Thanks a bunch for your help :slight_smile:

Some months are passed since the last post in this thread, but I had a similar problem in these days and I used a different solution, without changing the global coordinate system.

I share it because it may be useful.

I use a Polhemus Fastrak, whose coordinate system has pitch and roll axis inverted, and positive heading axis going down (so: Z positive down, X positive forward, Y positive right).

I used a dummy NodePath as parent for two nodes: one for the tracker, and one for the model of a hand. The two nodes are not parented with each other.

I can then query the position and the orientation of the tracker node, and apply the data back to the model node, switching the coordinates and negating values where needed.

I hope it helps.

Davide