Exemple #1
0
	def __init__(self):
		viz.mouse.setVisible(viz.OFF)
		#Activate NVIS HMD
		nvis.nvisorSX111()
		#nvis.nvisorSX60()
		viz.cursor(viz.OFF)
		#isense = viz.add('intersense.dls')
		vrpn = viz.add('vrpn7.dle')
		view = viz.MainView

		self.markers = []

		headMarker = vrpn.addTracker('PPT0@' + PPT_HOSTNAME, 0)
		self.markers.append(headMarker)
		self.markers.append( vrpn.addTracker('PPT0@' + PPT_HOSTNAME, 1) )
		self.markers.append( vrpn.addTracker('PPT0@' + PPT_HOSTNAME, 2) )
		self.markers.append( vrpn.addTracker('PPT0@' + PPT_HOSTNAME, 3) )
		self.markers.append( vrpn.addTracker('PPT0@' + PPT_HOSTNAME, 4) )

		filter = viz.add("filter.dle")
		headMarker_filter = filter.average(headMarker, samples = 7)

		headPos = viz.link(headMarker_filter, view, priority = 0)
		headPos.setOffset(DEFAULT_OFFSET)
		self.posLink = headPos
		#self.posLink.postScale(DEFAULT_SCALE)
		self.headMarker = headMarker
    def setup_world(self):
        viz.setOption('viz.fullscreen.monitor', 1)
        #viz.setOption('viz.window.width', 2560)
        #viz.setOption('viz.window.height', 1040)
        #viz.setMultiSample(4)
        #viz.MainWindow.clip(0.01, 500)
        #viz.vsync(1)

        vizconfig.register(nvis.nvisorSX111())

        viz.go(viz.FULLSCREEN)
Exemple #3
0
    def __init__(self, cfg, enabled=1, displayList=None):

        type = cfg['type']
        offset = cfg['offset']
        overlap = cfg['overlap']
        fov = cfg['fov']
        #self.hmdstats = self.HMDStats(offset, overlap)
        self.enabled = enabled

        if enabled:

            if 'nvis' == type:

                import nvis
                self.hmd = nvis.nvisorSX111()

                #vizconfig.register(self.hmd)
                print "HMD type: NVIS SX111"

                print '*** Offset:' + str(viz.MainWindow.getViewOffset())

            elif 'oculus' == type:

                import oculus
                self.hmd = oculus.Rift()
                print "HMD type: Oculus Rift"
                #vizconfig.register(self.hmd)
                #self.updateOverlap(self.hmdstats.overlap-self.hmd._overlap)

            elif 'DK2' == type:

                self.setupOculusMon(displayList)
                self.hmd = vizconnect.getTracker('rift')

            else:
                print "Unsupported HMD type when starting HMD"
                sys.exit(1)

#			import vizconfig
#			vizconfig.register(self.hmd)

            if (overlap > -1):
                self.updateOverlap(self.hmdstats.overlap - self.hmd._overlap)
            else:
                defaultOverlap = 100
                self.hmdstats = self.HMDStats(viz.MainWindow.getViewOffset,
                                              defaultOverlap)

            #print 'After: ' + str(viz.MainWindow.getViewOffset()) + str(viz.MainWindow.stereoOverlap())
            #self.hmdstats = self.HMDStats(viz.MainWindow.getViewOffset, viz.MainWindow.stereoOverlap)

        else:
            self.hmd = None
            print "HMD disabled"
