WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Thread Tools Rate Thread Display Modes
Old 10-08-2018, 11:17 AM
tianmoran tianmoran is offline
Join Date: Nov 2016
Posts: 16
Mark & Print Oculus data

Hi there,

I'm coding for an experiment but muddled with some trouble. My goal is to record the Oculus data(position, euler) every 50ms. At the same time, I need to mark some events, like below the events are 'cylinder is on', 'key pressed', 'cylinder is off'. So I put a variable called 'Event' and hope to change its value right after each event happens. Unfortunately, it didn't work.

I kind of know why it's not working. But is there any solution on that?

Thank you so much if anyone would like to help me out!!!

import viz
import vizact
import vizshape
import viztask
import vizinput
import vizinfo
import time
import random											        	   
import oculus														
import vizfx
import numpy
from numpy import *


hmd = oculus.Rift()
oculus = viz.addGroup()
oculusView =, viz.MainView)							

def Demo():
	global   acc, RT, Keycode, trialNo, oculus, oculusView, Cond, FMM, Code_direct, Event, trial, block, unit, acc, RT, Keycode, trialNo, oculus, oculusView,oculus_timer, Group, Code_Type, Code_Letter, FirstTrial
	FirstTrial = 1
	Instr = vizshape.addCylinder(1,0.05) 							
	yield viztask.waitTime(0.5)
	Oculusdata = open('testtest'+ "_Oculus.txt",'a',1)
	for trial in range(10):
		###### Calculating Reaction Time
		def df():
			global startTime
			startTime = viz.tick()
			print str(trial), 'startTime', startTime
		yield vizact.ontimer2(1,0,df)
		Event = 0
		def waitkeydown():
			global r, KeyPress, startTime
			r = yield viztask.waitKeyDown(None)

			if r.key == 'j':
				acc[0][trial] = 1			
				Keycode[0][trial] = 2 	### Key J is pressed
			elif r.key == 'f':
				acc[0][trial] = 0  		
				Keycode[0][trial]= 1 		### Key F is pressed
		yield viztask.waitAny([waitkeydown(), viztask.waitTime(3)])
		Event = 1
		Event = 2
		def printOculusData():
			global oculus_timer
			oculus_timer = viz.tick()
			OculusData = "%s\t%s\t%s\t%s\t%s\n" %(trial, Event,oculus_timer,oculusView.getPosition(), oculusView.getEuler())
		if FirstTrial == 1:
			FirstTrial = 0
Reply With Quote

events, oculus

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Vizard and Matlab sagar29 Vizard 7 12-25-2017 10:36 PM
Sending data from MATLAB(Simulink) to Vizard sagar29 Vizard 0 01-05-2017 03:31 PM
Oculus runtime disrupts clustering to mirror DK2 display performlabrit Vizard 1 01-23-2015 07:00 AM
about a pair game emily800326 Vizard 2 11-06-2012 07:45 AM
Crashing when I select Tracker option GoldenSun Vizard 4 07-01-2008 11:06 AM

All times are GMT -7. The time now is 09:47 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC