Пример #1
0
HOME_POLE = [[DIMENSION_X/2, 0.0, DIMENSION_Z/2], [-DIMENSION_X/2, 0.0, -DIMENSION_Z/2]]
ORI_POLE = [[DIMENSION_X/2 - DIMENSION_X/3, 0.0, DIMENSION_Z/2 - DIMENSION_Z/3], \
			[-DIMENSION_X/2 + DIMENSION_X/3, 0.0, -DIMENSION_Z/2 + DIMENSION_Z/3]]


# Describe the end-trial trigger line (end line) in the intersense coordinate system
# the end line is perpendicular to walking direction
K = -DIMENSION_X/DIMENSION_Z # The slope of the end line
END_DIS = 2.0 # The distance between end line to home pole position of following trial
# The intercept of the end line for two home poles respectively
B = [-(DIAGONAL/2 - END_DIS) / math.cos(ROOM_ANGLE), (DIAGONAL/2 - END_DIS) / math.cos(ROOM_ANGLE)]

#####################################################################################
# Settings

IPD = viz.input('Please enter notes(IPD):')

# Dialog box asking for type of control and subject number
HMD = 'Odyssey'
MONITOR = 'PC Monitor'
controlOptions = [HMD,MONITOR]
controlType = controlOptions[viz.choose('How would you like to explore? ', controlOptions)]

subject = viz.input('Please enter the subject number:','')
subject = str(subject).zfill(2)



# Use keyboard controls
# Controls:
# q - Strafe L		w - Forward		e - Strafe R
Пример #2
0
	
	backgrounds = {'D':viz.SKYBLUE, 'N':viz.BLACK}	
	
	#load playback
	autofiles = {}
	for yr in yawrates: 
		auto_fn = str(yr)
		playback = OpenTrial(auto_fn)	
		autofiles[auto_fn] = playback
	
	wheel = LoadAutomationModules()
	wheel.FF_on(1) # set to zero to turn off force feedback
	vizact.onexit(CloseConnections, wheel)
	
	## add participant interaction
	pp_id = viz.input('Participant code: ') #add participant code
	try:
		pp_id = int(pp_id)
	except: 
		raiseandquit("invalid pp code")		
		
	block = viz.input('Block: ') #add block number
	try: 
		block = int(block)
		if block not in [1,2,3,4]: raiseandquit("invalid block number")			
	except:
		raiseandquit("invalid block number")
		
	save_prefix = '_'.join(['Tuna19',str(pp_id),str(block)])
	print(save_prefix)
	
Пример #3
0
        os.path.abspath(os.path.join(SOUND_DIR, 'End.mp3')))
    sounds['begin'] = viz.addAudio(
        os.path.abspath(os.path.join(SOUND_DIR, 'Begin.mp3')))
    sounds['startover'] = viz.addAudio(
        os.path.abspath(os.path.join(SOUND_DIR, 'Startover.mp3')))
    sounds['stop'] = viz.addAudio(
        os.path.abspath(os.path.join(SOUND_DIR, 'Stop.wav')))
    # set up IO
    # Dialog box asking for type of control and subject number
    HMD = 'Odyssey'
    MONITOR = 'PC Monitor'
    controlOptions = [HMD, MONITOR]
    controlType = controlOptions[viz.choose('How would you like to explore? ',
                                            controlOptions)]

    subject = viz.input('Please enter the subject number:', '')
    subject = str(subject).zfill(2)

    # Use keyboard controls
    # Controls:
    # q - Strafe L		w - Forward		e - Strafe R
    # a - Turn L		s - Back		d - Turn R
    # y - Face Up		r - Fly Up
    # h - Face Down		f - Fly Down
    if controlType == MONITOR:
        HZ = 60
        headTrack = viztracker.Keyboard6DOF()
        link = viz.link(headTrack, viz.MainView)
        headTrack.eyeheight(1.6)
        link.setEnabled(True)
    elif controlType == HMD:
import math
import random
import datetime
import time
import linecache

#Brings up menu for HMD etc.
viz.go(viz.PROMPT)
# Get and validate a subject ID
test = True
sight = test
validID = False
while not (validID):
  try:
		#Prompt the user for an ID number
		subjectID = int(viz.input('Input Subject ID Number'))
		RESULTS_DIRECTORY = 'C:\Users\Administrator\Downloads'
		#Validate the subject ID number
		outFilePath = '%s\Subject_%s.txt' %(RESULTS_DIRECTORY, str(subjectID))
		if os.path.exists(outFilePath) or subjectID is '':
			yes = viz.ask('The Subject ID Number ' + str(subjectID) + ' already exists. Pick a new one?')
			if not yes:
				raise 'Exiting...'
		else:
			validID = True
			print "we have a valid ide!"
	except ValueError:
		print('Subject ID number must be an integer')
