def ExitProximity(e):
 global lSelectedNode, rSelectedNode, lhandtarget, rhandtarget, molecExited, h2omodels, NUM_H2O
 print "moleucle has left the building!!"
 print "exit prox: ", lSelectedNode, rSelectedNode
#drop molecule to specified place

 obj = None
 if e.target == lhandtarget:
  obj = lSelectedNode
  lSelectedNode = None
  moleculeManager.removeTarget(lhandtarget)

 elif e.target == rhandtarget: 
  obj = rSelectedNode
  rSelectedNode = None
  moleculeManager.removeTarget(rhandtarget)
 rhGrabber.removeItems([obj])
 lhGrabber.removeItems([obj])
 print obj
 molecExited = True

 '''x,y,z = (h2omodels[0]).getPosition()
 x += .5
 moveToH2O = vizact.moveTo([x,y,z] , speed = .75)
 obj.addAction(moveToH2O)
 print "should be moving!"'''
 
 viztask.schedule(moveCO2toH2O(obj))
 #start molecule combination animation
 #hide and remove h20 and co2 molecules
 '''obj.visible(viz.OFF)
Ejemplo n.º 2
0
	def custom_walk(self, points):
		self.points = points
		self.place_points = 0
		self.avatar.setPosition(points[0][0])
		self.next_point = points[0][0]
		self.next_speed = points[0][1]
		viztask.schedule(self.start_custom_walk())
Ejemplo n.º 3
0
def startThreeTouch():
	#Captures the initial timeFrame whent the cubes are set up.
	global hfScoreTimes
#	global startTime
#	startTime = time.clock()
	viztask.schedule(playThreeTouch)
	print "scheduled the game at time = " + str(time.clock())
Ejemplo n.º 4
0
def startZone3Hunt():
 global SWIM_ZONE_TO_ZONE_COMPLETE_EVENT
# yield viztask.waitEvent(scavengerhunt.ZONE1_OVER_EVENT)
# print "waiting for swimming to end"
# yield viztask.waitEvent(SWIM_ZONE_TO_ZONE_COMPLETE_EVENT)
# scavengerhunt.disableGrabber()
# globals_oa.basket.disable(viz.RENDERING)
 yield fader.fadeOutTask()
 globals_oa.AUDIO_ZONE_CUT_AMBIENT.play()
# globals_oa.ZONE3_TRANSITION.play()
 
 
 #Untested fish hiding
# for school in schooling.all_fish_schools:
#   chromis_chromis.hidePercentage(20)
#   diplodus_annularis.hidePercentage(100)
#   labrus_viridis.hidePercentage(100)
#   sarpa_salpa.hidePercentage(20)
 for school in schooling.all_fish_schools:
  school.hidePercentage(50)
 globals_oa.currentZoneNumber = 2
 transport_vhil.cycleZones()
 #viz.res.addPublishFile('data/speciesToFindZone3.txt')
 #scavengerhunt.initialize(globals_oa.terrainZone3, globals_oa.filePathToSpeciesForScavengerHuntInZone3) 
 #Enable swimming 
 yield fader.fadeInTask()
 globals_oa.AUDIO_ZONE3_AMBIENT.play()
 yield viztask.waitTime(3)
 globals_oa.ZONE3_AUDIO_1.play()
# playAudioAndSaveGlobalPointer(globals_oa.ZONE3_AUDIO_1)
 viztask.schedule(startBoatOutro())
Ejemplo n.º 5
0
def main():
	global masterTimerG, recordingTimer
	setUp()
	masterTimerG = vizact.ontimer(0, masterTimer)
	#recordingTimer = vizact.ontimer(0, recordCurrentSubjectStatus)
	
	if not KEYBOARD_NAVIGATE:
		addKeyPresses()
	else:
		# Setup keyboard/mouse tracker
		tracker = vizcam.addWalkNavigate(moveScale=10.0)
		tracker.setPosition([0,1.8,0])
		viz.link(tracker,viz.MainView)
		viz.mouse.setVisible(False)
		def printLocation():
			print viz.MainView.getPosition(), viz.MainView.getEuler()
		vizact.onkeydown('p', printLocation)
	
	
	#Add Wiimote support
#	wii = viz.add('wiimote.dle')
#	#Connect to first available wiimote
#	wiimote = wii.addWiimote()
#	wiimote.led = wii.LED_4
#	#Add button functions
#	vizact.onsensordown(wiimote,wii.BUTTON_A,TurnFlyingOn)
#	vizact.onsensordown(wiimote,wii.BUTTON_B,TurnFlyingOff)
#	vizact.onsensordown(wiimote,wii.BUTTON_1,endChildHappy)
#	
	#Hacky bug fix below, I apologize -Mark
	if not FLYING_F and YOKE_F:
		viztask.schedule(fixStartHeliPos) 
Ejemplo n.º 6
0
def MoveToNextStation():  # Leave Station
    print('Leaving Station')
    trainMove.play()  # Train Audio
    train.addAction(moveForward)  # Move train forward
    SetupHMD.MovePlayer()
    yield viztask.waitTime(30)  # Wait 30 seconds
    print('Reset Train Pos')
    train.setPosition(-120, -1, 6)  # Reset train at other end of tunnel

    if (SetupHMD.hmdconnected):
        SetupHMD.SetRotation(180)
        trainPos = train.getPosition()
        trainPos[1] += 1.5
        trainPos[2] += 1.6
        SetupHMD.SetPos(trainPos)
    else:
        pos = train.getPosition(viz.ABS_GLOBAL)
        pos[0] += 0.3  # Along Seat
        pos[1] = 1.7  # Eye Height
        pos[2] += 1.3  # Depth
        viz.MainView.setPosition(pos)
        viz.MainView.setEuler(180, 0, 0)

    yield viztask.waitTime(30)  # Wait 30 seconds
    print('Arrived at Station')
    trainMove.stop()  # Stop Audio
    viztask.schedule(StationReached())  # Trigger next function
Ejemplo n.º 7
0
	def __init__(self, dataset):
		self.modeName = ''
		
		self._maxThreads = 8
		self._curThreads = 0
		
		self._meshes			= []
		self._meshesByFilename	= {}
		self._keystones			= []
		self._proximityList		= []
		self._boundingBoxes		= {}
		self._keyBindings		= []
		self._inRange			= []
		
		self._meshesById	= {}
		
		self._boneInfo			= None
		self._closestBoneIdx 	= None
		self._prevBoneIdx		= None
		self._lastGrabbed 		= None
		self._lastMeshGrabbed	= None
		self._lastBoxGrabbed	= None
		self._highlighted		= None
		self._gloveLink			= None

		self._grabFlag		= False
		self._snapAttempts	= 0
		self._imploded		= False
		
		self._pointerTexture	= model.pointer.getTexture()
		self._pointerOrigColor	= model.pointer.getColor()

#		self.viewcube = puzzleView.viewCube()
		
		viztask.schedule(self.load(dataset))
Ejemplo n.º 8
0
	def collision( self ):
		#self.next_point = [self.next_point[0] - .1, 0, self.next_point[2] - .1] #get_quadrant(self.avatar.getPosition()).get_random_walk()#[self.avatar.getPosition()[0], 0, self.avatar.getPosition()[2] - 0.05]
		yield viztask.addAction(self.avatar, vizact.waittime(0.5))
		#self.avatar.lookat(self.next_point)
		#yield viztask.addAction(self.avatar, vizact.waittime(1))
		self.coll = 0
		viztask.schedule(self.walk_around())
Ejemplo n.º 9
0
 def saveScreenshot(self):
     """ Save a BMP screenshot of the current Vizard window """
     fn = 'svr_screenshot_{:d}.bmp'.format(self._next_screenshot)
     viz.window.screenCapture(fn)
     self._next_screenshot += 1
     viztask.schedule(showVRText('Screenshot saved.'))
     print('Screenshot saved.')
Ejemplo n.º 10
0
def check_pos_and_move():
    # Get currentcoordinates. Check to see if they match the "collide coordinates". If they do,
    # call learn_move
    x, y, z = viz.MainView.getPosition(viz.ABS_GLOBAL)
    if ((x >= collide_coords[0] and x <= collide_coords[1])
            and (z >= collide_coords[2] and z <= collide_coords[3])):
        viztask.schedule(learn_move())
Ejemplo n.º 11
0
	def load(self, dataset):
		"""
		Load datasets and initialize everything necessary to commence
		the puzzle game.
		"""
		
		# Dataset
		model.ds = bp3d.DatasetInterface()

		# Proximity management
		model.proxManager = vizproximity.Manager()
		target = vizproximity.Target(model.pointer)
		model.proxManager.addTarget(target)

		model.proxManager.onEnter(None, self.EnterProximity)
		model.proxManager.onExit(None, self.ExitProximity)

		#Setup Key Bindings
		self.bindKeys()

		self.score = PuzzleScore(self.modeName)
		
#		viztask.schedule(soundTask(glove))

		self._meshesToLoad = model.ds.getOntologySet(dataset)
		self._filesToPreSnap = model.ds.getPreSnapSet()
		
		yield self.loadControl(self._meshesToLoad)
		yield self.prepareMeshes()
		yield self.preSnap()
		yield self.setKeystone(1)
		
		viztask.schedule(self.updateClosestBone())
Ejemplo n.º 12
0
 def moveView(self):
     # move view
     xT,_,zT  = self.cTrial.getPos('src', 'near')
     moveTo = vizact.moveTo([xT,ct.EYE_HEIGHT,zT], speed=5)
     viz.MainView.addAction(moveTo)
  
     yield viztask.waitActionEnd(viz.MainView, moveTo)
  
     # make source building semi transparent
     self.cTrial.showBuilding('src', 'transparent')
     
     # align reference vertex to mainview
     self.refVert.setMatrix( viz.MainView.getMatrix() )
             
     # enable user mouse look
     WalkNavigate(forward='w', backward='s', left='a', right='d', moveScale=0, turnScale=1.0)
     
     vx, _, vz = viz.MainView.getPosition()
     # draw grid            
     self.cross90.setPosition(vx, 0.01, vz)
     self.cross90.visible(viz.ON)
             
     self.grid.setPosition(vx, 0.1, vz)
     self.grid.visible(viz.ON)
     
     viztask.schedule( self.getTargetAngle() )
Ejemplo n.º 13
0
def CrosshairDisplay(s):
	Piazza.visible(viz.OFF)
	GrassGround.visible(viz.OFF)
	crosshair.visible(viz.ON)
	viztask.schedule(ReturnToExperiment(s))
	stripe1.visible(viz.OFF)
	stripe2.visible(viz.OFF)
Ejemplo n.º 14
0
def playStory():
	global selectedAvatar, playing, avs
	
	if selectedAvatar.name == 'exit':
		viztask.schedule(playBusCloseAudio)
	else:
		selectedAvatar.story.play()
		playing = True
		toOutput = 'Started listening to ' + selectedAvatar.name
		dc.collect(toOutput)
		yield viztask.waitMediaEnd(selectedAvatar.story)
		
		playing = False
		selectedAvatar.done = True
		if selectedAvatar.name == 'son/father':
			for avatar in avs:
				if avatar.name == 'father/son':
					avatar.done = True
					break
		if selectedAvatar.name == 'father/son':
			for avatar in avs:
				if avatar.name == 'son/father':
					avatar.done = True
					break
		toOutput = 'Finished listening to ' + selectedAvatar.name
		dc.collect(toOutput)

		yield viztask.waitTime(0.1)
		selectedAvatar = None
Ejemplo n.º 15
0
	def __init__(self):
		#init canvas and create themes for the test panel
		self.canvas = viz.addGUICanvas(align = viz.ALIGN_CENTER_CENTER)
		self.canvas.setPosition(0,0,0)
		viz.mouse.setVisible(False)
		self.name = 'test'
		self._theme = viz.Theme()
		self._theme.borderColor = (0.1,0.1,0.1,1)
		self._theme.backColor = (0.4,0.4,0.4,1)
		self._theme.lightBackColor = (0.6,0.6,0.6,1)
		self._theme.darkBackColor = (0.2,0.2,0.2,1)
		self._theme.highBackColor = (0.2,0.2,0.2,1)
		self._theme.textColor = (1,1,1,1)
		self._theme.highTextColor = (1,1,1,1)
		
		#initialize test panel
		vizdlg.Panel.__init__(self, parent = self.canvas, theme = self._theme, align = viz.ALIGN_CENTER_TOP, fontSize = 15)
		self.visible(viz.OFF)
		self.setScale(*[i*config.menuScale[self.name] for i in [1,1,1]])
		self.alpha(0.6)
		
#		#title
		title = vizdlg.TitleBar('INSTRUCTIONS')
		self.addItem(title, align = viz.ALIGN_CENTER_TOP)
		
		#bones to be snapped. source snapped to target.
		source = 'a'*20
		self.sourceText = viz.addTextbox(parent = self.canvas)
		self.sourceText.setLength(1.5)
		target = 'a'*20
		self.targetText = viz.addTextbox(parent = self.canvas)
		self.targetText.setLength(1.5)
		
		#instructions 
		self.Instruct1 = self.addItem(viz.addText('Snap the: ', parent = self.canvas), align = viz.ALIGN_CENTER_TOP)
		self.sourceCommand = self.addItem(self.sourceText, align = viz.ALIGN_CENTER_TOP)
		self.Instruct2 = self.addItem(viz.addText('To the: ', parent = self.canvas), align = viz.ALIGN_CENTER_TOP)
		self.targetCommand = self.addItem(self.targetText, align = viz.ALIGN_CENTER_TOP)
		
		#render canvas
		
		if config.dispMode == config.DisplayMode.monitor:
			self.canvas.billboard(viz.BILLBOARD_YAXIS)
			self.canvas.setPosition(-2,0,0)
			self.canvas.setBackdrop(viz.ALIGN_CENTER_TOP)
			

		if config.dispMode == config.DisplayMode.oculus:

			bb = self.canvas.getBoundingBox()
			self.canvas.setRenderWorldOverlay([bb.width*1, bb.height*1], fov = bb.height, distance = 0.4)
			self.canvas.setPosition(0,0.05,0)
			self.canvasViewPos = self.canvas.getPosition()
			self.canvas.setEuler(0,15,0)
			self.canvas.setPosition(0, -5, 0)
			self.canvasHidePos = self.canvas.getPosition()
			viztask.schedule(self.updatePanelPos())
			
		vizact.onkeydown(viz.KEY_ESCAPE, self.toggle)
Ejemplo n.º 16
0
def MainTask():
    """Top level task that controls the game"""

    # Display instructions and wait for key press to continue
    yield DisplayInstructionsTask()
    tracker = vizcam.addWalkNavigate(moveScale=2.0)
    tracker.setPosition([0, 2.5, 0])
    viz.link(tracker, viz.MainView)
    viz.mouse.setVisible(False)

    # Create panel to display trial results
    resultPanel = vizinfo.InfoPanel('',
                                    align=viz.ALIGN_CENTER,
                                    fontSize=25,
                                    icon=False,
                                    key=None)
    resultPanel.visible(False)

    # Reset score
    score = 0
    UpdateScore(score)
    sensors()
    found = True
    number = 0

    while found and number < 7:
        # Perform a trial
        found = False
        found = yield TrialTask()

        # Update score and display status text
        if found:
            score += 1
            UpdateScore(score)
            resultPanel.setText(TRIAL_SUCCESS)

        else:
            viztask.schedule(FadeToGrayTask())
            resultPanel.setText(TRIAL_FAIL)
            viz.mouse.setVisible(True)
            Run_function()

        #Display success/failure message
        resultPanel.visible(True)

        # Add delay before starting next trial
        yield viztask.waitTime(TRIAL_DELAY)
        resultPanel.visible(False)
        number += 1

    # Disable gray effect
    gray_effect.setEnabled(False)

    #Display results and ask to quit or play again
    resultPanel.setText(RESULTS.format(score, TRIAL_COUNT))
    resultPanel.visible(True)
    yield viztask.waitTime(5)
    resultPanel.visible(False)
    UpdateScore(10)
Ejemplo n.º 17
0
 def clearPoints(self):
     """ Remove previously placed point axes objects
     and clear the point data list """
     for object in self._points:
         object.remove()
     self._points = []
     viztask.schedule(showVRText('Points data cleared.'))
     print('Point data and axes cleared.')
Ejemplo n.º 18
0
def onCollideBegin(e):
	global people
	
	for person in people:
		if person.avatar == e.obj1:
			person.coll = 1
			person.avatar.clearActions()
			viztask.schedule(person.collision())
Ejemplo n.º 19
0
def MainTask():
    """Top level task that controls the game"""

    # Display instructions and wait for key press to continue
    yield DisplayInstructionsTask()

    # Create panel to display trial results
    resultPanel = vizinfo.InfoPanel("", align=viz.ALIGN_CENTER, fontSize=25, icon=False, key=None)
    resultPanel.visible(False)

    viztask.waitDirector(getData)

    while True:

        num_trials += 1

        # Randomly choose hiding spots from list
        locations = random.sample(HIDING_SPOTS, TRIAL_COUNT)

        # Reset score
        score = 0
        UpdateScore(score)

        # Go through each position
        for pos in locations:

            # Perform a trial
            found = yield TrialTask(pos)

            # Update score and display status text
            if found:
                viz.playSound("sounds/pigeon_catch.wav")
                score += 1
                total_score += 1
                UpdateScore(score)
                tracker.runAction(vizact.spinTo(point=pos, time=0.8, interpolate=vizact.easeOutStrong))
                resultPanel.setText(TRIAL_SUCCESS)
            else:
                viz.playSound("sounds/pigeon_fly.wav")
                viztask.schedule(FadeToGrayTask())
                resultPanel.setText(TRIAL_FAIL)

            # Display success/failure message
            resultPanel.visible(True)

            # Add delay before starting next trial
            yield viztask.waitTime(TRIAL_DELAY)
            resultPanel.visible(False)

            # Disable gray effect
            gray_effect.setEnabled(False)

        viztask.waitDirector(writeScore, score)
        # Display results and ask to quit or play again
        resultPanel.setText(RESULTS.format(score, TRIAL_COUNT))
        resultPanel.visible(True)
        yield viztask.waitKeyDown(" ")
        resultPanel.visible(False)
Ejemplo n.º 20
0
def h2co3FormationTriggerEvent(e):
	global rightHandTarget, leftHandTarget, bubble
	print "Forming H2CO3 now!!!"
	bubble.disable(viz.RENDERING)
	if e.target == rightHandTarget:
		vizact.ontimer2(0.004, 25, vibrateHandController, 2)
	elif e.target == leftHandTarget:
		vizact.ontimer2(0.004, 25, vibrateHandController, 1)
	viztask.schedule(H2CO3formation())
def ExitProximity(e):
 global lSelectedNode, rSelectedNode, lhandtarget, rhandtarget, molecExited, h2omodels, NUM_H2O
 print "moleucle has left the building!!"
 print "exit prox: ", lSelectedNode, rSelectedNode
#drop molecule to specified place

 obj = None
 if e.target == lhandtarget:
  if lSelectedNode == None: return #If hand exits but has no molecule
  obj = lSelectedNode
  lSelectedNode = None
  moleculeManager.removeTarget(lhandtarget)

 elif e.target == rhandtarget: 
  if rSelectedNode == None: return #If hand exits but has no molecule
  obj = rSelectedNode
  rSelectedNode = None
  moleculeManager.removeTarget(rhandtarget)
  
 rhGrabber.removeItems([obj])
 lhGrabber.removeItems([obj])
 print obj
 molecExited = True

 x,y,z = (h2omodels[0]).getPosition()
 x += .5
 '''moveToH2O = vizact.moveTo([x,y,z] , speed = .75)
 obj.addAction(moveToH2O)
 print "should be moving!"'''
 #viztask.schedule( fadeAndAppear() )
 viztask.schedule(moveCO2toH2O(obj))
 #moveCO2 = vizact.moveTo([x,y,z],speed = .75 )
 #obj.addAction(moveCO2)
 '''co2 = obj
 print "in moveCO2toH20", co2
 #global h2omodels, NUM_H2O
 x,y,z = (h2omodels[0]).getPosition()
 x += .3
 moveToH2O = vizact.moveTo([x,y,z] , speed = 1.75)
 print x,y,z
 print (h2omodels[0]).getPosition()
 #viztask.addAction(co2, vizact.move(x,y,z,2))
 sequence = vizact.sequence(moveToH2O, vizact.waittime(4), vizact.fadeTo(0, time = 1))
 yield co2.add(sequence) 
 print "should be moving!"
 #yield viztask.waitTime(2)
 #"before turning off co2"
 #co2.visible(viz.OFF)
 h2omodels[0].visible(viz.OFF)
 print "before removing h20"
 h2omodels.remove(h2omodels[0])
 NUM_H2O -= 1 '''
 
 print "past viztask in exit prox"
 #start molecule combination animation
 #hide and remove h20 and co2 molecules
 '''obj.visible(viz.OFF)
