View Single Post
Old 06-16-2014, 06:43 AM
shivanangel shivanangel is offline
Join Date: Feb 2006
Location: New Jersey
Posts: 182
Solution to the problem for future interested parties:

1) Setup output in DTrack2 for the flystick or any other device you plan on using.
2) Setup the VRPN server. You can either download the windows binaries online or by registering your SmartTrack with A.R.T. they will provide a download location.
3) Edit the VRPN config file by searching for DTrack. You'll want to uncomment the following line:
vrpn_Tracker_DTrack DTrack 5000
4) Start your DTrack2 and press the start button to begin tracking and trasmitting.
5) Start your VRPN Server
6) Connect to the VRPN Server using WorldViz Vizard at the following:
device_label = "DTrack@"
vrpn_source = device_label +  ip_address
vrpn = viz.add('vrpn7.dle')
tracker = 	vrpn.addTracker( vrpn_source )
buttons = 	vrpn.addButton(  vrpn_source )
joystick = vrpn.addAnalog(  vrpn_source )
7) Your VRPN server should have spit out some command line notification about Vizard connecting and eventually disconnecting.

Still working on the proper orientations and making the device work the way I expect in Vizard.

class FlyStick2:
	device_label = "DTrack@"
	#Button Layout
	#1 -  Trigger
	#2 - Far Right
	#3 - Middle Right
	#4 - Middle Left
	#5 - Far Left
	#6 - Analog Push in
	def __init__(self, ip_address = 'localhost'):
		vrpn_source = self.device_label +  ip_address
		vrpn = viz.add('vrpn7.dle')
		self.tracker = 	vrpn.addTracker( vrpn_source )
		self.buttons = 	vrpn.addButton(  vrpn_source )
		self.joystick = vrpn.addAnalog(  vrpn_source )
		#Swap position and orientation to match Vizard's coordinate system
		#The states of the controller button (are they down)
		self.button_states = [ False, False, False, False, False, False]
		self.analog_x = 0.0
		self.analog_y = 0.0		
		viz.callback( viz.SENSOR_DOWN_EVENT, self.onButtonDown )
		viz.callback( viz.SENSOR_UP_EVENT, self.onButtonUp )
		viz.callback( viz.TIMER_EVENT, self.onTimer )
		viz.starttimer( 0, 0.01, viz.PERPETUAL )

	def onTimer(self, timer_id ):
		Polls the analog and position information
		self.analog_x, self.analog_y = self.joystick.getData()[0:2]
		#print self.analog_x, self.analog_y

	def onButtonDown(self, event):
		if event.object is self.buttons:
			#print 'onButtonDown', event.button
			self.button_states[event.button] = True

	def onButtonUp(self, event):
		if event.object is self.buttons:
			#print 'onButtonUp', event.button
			self.button_states[event.button] = False
Reply With Quote