if test:
	subjectInitial = 'test'
else:
Пример #5
0
import vizact  # vizard library for timers
import numpy as np  # numpy library - such as matrix calculation
import random  # python library
import vizdriver_Orca18_pilotnosteering as vizdriver  # vizard library
import viztask  # vizard library
import math as mt  # python library
import Count_Adjustable  #distractor task

viz.go()
viz.window.setFullscreenMonitor(2)
viz.window.setFullscreen(viz.ON)

# Prompt for filename
ExpID = "Orca19_Distractor_Baseline_"
DEG_SYM = unichr(176).encode("latin-1")
pname = viz.input('Participant code: ')

########### CHANGE HERE TO TOGGLE PRACTICE ANDS BLOCK #############

#SP CHANGE HERE

PRACTICE = False  #if practice, they only do one of each.
DISTRACTOR_TYPE = "Middle"  #(2 targets)# "Hard" #"Easy" (1 target) or "Hard" (3 targets).

#Will change here
BLOCK = 2  #1 or 2. #switch to not save over previous file.

#### ORDER TRIALS #####

#previous data was 40%, 2 targets
Пример #6
0
        print_('unsynced')
        
    def on_emg(self, myo, timestamp, emg):
        show_output('emg', emg)
        
def show_output(message, data):
    if random.random() < SHOW_OUTPUT_CHANCE: 
        return

test = False
validID = False
subjectID = 1
while not (validID):
    try:
        #Prompt the user for an ID number
        subjectID = int(viz.input('Input Subject ID Number'))
        RESULTS_DIRECTORY = 'C:\Users\Bryton\Downloads\MyoResults2015'##CHANGE THIS
        #Validate the subject ID number
        outFilePath = '%s\Subject_%s.txt' %(RESULTS_DIRECTORY, str(subjectID))
        if os.path.exists(outFilePath) or subjectID is '':
            yes = viz.ask('The Subject ID Number ' + str(subjectID) + ' already exists. Pick a new one?')
            if not yes:
                raise 'Exiting...'
        else:
            validID = True
    except ValueError:
        print('Subject ID number must be an integer')
if test:
    subjectInitial = 't'
else:
    subjectInitial = (viz.input('Input subject initial'))
Пример #7
0
def myKeyboard( key):
	global t , trialstartframe, trialType, feetScaledFlag, Piazza, stripe2, lFoot, rFoot
	global affTrials, distTrials, trials, footSize, numTrials, canStep, DataEntry, verbalEst
	global subjectno, ToRecord_YN, Estimate, FootH_Offset, Swapped, Tracker_Offset, paused
	global lFootTracker, rFootTracker, LFootLink, RFootLink, rFoot, lFoot, Tracker2FootEdge
	global lFootModel, rFootModel, InputString, EH_Flag
	
	if DataEntry == False:
		
		if key == '`':
			DataEntry = True
		if key == 'n':
			ToRecord_YN = "FALSE"
		if key == 'y':
			ToRecord_YN = "TRUE"
		# Starts the next trial
		if key == 'p':
			BlockDisplayOFF()
		if key ==  ' ':
			if trialType == 0: # AFFORDANCE
				out.write(str(subjectno) + ',' + str(t) + ',' +	str(trials[t][1]) + ',' + 'AFFORDANCE' + ',' + str(trials[t][0]) + ',' + str(ToRecord_YN) +'\n') 
				#('\nSubject Number,Trial Index,Gap Width,Trial Type,Rotation,Can Step,Distance,Height Perception,Height Change %')
				out.flush()
				os.fsync(out) 
				ToRecord_YN = None
				
				if t < len(affTrials) - 1:
					CrosshairDisplay(2)
					t += 1
					doTrial( trials[t][0] , trials[t][1] )
					print t
					print trials[t]
					trialstartframe =  viz.getFrameNumber()
				else: # Finished AFFORDANCE
					t += 1 # Increment so that the scene that is loaded after the message box is the first DISTANCE trial/next trial
					trialType = 1 # DISTANCE
	
					numTrials = 12 # Number of trials in each foot size for the DISTANCE judgments
					canStep = -1 # No longer used for remaining trials
					
					# Take break before beginning DISTANCE judgments
					BlockDisplay("DISTANCE")
					# Load the first DISTANCE trial
					doTrial (trials[t][0] , trials[t][1])
					print t
					print trials[t]
					
			else: # DISTANCE (trialType == 1) or EYE HEIGHT (trialType == 2) 
				if t < len(trials) - 1:
					CrosshairDisplay(3)
					out.write(str(subjectno) + ',' + str(t) + ',' +	str(trials[t][1]) + ',' + 'DISTANCE' + ',' + str(trials[t][0]) + ',' + "N/A" + ',' + InputString +'\n') 
					#('\nSubject Number,Trial Index,Trial Type,Rotation,Can Step,Distance,Height Perception,Height Change %')
					out.flush()
					os.fsync(out) 
					InputString = ""
					InputText2D.message(InputString)
					
					t += 1