Ejemplo n.º 22
0
def enable():
	global started, enabled
	global selector
	
	if not started:
		viztask.schedule(begin())
		started = True
			
	enabled = True
Ejemplo n.º 23
0
def disable():
	global enabled
	global selector
	
	if enabled:
		selector.disable()
		enabled = False

	viztask.schedule(playBusCloseAudio())
Ejemplo n.º 24
0
def experiment():
    for trialN in range(10):
        if trialN < 9:
            datafile = 'Trial0' + str(trialN + 1) + '.txt'
            respfile = 'RT_Trial0' + str(trialN + 1) + time.strftime(
                "_%d-%b-%y_%H-%M") + '.csv'
        else:
            datafile = 'Trial' + str(trialN + 1) + '.txt'
            respfile = 'RT_Trial' + str(trialN + 1) + time.strftime(
                "_%d-%b-%y_%H-%M") + '.csv'

        colors = []
        with open(datafile, 'rb') as csvfile:
            csvreader = csv.reader(csvfile, delimiter=' ')
            for row in csvreader:
                colors.append(row)
        colors = numpy.asarray(colors, dtype=uInt8)
        # colors = colors[0]

        strobes = Strobes(x, 100)
        leds = LEDs(colors, 0.05, 0.9403)
        vizact.onkeydown('.', leds.recordResp)

        sensor_Target = vizproximity.Sensor(
            vizproximity.RectangleArea([4, 0.1],
                                       center=[0, real_tg_dist[(-1)**trialN]]),
            None)
        manager.addSensor(sensor_Target)

        # Show where the target is and ask them to face to the target
        yield viztask.waitKeyDown('a')
        standBy = viztask.schedule(leds.standby(trialN % 2))
        # Turn of the LED to get the experiment ready to start
        yield viztask.waitKeyDown('s')
        standBy.kill()
        leds.all_off()
        leds.stop()
        monitor_record_Network.send('Start!')
        strobes.StartTask()
        f = viztask.schedule(leds.flashing())
        monitor_record_Network.send('Start!')
        yield vizproximity.waitEnter(
            sensor_Target)  # flash until they enter the target zone
        f.kill()
        # Once reach the target turn off both the LEDs and strobes
        strobes.StopTask()
        strobes.ClearTask()
        leds.all_off()
        leds.stop()
        leds.clear()
        # Save the data into a csv file
        leds.saveAsFile(respfile)
        manager.clearSensors()

    yield viztask.waitTime(10)
    viz.quit()
