WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 07-04-2012, 10:17 PM
snovob93 snovob93 is offline
Member
 
Join Date: Jun 2012
Posts: 6
Timer issues

Below is the script we are using for the project. I wish to add a timer that starts as soon as the file is run and records the time and target number that was touched. It should keep doing this as each target is touched.
Hope someone can help!


import viz
import vizact
import vizproximity
import viztask
import random

#Define session parameters
nTrial = 10;
nTargetList = [1,2,3,1,2,3,1,2,3,1];
#nRandList = random.shuffle(nTargetList)
print nTargetList

viz.setMultiSample(4)
viz.fov(60)
viz.go()

#Create Background and Main View
viz.clearcolor(viz.BLACK)

viz.MainView.setPosition(0,2,-6)

#Create Floor
floor = viz.add('ground.osgb')

#Connect to server at specified IP address
phasespace = viz.add('phasespace.dle',0,'10.3.6.119:2')

#Add first marker
marker1 = phasespace.addMarker(1)

#Target Marker (finger)
marker2 = phasespace.addMarker(5)
ball = viz.add('white_ball.wrl',color=viz.RED,cache=viz.C ACHE_CLONE)
viz.link(marker2,ball, priority=1)

#Create proximity manager
manager = vizproximity.Manager()
manager.setDebug(viz.ON)

#Spheres 1 : 4
spheres = []
sphereSensors = []
sphere1 = viz.add('ball.wrl')
sphere1.setPosition([0,0,0])
spheres.append(sphere1)
#proximity sensor-sphere
sphereSensor1 = vizproximity.Sensor(vizproximity.Box([0.5,0.5,0.5],center=[0,0.1,0]),source=sphere1)
#Add sensors to manager (sphere)
manager.addSensor(sphereSensor1)
sphereSensors.append(sphereSensor1)
sphere2 = viz.add('ball.wrl')
sphere2.setPosition([0,0.5,0])
spheres.append(sphere2)
#proximity sensor-sphere
sphereSensor2 = vizproximity.Sensor(vizproximity.Box([0.5,0.5,0.5],center=[0,0.1,0]),source=sphere2)
#Add sensors to manager (sphere)
manager.addSensor(sphereSensor2)
sphereSensors.append(sphereSensor2)
sphere3 = viz.add('ball.wrl')
sphere3.setPosition([0,1,0])
spheres.append(sphere3)
#proximity sensor-sphere
sphereSensor3 = vizproximity.Sensor(vizproximity.Box([0.5,0.5,0.5],center=[0,0.1,0]),source=sphere3)
#Add sensors to manager (sphere)
manager.addSensor(sphereSensor3)
sphereSensors.append(sphereSensor3)
sphere4 = viz.add('ball.wrl')
sphere4.setPosition([0,1.5,0])
spheres.append(sphere4)
#proximity sensor-sphere
sphereSensor4 = vizproximity.Sensor(vizproximity.Box([0.5,0.5,0.5],center=[0,0.1,0]),source=sphere4)
#Add sensors to manager (sphere)
manager.addSensor(sphereSensor4)
sphereSensors.append(sphereSensor4)


#Add main viewpoint as proximity target
target = vizproximity.Target(marker2)
#Add viewpoint target to manager
manager.addTarget(target)

def destinationsTask():
fade1 = vizact.fadeTo(0,speed=2)
fade2 = vizact.fadeTo(1,speed=2)
spheres[1].addAction(fade1)
spheres[2].addAction(fade1)
spheres[3].addAction(fade1)
x = 1;
while x <= nTrial:
print 'Reach to start.'
yield viztask.waitTime(2)
yield vizproximity.waitEnter(sphereSensors[0])
spheres[0].addAction(fade1)
spheres[nTargetList[x]].addAction(fade2)
print 'Reach to target.'
yield viztask.waitTime(1)
yield vizproximity.waitEnter(sphereSensors[nTargetList[x]])
spheres[nTargetList[x]].addAction(fade1)
spheres[0].addAction(fade2)
x = x + 1;
print 'The end.'

viztask.schedule( destinationsTask() )
Reply With Quote
  #2  
Old 07-06-2012, 06:03 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,458
Register a callback function for the EnterProximity event. Within the callback function you can record the sensor and simulation time to a file:
Code:
def EnterProximity(e):
	"""@args vizproximity.ProximityEvent()"""
	sensor = e.sensor
	time = viz.getFrameTime()
	
	#record sensor and time to file

manager.onEnter(None,EnterProximity)
Reply With Quote
Reply

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
Question about Vizard Expiration Timer Rate mizutani_jun Vizard 2 02-23-2011 10:13 PM
Timer event in viztask GiudiceLab Vizard 1 10-07-2010 01:14 PM
timer question again Elittdogg Vizard 3 10-18-2007 11:29 AM
Timer speed Jerry Vizard 1 12-08-2006 12:01 PM
timer paulpars Vizard 2 06-14-2006 03:31 PM


All times are GMT -7. The time now is 01:37 PM.


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