#					if (t != len(affTrials)) and (t-len(affTrials))%numTrials == 0:
#						viz.message("")
#						print 'hit third break'
#						currSizeIndex = 1 # Set foot size index to second foot size
					doTrial( trials[t][0] , trials[t][1] )
					print t
					print trials[t]
					trialstartframe =  viz.getFrameNumber()
				else: # Finished DISTANCE
					if(EH_Flag == False):
						out.write(str(subjectno) + ',' + str(t) + ',' +	str(trials[t][1]) + ',' + 'DISTANCE' + ',' + str(trials[t][0]) + ',' + "N/A" + ',' + InputString +'\n')
						EH_Flag = True
					else:
						out.write(str(subjectno) + ',' + str(t+1) + ',' +	"N/A" + ',' + 'HEIGHT ESTIM' + ',' + str(trials[t][0]) + ',' + "N/A" + ',' + "N/A" + ',' + InputString +'\n')
					trialType = 2 # EYE HEIGHT
					paused = True
					InputString = ""
					InputText2D.message(InputString)
					BlockDisplay("EYE HEIGHT")
					
		# Precautionary inclusion, these keys should be VERY circumstantially used
		# Go back one trial
		if key == viz.KEY_LEFT:
			t -= 2
			myKeyboard(' ')
		# Going forward one trial would be equivalent to pressing the spacebar so that key == ' '
			
		
		# Use this key for updating scale of the shoes to reflect the base shoe size/dimensions
		if key == 'u' and feetScaledFlag < 0:
			print ("Scaling Feet")
			# The shoes will now be scaled properly
			feetScaledFlag = 1
			
			TempList = rFoot.getScale()
			TempList = [TempList[0]*Multi,TempList[1]*Multi,TempList[2]*Multi]
			rFoot.setScale(TempList)
			TempList = lFoot.getScale()
			TempList = [TempList[0]*Multi,TempList[1]*Multi,TempList[2]*Multi]
			lFoot.setScale(TempList)
			SetShoes()
			del TempList
			
			# Make the shoes visible to the user
			rFoot.visible(viz.ON)
			lFoot.visible(viz.ON)
			
			RotAngle = math.degrees(math.asin(Tracker_Offset/Tracker2FootEdge))
			print("RotAngle: " + str(RotAngle))
			rFootModel.setAxisAngle([1,0,0,RotAngle])
			lFootModel.setAxisAngle([1,0,0,RotAngle])
			
			# Schedule a task so that the data is recorded every FRAME_DELAY seconds
			viztask.schedule(printTarget)
			
			print ("Scaling Feet Done")
		
		# Show noisy blank screen
		if key == 'b':
			CrosshairDisplay(2)
		
		if key == '1':
			Tracker_Offset = viz.input('Tracker offset from center to ground (in CM)' , value='0')
			Tracker_Offset = Tracker_Offset * .01
			LFootLink.remove()
			RFootLink.remove()
			RFootLink = viz.link(Tracking[0], rFoot, offset=(0,-Tracker_Offset,0, viz.REL_PARENT))
			LFootLink = viz.link(Tracking[1], lFoot, offset=(0,-Tracker_Offset,0, viz.REL_PARENT))
			
			if(Tracker_Offset/Tracker2FootEdge > 1 or Tracker_Offset/Tracker2FootEdge < 0):
				CalcErrorFlag = True
			
			while(CalcErrorFlag):
				Tracker_Offset = viz.input('Tracker offset from center to ground (in CM)' , value='0')
				Tracker_Offset = Tracker_Offset * .01
				Tracker2FootEdge = viz.input('distance from tracker center to the ground in front of the participants foot (in CM)' , value='0')
				Tracker2FootEdge = Tracker2FootEdge * .01
				if(Tracker_Offset/Tracker2FootEdge > 1 or Tracker_Offset/Tracker2FootEdge < 0):
					pass
				else:
					CalcErrorFlag = False
					
			RotAngle = math.degrees(math.asin(Tracker_Offset/Tracker2FootEdge))
			print("RotAngle: " + str(RotAngle))
			rFootModel.setAxisAngle([1,0,0,RotAngle])
			lFootModel.setAxisAngle([1,0,0,RotAngle])
	
		if key == '2':
			Tracker2FootEdge = viz.input('distance from tracker center to the ground in front of the participants foot (in CM)' , value='0')
			Tracker2FootEdge = Tracker2FootEdge * .01

			if(Tracker_Offset/Tracker2FootEdge > 1 or Tracker_Offset/Tracker2FootEdge < 0):
				CalcErrorFlag = True
			
			while(CalcErrorFlag):
				Tracker_Offset = viz.input('Tracker offset from center to ground (in CM)' , value='0')
				Tracker_Offset = Tracker_Offset * .01
				Tracker2FootEdge = viz.input('distance from tracker center to the ground in front of the participants foot (in CM)' , value='0')
				Tracker2FootEdge = Tracker2FootEdge * .01
				if(Tracker_Offset/Tracker2FootEdge > 1 or Tracker_Offset/Tracker2FootEdge < 0):
					pass
				else:
					CalcErrorFlag = False
	
			RotAngle = math.degrees(math.asin(Tracker_Offset/Tracker2FootEdge))
			print("RotAngle: " + str(RotAngle))
			rFootModel.setAxisAngle([1,0,0,RotAngle])
			lFootModel.setAxisAngle([1,0,0,RotAngle])

	elif DataEntry == True:
		
		if key == '`' or key == viz.KEY_RETURN:
			DataEntry = False
		elif key == viz.KEY_BACKSPACE:
			InputString = InputString[:-1]
		else:
			InputString = InputString + key
		InputText2D.message(InputString)
		
		
	if key == viz.KEY_F6:
		LFootLink.remove()
		RFootLink.remove()
		if Swapped == False:
			Swapped = True
			RFootLink = viz.link(Tracking[1], rFoot, offset=(0,-Tracker_Offset,0, viz.REL_PARENT))###FIX
			LFootLink = viz.link(Tracking[0], lFoot, offset=(0,-Tracker_Offset,0, viz.REL_PARENT))
			
		elif Swapped == True:
			Swapped = False
			RFootLink = viz.link(Tracking[0], rFoot, offset=(0,-Tracker_Offset,0, viz.REL_PARENT))###FIX
			LFootLink = viz.link(Tracking[1], lFoot, offset=(0,-Tracker_Offset,0, viz.REL_PARENT))
			

	if key == viz.KEY_ESCAPE:
		out.flush()
		out2.flush()
		os.fsync(out)
		os.fsync(out2) 
		out.close()
		out2.close()
		viz.quit()