Ejemplo n.º 25
0
	def snap(self):
		"""
		Moves dog to the pos and euler of its target (dogTarget)
		"""
		movePos = vizact.moveTo(self.outlineCenter.getPosition(), time = self.snapTransitionTime)
		moveAng = vizact.spinTo(euler = self.outlineCenter.getEuler(), time = self.snapTransitionTime)
		transition = vizact.parallel(movePos, moveAng)
		self.dogCenter.addAction(transition)
		viz.playSound(".\\dataset\\snap.wav")
		viztask.schedule(self.mechanics())
Ejemplo n.º 26
0
	def update(self):
		if not self.__nvd.isInView():
			return True
		else:
				global seatQueue
				if timerEnded and abs(self.__node.getPosition()[0] - firstSeatPosition[0]) > 0.1:
					seatQueue.rotate(1) # Takes the most recent (past) position
					viztask.schedule( moveBackwards(self.__node, seatQueue[0]) )
					return True#abs(seatQueue[0][0] - self.__node.getPosition()[0]) < 0.1
				else: return False
Ejemplo n.º 27
0
def checkForNextEvent( obj ):
	global OBJS_WITH_NARRATION, selector
	evict = next((obj for obj in OBJS_WITH_NARRATION if obj.name == 'EvictionNotice'), None)
	door = next((obj for obj in OBJS_WITH_NARRATION if obj.name == 'Door'), None)
	if obj.name == 'Radio.OSGB': playNarrationFile(door)
	elif obj.name == 'Door': playNarrationFile(evict)
	
	else:
		selector.crosshair.visible(True)
		viztask.schedule(prepareForObjectSelling(evict))
