View Single Post
  #1  
Old 08-11-2009, 10:40 PM
_kj_ _kj_ is offline
Member
 
Join Date: Aug 2009
Posts: 2
The problem of tracker using via VRPN

Greetings to everyone!

We develop a small application in WorldViz. The viewport rotation must be implemented through 3DOF trackers in this application. Using embedded WorldViz driver for InterSense tracker, app works well. InterSense is used as follows:

Code:
viz.go( viz.TRACKER )
tracker = viz.add( 'intersense.dls' )
vizact.onupdate( 0, UpdateView )

def UpdateView():
	yaw, pitch, roll = tracker.getEuler()
	viz.MainView.setEuler( GetOrderedAndInvertedViewAngles( yaw, pitch, roll ), viz.BODY_ORI )

# Return ordered and inverted view angles depends on current settings
def GetOrderedAndInvertedViewAngles( yaw, pitch, roll ):
	# order:
	if view_angles_order_1.get() == viz.DOWN:
		y = yaw
		p = pitch
		r = roll
	elif view_angles_order_2.get() == viz.DOWN:
		y = pitch
		p = yaw
		r = roll
	elif view_angles_order_3.get() == viz.DOWN:
		y = pitch
		p = roll
		r = yaw
	elif view_angles_order_4.get() == viz.DOWN:
		y = yaw
		p = roll
		r = pitch
	elif view_angles_order_5.get() == viz.DOWN:
		y = roll
		p = pitch
		r = yaw
	elif view_angles_order_6.get() == viz.DOWN:
		y = roll
		p = yaw
		r = pitch
	# invert:
	if view_angles_invert_yaw.get() == viz.DOWN:
		y = -y
	if view_angles_invert_pitch.get() == viz.DOWN:
		p = -p
	if view_angles_invert_roll.get() == viz.DOWN:
		r = -r
	return [y, p, r]
But if we use WorldViz VRPN driver, the viewport rotations will go incorrect. If in zero orientation up/down tracker rotations result in up/down viewport rotations respectively, while turning tracker 90 degrees to the left/right, up/down tracker rotations will no longer result in proper up/down viewport rotations, but in left/right viewport roll... It seems that tracker and viewport work in different coordinate systems. We tried all combinations of flags in viz.MainView.setEuler() method and there was no combination that worked properly. It seems that the flag viz.ABS_LOCAL does not generally work correctly, because it works exactly the same as the viz.REL_LOCAL flag, so it interprets rotation angles as relative but not absolute, as it must be according to the flag`s name and its description in WorldViz help. There is a code:

Code:
viz.go()

vrpn = viz.add( 'vrpn7.dle' )
tracker = vrpn.addTracker( 'Head@localhost' )

def UpdateView():
	yaw, pitch, roll = tracker.getEuler()
	viz.MainView.setEuler( GetOrderedAndInvertedViewAngles( yaw, pitch, roll ), viz.BODY_ORI )

# Return ordered and inverted view angles depends on current settings
def GetOrderedAndInvertedViewAngles( yaw, pitch, roll ):
	# order:
	if view_angles_order_1.get() == viz.DOWN:
		y = yaw
		p = pitch
		r = roll
	elif view_angles_order_2.get() == viz.DOWN:
		y = pitch
		p = yaw
		r = roll
	elif view_angles_order_3.get() == viz.DOWN:
		y = pitch
		p = roll
		r = yaw
	elif view_angles_order_4.get() == viz.DOWN:
		y = yaw
		p = roll
		r = pitch
	elif view_angles_order_5.get() == viz.DOWN:
		y = roll
		p = pitch
		r = yaw
	elif view_angles_order_6.get() == viz.DOWN:
		y = roll
		p = yaw
		r = pitch
	# invert:
	if view_angles_invert_yaw.get() == viz.DOWN:
		y = -y
	if view_angles_invert_pitch.get() == viz.DOWN:
		p = -p
	if view_angles_invert_roll.get() == viz.DOWN:
		r = -r
	return [y, p, r]
Could anybody give a sample code of using 3DOF tracker for viewport control via VRPN, that is working properly?
Reply With Quote