Пример #8
0
def CloseConnections(EYETRACKING):
    """Shuts down EYETRACKING and wheel threads then quits viz"""

    print("Closing connections")
    if EYETRACKING:
        comms.stop_trial()  #closes recording

    #kill automation
    viz.quit()


if __name__ == '__main__':

    ###### SET EXPERIMENT OPTIONS ######
    EYETRACKING = True
    PRACTICE = True
    TILING = True  #to reduce memory load set True to create two groundplane tiles that dynamically follow the driver's position instead of one massive groundplane.
    EXP_ID = "BenLui17"

    if PRACTICE == True:  # HACK
        EYETRACKING = False

    ParticipantNumber = viz.input('Enter participant number')  #cmg edit

    myExp = myExperiment(
        EYETRACKING, PRACTICE, TILING, EXP_ID,
        ppid=ParticipantNumber)  #initialises a myExperiment class

    viz.callback(viz.EXIT_EVENT, CloseConnections, myExp.EYETRACKING)

    viztask.schedule(myExp.runtrials())
Пример #9
0
	MSAAVal = 2
elif MSAA == 4:
	MSAAVal = 0
viz.setMultiSample(MSAAVal)
print ("MSAA: " + str(MSAAVal))
del MSAAVal

VSync = viz.choose("Vertical Sync", ['False', 'True'])
if VSync == 0:
	viz.vsync(0)
else:
	viz.vsync(1)
print ("VSync: " + str(VSync))