Ejemplo n.º 28
0
def snap(dog, dogTarget):
    """
	Moves dog to the pos and euler of its target (dogTarget)
	"""
    movePos = vizact.moveTo(dogTarget.getPosition(), time=snapTransitionTime)
    moveAng = vizact.spinTo(euler=dogTarget.getEuler(), time=snapTransitionTime)
    transition = vizact.parallel(movePos, moveAng)
    dog.addAction(transition)
    viz.playSound(".\\dataset\\snap.wav")
    viztask.schedule(Tutorial.mechanics())
Ejemplo n.º 29
0
def snap(dog, dogTarget):
    """
	Moves dog to the pos and euler of its target (dogTarget)
	"""
    movePos = vizact.moveTo(dogTarget.getPosition(), time=snapTransitionTime)
    moveAng = vizact.spinTo(euler=dogTarget.getEuler(),
                            time=snapTransitionTime)
    transition = vizact.parallel(movePos, moveAng)
    dog.addAction(transition)
    viz.playSound(".\\dataset\\snap.wav")
    viztask.schedule(Tutorial.mechanics())
Ejemplo n.º 30
0
def nextRoundAnimation():
	global nextRoundPlaque, nextRoundSound
	if nextRoundPlaque is None:
		nextRoundPlaque = viz.addTexQuad()
		nextRoundPlaque.texture(viz.addTexture('./Resources/Misc/confetti.jpg'))
		nextRoundSound = nextRoundPlaque.playsound('./Resources/Misc/partyHorn.wav', viz.STOP, volume=0.1)
		nextRoundPlaque.setPosition(NRP_POS)
		nextRoundPlaque.setEuler(180, 0, 0)
		nextRoundPlaque.visible(viz.OFF)
	nextRoundSound.play()
	viztask.schedule(_plaqueAni)