Exemple #4
0
def setup():
	global lhPPT, rhPPT, headPPT, headLink;
	global lhSphere, rhSphere
	
	nvis.nvisorSX111();
	#nvis.nvisorSX60();
	viz.mouse.setVisible(False)
	#viz.cursor(viz.OFF);
	view = viz.MainView
	isense = viz.add('intersense.dle')
	headTracker = isense.addTracker(port=1)
	vizact.onkeydown('r',headTracker.resetHeading)
	vrpn = viz.add('vrpn7.dle');
	PPT_HOSTNAME = '171.64.33.43';
	headPPTorig = vrpn.addTracker('PPT0@' + PPT_HOSTNAME, 0);

	#Merge two links together
	headPPT = viz.mergeLinkable(headPPTorig,headTracker)
	headLink = viz.link(headPPT, viz.MainView);
	headLink.postTrans([EYE_VECTOR[0], EYE_VECTOR[1], EYE_VECTOR[2]]);
	
	#now add the PPT hands tracker
	rhPPT = vrpn.addTracker('PPT0@' + PPT_HOSTNAME, 1)
	lhPPT = vrpn.addTracker('PPT0@' + PPT_HOSTNAME, 2)
	
	grid = vizshape.addGrid();
	grid.color([0.5] * 3);
	
	viz.callback(viz.KEYDOWN_EVENT, onKeyDown);
	
	if(DEBUG_MODE):
		print "adding spheres";
		rhSphere = vizshape.addSphere(radius = 0.1, color = viz.WHITE);
		lhSphere = vizshape.addSphere(radius = 0.1, color = viz.WHITE);
		rfSphere = vizshape.addSphere(radius = 0.1, color = viz.WHITE);
		lfSphere = vizshape.addSphere(radius = 0.1, color = viz.WHITE);
		

	
	return;
	def __init__(self, cfg, enabled=1):
		
		type = cfg['type']
		offset = cfg['offset']
		overlap = cfg['overlap']
		fov = cfg['fov']
		#self.hmdstats = self.HMDStats(offset, overlap)
		self.enabled = enabled
		
		if enabled:
			
			if 'nvis' == type:
				
				import nvis
				self.hmd = nvis.nvisorSX111()
				
				#vizconfig.register(self.hmd)
				print "HMD type: NVIS SX111"
				
				print '*** Offset:' + str( viz.MainWindow.getViewOffset() )
			elif 'oculus' == type:
			
				import oculus
				self.hmd = oculus.Rift()
				print "HMD type: Oculus Rift"
				#vizconfig.register(self.hmd)
				#self.updateOverlap(self.hmdstats.overlap-self.hmd._overlap)
			
			else:
				print "Unsupported HMD type when starting HMD"
				sys.exit(1)
			
			import vizconfig
			vizconfig.register(self.hmd)
			
			if(overlap > -1 ):
					self.updateOverlap(self.hmdstats.overlap-self.hmd._overlap)
			else:
				defaultOverlap = 100
				self.hmdstats = self.HMDStats(viz.MainWindow.getViewOffset, defaultOverlap)
				
			#print 'After: ' + str(viz.MainWindow.getViewOffset()) + str(viz.MainWindow.stereoOverlap())
			#self.hmdstats = self.HMDStats(viz.MainWindow.getViewOffset, viz.MainWindow.stereoOverlap)
			
			
		else:
			self.hmd = None
			print "HMD disabled"
def main():
    viz.setOption('viz.fullscreen.monitor', 1)
    viz.setOption('viz.window.width', 2 * 640)
    viz.setOption('viz.window.height', 480)
    viz.setMultiSample(4)
    viz.MainWindow.clip(0.01, 500)

    vizconfig.register(nvis.nvisorSX111())

    viz.go(viz.FULLSCREEN)

    piazza = viz.addChild('piazza.osgb')

    mocap = phasespace.Mocap('192.168.1.230')

    head = mocap.track_rigid('Resources/hmd-nvis.rb', center_markers=(0, 5))
    head.link_pose(viz.MainView)

    glove = mocap.track_points([8, 9, 10])

    paddle = mocap.track_rigid({
        17: (0, 0, 1),
        19: (0, 0, 0),
        20: (1, 0, 0),
        22: (0, 1, 0),
    })

    mocap.start_thread()

    #mocap.start_timer()

    def log_mocap(timer_id):
        print 'glove#9 pos {0[1]:.2f} {0[1]:.2f} {0[2]:.2f}'.format(
            *glove.get_marker(9))
        print 'head    pos {0[0]:.2f} {0[1]:.2f} {0[2]:.2f}, quat {1[0]:.3f} {1[1]:.3f} {1[2]:.3f} {1[3]:.3f}'.format(
            *head.get_pose())
        print 'paddle  pos {0[0]:.2f} {0[1]:.2f} {0[2]:.2f}, quat {1[0]:.3f} {1[1]:.3f} {1[2]:.3f} {1[3]:.3f}'.format(
            *paddle.get_pose())

    viz.callback(viz.TIMER_EVENT, log_mocap)
    viz.starttimer(0, 1, viz.FOREVER)

    def keydown(*args):
        head.reset()
        paddle.reset()

    viz.callback(viz.KEYDOWN_EVENT, keydown)