# Input questions/variables: Asked at program launch
subjectno = viz.input('subject number?' , value='99')
age = viz.input('Age number?' , value='-1')
gender = viz.choose("Gender?", ["Male","Female","Not Given"])
footSize = 0
while int(footSize) <= 0:
	footSize = viz.input('Participant foot size (in CM)' , value='0')
baseDepth = footSize *.01 #sets participants foot size to be the basis of calculation for shoe model
print baseDepth
baseWidth = baseDepth * .74 #based on the percentage basewidth is of basdepth for the adult trial (which is the original declarition of these variables)
baseHeight = baseDepth * 0.60 # Shoe height for this particular kind of shoe estimated by roughly measuring Nike high tops



while(CalcErrorFlag):
	Tracker_Offset = viz.input('Tracker offset from center to ground (in CM)' , value='0')
	Tracker_Offset = Tracker_Offset * .01
Пример #10
0
    #		trials = 3
    #trials = 6
    #else:
    #		trials = 6

    trials = 6  #results in about five minutes quicker than six repetitions.

    if DISTRACTOR_TYPE is None:
        EXP_ID = EXP_ID + '_' + str(
            DISTRACTOR_TYPE
        )  #+ '_' + str(BLOCK) #build string for file saving.
    else:
        EXP_ID = EXP_ID + '_' + str(
            DISTRACTOR_TYPE)  #build string for file saving.

    PP_ID = viz.input('Participant code: ')  #add participant code

    if PRACTICE == True:  # HACK
        EYETRACKING = False

    if EYETRACKING:
        from eyetrike_calibration_standard import Markers, run_calibration
        from eyetrike_accuracy_standard import run_accuracy
        from UDP_comms import pupil_comms
        import pupil_logger

    myExp = myExperiment(EYETRACKING,
                         PRACTICE,
                         EXP_ID,
                         AUTOWHEEL,
                         DEBUG,
Пример #11
0
# Setup Oculus Rift HMD
hmd = oculus.Rift()
if not hmd.getSensor():
    sys.exit('Oculus Rift not detected')

# Go fullscreen if HMD is in desktop display mode
if hmd.getSensor().getDisplayMode() == oculus.DISPLAY_DESKTOP:
    viz.window.setFullscreen(True)

# # Apply user profile eye height to view
profile = hmd.getProfile()
if profile:
    height = profile.eyeHeight - 0.1
else:
    height = float(viz.input('Height?'))

# Set up the instruction
beforeExp = """That's the practice. 
Ready for the experiment?
"""
ReqResp = 'Left or Right?'
# GotResp = 'Next Trial'

# Set up the target
Target = vizshape.addCylinder(height=3, radius=0.02, yAlign=vizshape.ALIGN_MIN)
Target.color(viz.ORANGE)
Target.visible(viz.OFF)

# Set up view movement
view = viz.MainView
Пример #12
0
		title.fontSize(24)
		title.addParent(inputPanel)
		title.setPosition([.4, .53+.1*p, 0])
		name.setPosition([.5, .5+.1*p, 0])
		name.addParent(inputPanel)
		names.append(name)
	startB = viz.addButtonLabel('START')
	startB.setPosition(.5,.4)
	startB.addParent(inputPanel)
	vizact.onbuttonup(startB, initialize)
	
if studyMode:
	trial = viz.choose('Choose practice or main trial:',['practice', 'trial'])
	condition = viz.choose('Choose study condition:',['1P', '3P', 'Facilitated'])
	if trial:
		group = viz.input('Choose group number:', '')
		displayInputPanel()
	else:
		initialize() 
else:
	condition = CONDITION	#0->'1P', 1->'3P', 2->'F' 
	trial = TRIAL			#1->full factory & logging, 0->practice
	initialize()
	
#----------------------------------------------------------------
def sendEventToMachine (mach, action):
	(mActions, mMessage, multi) = FSM[mach].evaluate_multi_input(action, gPlayers[1]['player'], True)
	gPlayers[1]['player'].BroadcastActionsMessages(mActions, mMessage)

def changeFSMState (mach, newState):
	FSM[mach].set_start(newState)
Пример #13
0
def setUpYoke():
	global GET_FLIGHT_FILE
	if not FLYING_F or TOURING_F:
		GET_FLIGHT_FILE = addZeros(str(viz.input('Enter flight file:')))
		while (not os.path.exists('positionData/' + GET_FLIGHT_FILE)):
			GET_FLIGHT_FILE = addZeros(str(viz.input('No such file. Re-enter flight file:')))