Ejemplo n.º 31
0
def changeState(state):
    global objects, objectLocations, targetLocations, targetRotations, currentTarget, rotation, startPosition, set
    global cylinder, arrow, targetToFace, objectFiles, startFileIndex, targetObjects, targetPosition, startAngle
    global recordFile, angleIndex, sun, monument
    #--------------------------------------------------------------
    #A state of 0 corresponds to showing all of the objects and no target
    if(state == 0):
        showScenery()
        for x in range(len(objects)):
                objects[x].visible(viz.ON)
        hideArrowCylinder()
    
    #--------------------------------------------------------------
    #A state of 1 corresponds to showing the target and waiting for the participant to
    #walk toward the target and face the right direction
    elif(state == 1):
        targetPosition = rotate(rotation, targetLocations)[currentTarget]
        targetRotation = targetRotations[currentTarget] + rotation
        cylinder.setPosition(targetPosition)
        angleArray = [45,90,45]
        arrowPosition = rotate(rotation, arrowLocations)[currentTarget]
        arrow.setPosition(arrowPosition)
        cylinder.setEuler(targetRotation)
        
        #show all of the objects and the cylinder and the arrow
        
        for x in range(len(objects)):
                objects[x].visible(viz.ON)
        showArrowCylinder()
    #--------------------------------------------------------------
    #A state of 2 corresponds to hiding the scene and waiting for the
    #participant to finish turning
    elif(state == 2):
        global startTime
        if not sight:
            hideScenery()
            for x in range(len(objects)):
                objects[x].visible(viz.OFF)
        hideArrowCylinder()
        startPosition = view.getPosition()
        viz.MainView.velocity(0,0,0)
        startAngle = view.getEuler()[0]#ERROR
        startTime = time.clock()
        viztask.schedule(ShowMessage('Please turn to face %s' % objectAddresses[set][(fileStartIndex + targetObjects[currentTarget][targetToFace]) % len(objectFiles[set])]))
        
    #--------------------------------------------------------------
    #A state of 3 corresponds to showing only the cylinder and arrow
    #so that the participant can be reoriented to the starting position
    elif(state == 3):
        if not sight:
            hideScenery()
            for x in range(len(objects)):
                objects[x].visible(viz.OFF)
        showArrowCylinder()
Ejemplo n.º 32
0
def main():
    global TRACKER

    viz.go(0)

    # configure the phasespace.
    mocap = vrlab.Phasespace('192.168.1.230', freq=100., postprocess=True)
    mocap.start_thread()
    TRACKER = mocap.track_points(M)

    viztask.schedule(workflow)
Ejemplo n.º 33
0
def main():
    global TRACKER

    viz.go(0)

    # configure the phasespace.
    mocap = vrlab.Phasespace('192.168.1.230', freq=100., postprocess=True)
    mocap.start_thread()
    TRACKER = mocap.track_points(M)

    viztask.schedule(workflow)
Ejemplo n.º 34
0
def main():
    global train
    train = viz.addChild('Assets/Railcar_Main_OS.osgb', scene=viz.Scene1)
    platform = viz.addChild('Assets/environment.osgb', scene=viz.Scene1)
    viz.addChild('sky_day.osgb', scene=viz.Scene1)
    EnvironmentSetup.Start(train)
    NPCSpawner.InitPlat(platform)
    NPCSpawner.InitSeatedPos(train)
    NPCSpawner.InitStandingPos(train)
    NPCSpawner.SpawnPlatformNPC()
    viztask.schedule(RecordHR())
    viztask.schedule(InitalSetup(train))
Ejemplo n.º 35
0
 def sellObject(self):
     line = viz.MainWindow.screenToWorld([0.5, 0.5])  # TODO: Make sure this works for Rift
     intersection = self.scene.intersect(line.begin, line.end)
     if intersection.valid:
         self.foundObj = intersection.object
         if intersection.object.id in self.selectables:
             wait = vizact.waittime(self.delay)
             fadeout = vizact.fadeTo(0, time=self.fadetime)
             self.foundObj.addAction(wait)
             self.foundObj.addAction(fadeout)
             viztask.schedule(self.playAudio())
             self.selectables.remove(intersection.object.id)
Ejemplo n.º 36
0
	def start_custom_walk(self):
		walk = vizact.walkTo(self.next_point, self.next_speed, 90)
		yield viztask.addAction(self.avatar, walk)
		if(self.place_points < len(self.points)):			
			self.next_point = self.points[self.place_points][0]
			self.next_speed = self.points[self.place_points][1]
			self.place_points += 1
		else:
			self.next_point = get_quadrant(self.avatar.getPosition()).get_random_walk()
			self.next_speed = random.uniform(4, 5) #change tophat speed here
		if self.coll == 0:
			##print "no collision"
			viztask.schedule(self.start_custom_walk())
Ejemplo n.º 37
0
	def walk_around( self ):
		global quadrants
		
		if random.random() > 1:#0.3:
			walk = vizact.walkTo(self.next_point)
		else:
			walk = vizact.walkTo(self.next_point, random.uniform(4, 5), 90) #change everyone else speed here
		#print self.next_point
		yield viztask.addAction(self.avatar, walk)
		self.next_point = get_quadrant(self.avatar.getPosition()).get_random_walk()
		if self.coll == 0:
			##print "no collision"
			viztask.schedule(self.walk_around())
Ejemplo n.º 38
0
def flyDownToChild():
	global isYoking, subjectState
	#Play TRUMPET!
	if not TOURING_F:
		trumpetAudio.play()
	subjectState = SS_CURRENTLY_PULLED_TOWARDS_CHILD
	for i in range(END_FLY_SPEED):
		if FLYING_F:
			flyingLink.postTrans(newTrans)
		yield viztask.waitTime(0.01)
	isYoking = False
	subjectState = SS_CURRENTLY_LANDED_AT_CHILD
	viztask.schedule(endingPhase)
Ejemplo n.º 39
0
    def getTargetAngle(self):
        gotAngle = 0
        
        # log trial onset
        self.trialData['trialOnset']  = viz.tick()
        
        # show pointing target
        self.info.showTargetInfo(self.cTrial, self.trialCtr+1, len(self.trials))
        
        while not gotAngle:
            keyObj = yield viztask.waitKeyDown(keys=None)
            
            if keyObj.key == ' ':
                trgAngle = viz.MainView.getEuler(viz.ABS_GLOBAL)
                print trgAngle[0]
                gotAngle = 1
                
#            if keyObj.key == 't':
#                viz.MainView.lookAt( self.cTrial.getPos('trg', 'center') )
#                self.cTrial.showBuilding('trg', 'opaque')
#                trueAngle = viz.MainView.getEuler(viz.ABS_GLOBAL)
#                print trueAngle[0]                
            
            if keyObj.key == 'q':
                self.cTrial.src.toggleTransp()
                        
        # hide buildings
        self.cTrial.hideBuildings()
        
        # hide pointing info
        self.info.resetMsg()
        
        # log trial end
        self.trialData['tChoiceMade'] = viz.tick()
        
        # log target angle
        self.trialData['measAngle'] = trgAngle[0] # measured
        
        self.refVert.lookAt( self.cTrial.getPos('trg', 'center') )
        trueAngle = self.refVert.getEuler(viz.ABS_GLOBAL)
        print "refVert: ", trueAngle[0]
        self.trialData['trueAngle'] = trueAngle[0] # ground truth
        
        # DEBUGGING
        # print self.trialData
        
        # log data
        self.logHdl.logDictData(self.trialData)
        
        # start new trial
        viztask.schedule( self.startNewTrial() )