def main():
    viz.setOption('viz.fullscreen.monitor', 1)
    viz.setOption('viz.window.width', 2 * 640)
    viz.setOption('viz.window.height', 480)
    viz.setMultiSample(4)
    viz.MainWindow.clip(0.01, 500)

    vizconfig.register(nvis.nvisorSX111())

    viz.go(viz.FULLSCREEN)

    piazza = viz.addChild('piazza.osgb')

    mocap = phasespace.Mocap('192.168.1.230')

    head = mocap.track_rigid('Resources/hmd-nvis.rb', center_markers=(0, 5))
    head.link_pose(viz.MainView)

    glove = mocap.track_points([8, 9, 10])

    paddle = mocap.track_rigid({
      17:(0, 0, 1),
      19:(0, 0, 0),
      20:(1, 0, 0),
      22:(0, 1, 0),
    })

    mocap.start_thread()
    #mocap.start_timer()

    def log_mocap(timer_id):
        print 'glove#9 pos {0[1]:.2f} {0[1]:.2f} {0[2]:.2f}'.format(*glove.get_marker(9))
        print 'head    pos {0[0]:.2f} {0[1]:.2f} {0[2]:.2f}, quat {1[0]:.3f} {1[1]:.3f} {1[2]:.3f} {1[3]:.3f}'.format(*head.get_pose())
        print 'paddle  pos {0[0]:.2f} {0[1]:.2f} {0[2]:.2f}, quat {1[0]:.3f} {1[1]:.3f} {1[2]:.3f} {1[3]:.3f}'.format(*paddle.get_pose())

    viz.callback(viz.TIMER_EVENT, log_mocap)
    viz.starttimer(0, 1, viz.FOREVER)

    def keydown(*args):
        head.reset()
        paddle.reset()

    viz.callback(viz.KEYDOWN_EVENT, keydown)
    def __init__(self, cfg, enabled=True):
        type = cfg['type']
        offset = cfg['offset']
        overlap = cfg['overlap']
        fov = cfg['fov']

        self.enabled = enabled
        self.hmd = None
        if not enabled:
            print 'HMD disabled'
            return

        if 'nvis' == type:
            import nvis
            self.hmd = nvis.nvisorSX111()
            print 'HMD type: NVIS SX111'

        elif 'oculus' == type:
            import oculus
            self.hmd = oculus.Rift()
            print 'HMD type: Oculus Rift'

        else:
            raise RuntimeError('Unsupported HMD type when starting HMD')

        vizconfig.register(self.hmd)

        if overlap < 0:
            overlap = 100

        self.stats = HMD.Stats(viz.MainWindow.getViewOffset, overlap)
        amount = self.stats.overlap - self.hmd._overlap
        self.hmd._overlap += amount
        offset = (self.hmd._hfov - self.hmd._overlap) / 2.0
        viz.MainWindow.setViewOffset(
            viz.Matrix.euler(-offset, 0.0, self.hmd._leftRollShift),
            eye=viz.LEFT_EYE)
        viz.MainWindow.setViewOffset(
            viz.Matrix.euler( offset, 0.0, self.hmd._rightRollShift),
            eye=viz.RIGHT_EYE)
        self.stats.offset = offset
        self.stats.overlap = self.hmd._overlap
        print 'Overlap', self.stats.overlap, 'Offset', self.stats.offset
Exemple #9
0
	vizact.onkeydown( 'p', mocap.resetRigid, 'torch' );
	
	# Allows one to link to the HMD rigid body , or use keyboard/mouse to navigate
	vizact.onkeydown('l',mocap.linkMainViewToHead)
	vizact.onkeydown('d',mocap.detatchMainViewFromHead)
	
	trackerId = 0
	markerIDOnTracker = 0
	vizact.onkeydown('m',mocap.getMarkerPosition,trackerId ,markerIDOnTracker )# not well debugged yet!
	
	if( mocap.mainViewLinkedToHead ):
		'LInked'
		
		#import oculus
		#hmd = oculus.Rift()
		
		import nvis
		hmd = nvis.nvisorSX111()
		
		#print "HMD IPD: " + str(hmd.getIPD())
		#print "Mainvtiew IPD: " + str(viz.MainWindow.getIPD())

	viz.window.setFullscreenMonitor([1,2]) 
	viz.setMultiSample(4)
	
	viz.go(viz.FULLSCREEN)
	#Add a world axis with X,Y,Z labels
	world_axes = vizshape.addAxes()
	X = viz.addText3D('X',pos=[1.1,0,0],color=viz.RED,scale=[0.3,0.3,0.3],parent=world_axes)
	Y = viz.addText3D('Y',pos=[0,1.1,0],color=viz.GREEN,scale=[0.3,0.3,0.3],align=viz.ALIGN_CENTER_BASE,parent=world_axes)
	Z = viz.addText3D('Z',pos=[0,0,1.1],color=viz.BLUE,scale=[0.3,0.3,0.3],align=viz.ALIGN_CENTER_BASE,parent=world_axes)
Exemple #10
0
    vizact.onkeydown('l', mocap.linkMainViewToHead)
    vizact.onkeydown('d', mocap.detatchMainViewFromHead)

    trackerId = 0
    markerIDOnTracker = 0
    vizact.onkeydown('m', mocap.getMarkerPosition, trackerId,
                     markerIDOnTracker)  # not well debugged yet!

    if (mocap.mainViewLinkedToHead):
        'LInked'

        #import oculus
        #hmd = oculus.Rift()

        import nvis
        hmd = nvis.nvisorSX111()

        #print "HMD IPD: " + str(hmd.getIPD())
        #print "Mainvtiew IPD: " + str(viz.MainWindow.getIPD())

    viz.window.setFullscreenMonitor([1, 2])
    viz.setMultiSample(4)

    viz.go(viz.FULLSCREEN)
    #Add a world axis with X,Y,Z labels
    world_axes = vizshape.addAxes()
    X = viz.addText3D('X',
                      pos=[1.1, 0, 0],
                      color=viz.RED,
                      scale=[0.3, 0.3, 0.3],
                      parent=world_axes)