Ejemplo n.º 40
0
def init(avatar, pack_objs, intro, **kwargs):
	global isBusScene, moveSeats, seatQueue
	isBusScene = False
	DetectWhetherInView.init(**kwargs)
	seats = [Seats.getseatplacement(id)[0] for id in avatar.teleSeatIDs] # TODO: Abstract to handle arbitrary orientation too (for front right seats)
	seatQueue = deque([[seat[0],seat[1],seat[2]-0.5] for seat in seats]) # Node is in bus aisle

	
	global introAudio1, introAudio2
	introAudio1 = intro
	introAudio2 = viz.addAudio('Audio/CreepyTaskIntroduction.wav')
	
	FadeObject.init(pack_objs, 25, 0.01, **kwargs)
	
	viztask.schedule( creepilyMoveCloser(avatar) )
def d(a):
	if a==1:
		move=vizact.moveTo([-0.4,6,6],speed=12)
		head_tracker.addAction(move)
		head_tracker.runAction(move)
#		viz.window.displayHTML('F:\Lab 2\index.html',size=[1200,600],pos=[30,30,-30])
#		head_tracker.setEuler([0,0,0])
		viztask.schedule(MyTask())
	if a==2:
		
		viz.window.hideHTML()
		move=vizact.moveTo([0,1.5,0],speed=15)
		head_tracker.addAction(move)
		head_tracker.runAction(move)
		head_tracker.setEuler([0,0,0])
Ejemplo n.º 42
0
def d(a):
    if a == 1:
        move = vizact.moveTo([-0.4, 6, 6], speed=12)
        head_tracker.addAction(move)
        head_tracker.runAction(move)
        #		viz.window.displayHTML('F:\Lab 2\index.html',size=[1200,600],pos=[30,30,-30])
        #		head_tracker.setEuler([0,0,0])
        viztask.schedule(MyTask())
    if a == 2:

        viz.window.hideHTML()
        move = vizact.moveTo([0, 1.5, 0], speed=15)
        head_tracker.addAction(move)
        head_tracker.runAction(move)
        head_tracker.setEuler([0, 0, 0])
Ejemplo n.º 43
0
 def startNewRound(self):
     self.cTrial   =  None
     self.trialCtr = -1
     
     # prepare trials
     for cS in self.buildings:
         for cT in self.buildings:
             if not cS == cT:
                 #Debugging: print src and trg
                 #print "src: %s; trg: %s"%(cS.bName, cT.bName)
                 self.trials.append( Ptrial(cS, cT) )
     
     random.shuffle(self.trials)
     
     viztask.schedule( self.startNewTrial() )
Ejemplo n.º 44
0
def trialSetting_Exp(block_no, node):
    info.setText("Hurrah!! Please wait for the experimenter.")
    for m in range(4):

        yield viztask.waitNetwork(serverName)
        sub_rt.write('\nBlock ' + str(block_no) + ' Trial ' + str(m + 1))
        node.color(viz.ORANGE)
        Target.visible(viz.ON)
        myNetwork.send('Ready')
        yield viztask.waitNetwork(serverName)
        sound.play()
        myNetwork.send('Block ' + str(block_no) + ' Trial ' + str(m + 1))
        colorChange = viztask.schedule(changeColor(node))

        yield vizproximity.waitEnter(sensor_Target)
        Target.visible(viz.OFF)
        sound.stop()
        colorChange.kill()
        myNetwork.send('Reach Target!')

        ori = (1 + (-1)**m) * 90
        Target.setPosition(SPpos[(-1)**m], mode=viz.ABS_PARENT)
        Target.setEuler([ori, 0, 0], mode=viz.REL_LOCAL)

        if m < 3:
            info.visible(viz.ON)
            yield viztask.waitTime(3)
            info.visible(viz.OFF)
        else:
            sub_rt.write('\nend of block' + str(block_no))
            info.setText('End of Block ' + str(block_no))
            info.visible(viz.ON)
            yield viztask.waitTime(3)
            info.visible(viz.OFF)
Ejemplo n.º 45
0
    def launch_ball(self):
        """
        Launch the ball and start logging data. Schedule next trial.
        :return: None
        """
        # initialize new data file
        # viz.playSound('res/sounds/beeps.wav')
        # yield viztask.waitTime(3.41)

        self.data_file = open(self.data_filename, 'w')
        self.data_file.write(HEADER)

        self.ball.setAlpha(1)

        # reset timer
        self.timer = 0

        # start logging data
        self.log_action.setEnabled(True)

        # launch the ball
        #self.ball.setPosition(self.ball_pos)

        if self.is_fly_ball:
            self.ball.launch_fly(speed=self.trial_info['speed'], target=self.ball_dir)
        else:
            self.ball.launch_straight(speed=self.trial_info['speed'], direction=self.ball_dir)
        # TODO: maybe calculate trial duration and call end_trial with wait_time argument

        self.has_started = True
        self.await_end_task = viztask.schedule(self.await_end_trial())
Ejemplo n.º 46
0
	def lightUp(self, toucher = None):
		if not self._isLit:
			self._isLit = True
			if TouchCube.bingSound != None:
				TouchCube.bingSound.play()
			viz.VizNode.color(self, CUBE_LIT_COLOR)
			self.dimTask = viztask.schedule(self._waitForDim)
Ejemplo n.º 47
0
	def __init__(self):
		self.device = u6.U6()
		print self.device.configU6()
		
		#for the labjack
		self.numChannels = 12
		self.firstChannel = 2
		self.resolutionIndex = 4
		self.gainIndex = 0
		self.settlingFactor = 0
		self.differential = False
		
		self.latestAinValues = np.array([0]*self.numChannels, dtype='float')
		self.lastForceMoments = np.array([0]*self.numChannels, dtype='float')
		self.latestForceMoments = np.array([0]*self.numChannels, dtype='float')
		self.zero = np.array([0]*self.numChannels, dtype='float')
		
		self.lastTime = 0
		self.latestTime = 0
		
		self.lastLeftOn = False
		self.latestLeftOn = False
		self.lastLeftCOP = [0, 0]
		self.latestLeftCOP = [0, 0]

		self.lastRightOn = False
		self.latestRightOn = False
		self.lastRightCOP = [0, 0]
		self.latestRightCOP = [0, 0]
		
		FIOEIOAnalog = ( 2 ** self.numChannels ) - 1;
		fios = FIOEIOAnalog & (0xFF)
		eios = FIOEIOAnalog/256
		self.device.getFeedback(u6.PortDirWrite(Direction = [0, 0, 0], WriteMask = [0, 0, 15]))
		self.feedbackArguments = []
		self.feedbackArguments.append(u6.DAC0_8(Value = 125))
		self.feedbackArguments.append(u6.PortStateRead())
		for i in range(self.firstChannel, self.numChannels+self.firstChannel):
			self.feedbackArguments.append( u6.AIN24(i, self.resolutionIndex, self.gainIndex, self.settlingFactor, self.differential) )
			
		self.task = viztask.schedule(self.__update)
		self.going = True
		self.history = []
		self.recording = False
		
		#magic numbers to turn volts into Newtons and Newton.meters
		#left is stored in first 6 (x,y,z,mx,my,mz) and right in second 6
		self.M = np.array([[0, -2.309900 , 0.000000 , 1.308000 , 0.000000 , 2.306800 , 0.000000 , -495.780000 , 0.000000 , -494.040000 , 0.000000 , -2.034400],\
			[0, 6.308900 , 0.000000 , 5.913600 , 0.000000 , 11.633000 , 0.000000 , -2.295700 , 0.000000 , -13.079000 , 0.000000 , 499.990000],\
			[0, -491.360000 , 0.000000 , -488.510000 , 0.000000 , -488.270000 , 0.000000 , 5.064000 , 0.000000 , 6.732400 , 0.000000 , 0.391790],\
			[0, 48.162000 , 0.000000 , -298.930000 , 0.000000 , 299.410000 , 0.000000 , -1.565600 , 0.000000 , 4.956800 , 0.000000 , 54.786000],\
			[0, -254.760000 , 0.000000 , -26.647000 , 0.000000 , -25.153000 , 0.000000 , 42.462000 , 0.000000 , 42.087000 , 0.000000 , 1.601900],\
			[0, -7.032800 , 0.000000 , 1.345700 , 0.000000 , -1.140100 , 0.000000 , -243.640000 , 0.000000 , 354.550000 , 0.000000 , -4.020500],\
			[-2.688400 , 0.000000 , -0.083334 , 0.000000 , 1.258500 , 0.000000 , 491.220000 , 0.000000 , -495.750000 , 0.000000 , -6.723600 , 0],\
			[-7.642900 , 0.000000 , -5.959700 , 0.000000 , -3.659100 , 0.000000 , 15.847000 , 0.000000 , -12.401000 , 0.000000 , 507.580000 , 0],\
			[-490.840000 , 0.000000 , -490.690000 , 0.000000 , -492.520000 , 0.000000 , -6.428000 , 0.000000 , 3.723600 , 0.000000 , 4.807000 , 0],\
			[300.830000 , 0.000000 , -300.260000 , 0.000000 , 48.265000 , 0.000000 , -5.152500 , 0.000000 , -1.434500 , 0.000000 , 49.278000 , 0],\
			[26.955000 , 0.000000 , 27.005000 , 0.000000 , 253.680000 , 0.000000 , -40.116000 , 0.000000 , 41.703000 , 0.000000 , -1.501700 , 0],\
			[-1.380200 , 0.000000 , -2.450800 , 0.000000 , -1.349500 , 0.000000 , -348.250000 , 0.000000 , -245.680000 , 0.000000 , 10.366000 , 0]],\
			dtype='float')
Ejemplo n.º 48
0
def trials(block_no, vis_dist, isDisks=False):
    info.setText("Hurrah!! Please wait for the experimenter.")
    for m in range(4):
        vis_pos = [0, real_tg - vis_dist, vis_dist]
        sensor_Target = vizproximity.Sensor(
            vizproximity.RectangleArea([6, 0.1],
                                       center=[0,
                                               real_tg_dist[(-1)**(m + 1)]]),
            None)
        manager.addSensor(sensor_Target)

        if isDisks:
            disks.remove()
            global disks
            disks = diskCreator(vis_tg)
            disks.setPosition([0, 0, -vis_dist])

        yield viztask.waitNetwork(serverName)
        sub_rt.write('\nBlock ' + str(block_no) + ' Trial ' + str(m + 1))
        vis_tg.color(viz.ORANGE)
        vis_tg.visible(viz.ON)
        myNetwork.send('Ready')
        yield viztask.waitNetwork(serverName)
        sound.play()
        myNetwork.send('Block ' + str(block_no) + ' Trial ' + str(m + 1))
        colorChange = viztask.schedule(changeColor(vis_tg))

        yield vizproximity.waitEnter(sensor_Target)
        alert.play()
        print str(block_no) + ' ' + str(m + 1) + ' ' + str(
            view.getPosition()) + ' ' + str(vis_tg.getPosition())
        vis_tg.visible(viz.OFF)
        sound.stop()
        colorChange.kill()
        myNetwork.send('Reach Target!')

        ori = (1 + (-1)**m) * 90
        vistg_p = vis_tg.getPosition()
        vis_tg.setPosition(vistg_p[0],
                           vistg_p[1],
                           vis_pos[(-1)**m],
                           mode=viz.ABS_PARENT)
        vis_tg.setEuler([ori, 0, 0], mode=viz.REL_LOCAL)

        manager.clearSensors()

        if m < 3:
            info.visible(viz.ON)
            yield viztask.waitTime(3)
            info.visible(viz.OFF)
        else:
            sub_rt.write('\nend of block' + str(block_no))
            info.setText('End of Block ' + str(block_no))
            info.visible(viz.ON)
            yield viztask.waitTime(3)
            info.visible(viz.OFF)
            if isDisks:
                disks.remove()
Ejemplo n.º 49
0
	def load(self, dataset = 'right arm'):
		"""
		Load datasets and initialize everything necessary to commence
		the puzzle game. Customized for test mode.
		"""
		
		# Dataset
		model.ds = bp3d.DatasetInterface()
		

		# Proximity management
		model.proxManager = vizproximity.Manager()
		target = vizproximity.Target(model.pointer)
		model.proxManager.addTarget(target)

		model.proxManager.onEnter(None, self.EnterProximity)
		model.proxManager.onExit(None, self.ExitProximity)
		
		#create list of meshes to load
		self._meshesToLoad = model.ds.getOntologySet(dataset)
		self._filesToPreSnap = model.ds.getPreSnapSet()
		
		#create and add quiz panel
		self._quizPanel = puzzleView.TestSnapPanel()
		self._quizPanel.toggle()
		
		#load and prep meshes
		viz.MainWindow.setScene(viz.Scene2) #change to loading screen scene
		yield self.loadControl(self._meshesToLoad)
		yield self.prepareMeshes()
		yield self.preSnap()
		yield self.addToBoundingBox(self._meshes)
		yield self.disperseRandom(self._boundingBoxes.values())
		yield self.setKeystone(3)
		yield self.testPrep()
		yield self.hideMeshes()
		yield rotateAbout(self._boundingBoxes.values(), [0,0,0], [0,90,0])
		viz.MainWindow.setScene(viz.Scene1) #change back to game scene
		
		# Setup Key Bindings
		self.bindKeys()
		
		#Schedule closest bone calculation
		viztask.schedule(self.updateClosestBone)
Ejemplo n.º 50
0
    def init3dMouse(self):
        connexion = viz.add('3dconnexion.dle')
        device = connexion.addDevice()
        device.setRotateScale([0, 1, 0])
        device.setTranslateScale([0, 0, 1])

        #link = viz.link(device, self.pointer, viz.REL_PARENT)
        #link.preEuler([0,90,0])

        myTask = viztask.schedule(getCoords(device, self.pointer))
Ejemplo n.º 51
0
    def savePoints(self, filename='viz_svr_debug.csv'):
        """ Save list of stored coordinate points 
        
        Args:
            filename (str): Name of CSV output file
        """
        fields = ['point', 'device', 'marker', 'posX', 'posY', 'posZ', 'eulerX', 'eulerY', 'eulerZ']
        with open(filename, 'w') as pfile:
            writer = csv.DictWriter(pfile, delimiter='\t', lineterminator='\n', 
                                    fieldnames=fields, extrasaction='ignore')
            writer.writeheader()
            for pidx, point in enumerate(self._points):
                p = point.getPosition()
                e = point.getEuler()
                writer.writerow({'point': pidx, 'posX': p[0], 'posY': p[1], 'posZ': p[2], 
                                'eulerX': e[0], 'eulerY': e[1], 'eulerZ': e[2], 
                                'device': point._dev_index, 'marker': point._label})

        viztask.schedule(showVRText('Points data saved.'))
        print('Points data saved.')
Ejemplo n.º 52
0
def onNetwork(e):
    msg = str(e.data)
    info.setText(msg)
    if msg[2] == 'B':
        global recording
        print msg
        recording = viztask.schedule(writing(msg[2:-3].replace(' ', '_', 3)))
    elif msg[2] == 'R':
        try:
            recording.kill()
        except NameError:
            pass
Ejemplo n.º 53
0
	def load(self, dataset):
		"""
		Load datasets and initialize everything necessary to commence
		the puzzle game.
		"""
		
		# Dataset
		model.ds = bp3d.DatasetInterface()

		# Proximity management
		model.proxManager = vizproximity.Manager()
		target = vizproximity.Target(model.pointer)
		model.proxManager.addTarget(target)

		model.proxManager.onEnter(None, self.EnterProximity)
		model.proxManager.onExit(None, self.ExitProximity)

		#Setup Key Bindings
		self.bindKeys()
		

		self.score = PuzzleScore(self.modeName)
		
#		viztask.schedule(soundTask(glove))

		self._meshesToLoad = model.ds.getOntologySet(dataset)
		self._filesToPreSnap = model.ds.getPreSnapSet()
		
		viz.MainWindow.setScene(viz.Scene2) #change to loading screen scene
		yield self.loadControl(self._meshesToLoad)
		yield self.addToBoundingBox(self._meshes)
		yield self.prepareMeshes()
		yield self.disperseRandom(self._boundingBoxes.values())
		yield self.preSnap()
		yield self.setKeystone(3)
		yield rotateAbout(self._boundingBoxes.values() + self._meshes, [0,0,0], [0,90,0])
		viz.MainWindow.setScene(viz.Scene1) #change back to game scene
#		yield self.enableSlice()

		viztask.schedule(self.updateClosestBone())
Ejemplo n.º 54
0
	def __init__(self, tmill, forceplates):
		#use enable to prevent the belts from moving/view updating
		self.enable = False
		
		self.tmill = tmill
		self.forceplates = forceplates
		
		self.leftStrideLength = 0.#m, this is only an initial estimate, it will be measured
		self.rightStrideLength = 0.#m
		
		self.leftDistToDesired = 0.0#m
		self.rightDistToDesired = 0.0#m
		
		self.numSamples = 10 #average over this many stride times
		self.leftStrideTime = np.array([STRIDE_TIME_GUESS]*self.numSamples, dtype='float')#s, 1 is initial guess
		self.rightStrideTime = np.array([STRIDE_TIME_GUESS]*self.numSamples, dtype='float')#s, 1 is initial guess
		
		self.leftSpeed = self.leftStrideLength / np.median(self.leftStrideTime)
		self.rightSpeed = self.rightStrideLength / np.median(self.rightStrideTime)
		
		self.leftDownTime = 0.0#s
		self.leftUpTime = 0.0#s
		self.rightDownTime = 0.0#s
		self.rightUpTime = 0.0#s
		
		self.leftDownPos = [0.,0.]#m
		self.leftUpPos = [0.,0.]#m
		self.rightDownPos = [0.,0.]#m
		self.rightUpPos = [0.,0.]#m
		
		self.history = []
		
		viztask.schedule(self.__update)
		viztask.schedule(self.__stride)
		viztask.schedule(self.__ZeroSpacing)
Ejemplo n.º 55
0
    def __init__(self, verbose=True):
        self.T1 = treadmill.Treadmill()

        #linkables that keep track of the current position
        self.track = viz.add('box.wrl', alpha=0)
        self.separation = 0.05  #meters between the feet (approx is probably ok, or get it from force plates)

        self.going = False
        viztask.schedule(self.__start)
        viztask.schedule(self.__stop)
        viztask.schedule(self.__trackResponse)

        viztask.schedule(self.updatePos)

        self.verbose = verbose

        #for logutil
        self.history = []
        self.recording = False
Ejemplo n.º 56
0
def experiment():
    for trial in range(10):
        sensor_Target = vizproximity.Sensor(
            vizproximity.RectangleArea([4, 0.1],
                                       center=[0, real_tg_dist[(-1)**trial]]),
            None)
        manager.addSensor(sensor_Target)

        yield viztask.waitNetwork(serverName)
        record = viztask.schedule(writing(trial))
        yield viztask.waitTime(0.5)

        yield vizproximity.waitEnter(sensor_Target)
        winsound.Beep(
            800, 1000
        )  # Make a sound to notify the participant that he/she has reached the target.
        record.kill()
        manager.clearSensors()
Ejemplo n.º 57
0
 def updateKeybindings(self):
     """Menu keybinding state machine"""
     for keybinding in self.keybindings:
         keybinding.remove()
     if self.activeMenu == self.inGameMenu:
         self.keybindings.append(
             vizact.onkeydown(viz.KEY_ESCAPE, self.toggle))
     elif self.activeMenu == self.layerMenu:
         self.keybindings.append(
             vizact.onkeydown(viz.KEY_RETURN,
                              lambda: viztask.schedule(self.start))
         )  #use viztask to make loading screen appear before loading (necessary event when not multithreading)
         self.keybindings.append(
             vizact.onkeydown(viz.KEY_ESCAPE, self.backMenu))
     elif self.activeMenu == self.mainMenu:
         self.keybindings.append(
             vizact.onkeydown(viz.KEY_RETURN, self.nextMenu))
         self.keybindings.append(
             vizact.onkeydown(viz.KEY_ESCAPE, self.exitGame))
     elif self.activeMenu == self.modeMenu:
         self.keybindings.append(
             vizact.onkeydown(viz.KEY_RETURN, self.nextMenu))
         self.keybindings.append(
             vizact.onkeydown(viz.KEY_ESCAPE, self.backMenu))