def participantInfo():

	subject = vizinput.input('What is the participant number?')
	age = vizinput.input('age?')
	sex = ['male','female']
	sex_choice = vizinput.choose('Sex',sex)
	handedness = ['right','left','both']
	handedness_choice = vizinput.choose('Handedness',handedness)
	ts = time.time()

	##create demographic data file
	demographic_data = open('demographic_data_rod_frame.csv','w')
	with open('data/demographic_data_rod_frame.csv', 'a') as f:
		wr = csv.writer(f, delimiter=';', lineterminator='\n', quoting=csv.QUOTE_ALL)
		row_demo = [subject, age, sex[sex_choice] ,handedness[handedness_choice] , datetime.datetime.fromtimestamp(ts).strftime('%Y-%d-%m %H:%M:%S')]
		wr.writerow(row_demo)
	return subject,datetime.datetime.fromtimestamp(ts).strftime('%Y-%d-%m %H:%M:%S')
Beispiel #2
0
def InitRecording():
	# Condition is ALWAYS 1 here.
	pptExtension.STATE = 0
	pptExtension.ARMS_LIMIT_STATE = 0
	pptExtension.LEGS_LIMIT_STATE = 0

	global name
	name = vizinput.input('Participant Name: ')

	global gender
	genderChoices = ['female', 'male']
	gender = vizinput.choose('Gender: ', genderChoices)
	
	global condition
	wcChoices = ['Third Arm', 'Cylinder', 'Floating hand', 'Floating ball']
	condition = vizinput.choose('Which condition would you like to use?', wcChoices)
	
	global skin, skinChoices
	skinChoices = ['1','2','3','4','5','6','7','8','9','10']
	skin = viz.choose('Skin Color? (1 = lightest, 10 = darkest)',skinChoices)
	
	global file
	file = hf_playback.openAvatarRecording(genderChoices[gender], name, 'w')
Beispiel #3
0
def InitRecording():
	# Condition is ALWAYS 1 here.
	pptextension.STATE = 0
	pptextension.ARMS_LIMIT_STATE = 0
	pptextension.LEGS_LIMIT_STATE = 0

#BL:start
	some_global_variables.testRun = vizinput.ask('Is this a test run?')

	global participantID, controlSchema, controlSchemaChoices, numberOfArms

	controlSchemaChoices = ['BimanualControl', 'UnimanualControl', 'HeadControl']#['Wrist rotation', 'Asymmetric']
	participantID = 'No_ID'
	controlSchema = 0
	
	if not some_global_variables.testRun:
		participantID = vizinput.input('Participant ID: ')
#		controlSchema = vizinput.choose('Choose the control schema', controlSchemaChoices)
	
	numberOfArms = vizinput.choose('Number of arms', ['3','4','5'])
	numberOfArms += 3
	print "numberOfArms = " + str(numberOfArms)
	some_global_variables.isLeftHanded = vizinput.ask('Is the user left-handed?')
	global gender
	genderChoices = ['female', 'male']
	gender = 0#vizinput.choose('Gender: ', genderChoices)
	
	global appendage
	wcChoices = ['Third Arm', 'Cylinder', 'Floating hand', 'Floating ball']
	appendage = 0#vizinput.choose('Which appendage would you like to use?', wcChoices)
	
	global skin, skinChoices
	skinChoices = ['1','2','3','4','5','6','7','8','9','10']
	skin = 0#viz.choose('Skin Color? (1 = lightest, 10 = darkest)',skinChoices)
#BL:end
	
#	global filePointerForAvatarRecording, filePointerForRuntimeScoringRecording
	if not some_global_variables.testRun:
		touchcube.openRuntimeScoringTimesRecordingFile(participantID, controlSchemaChoices[controlSchema])
		hf_playback.openAvatarRecording(participantID, controlSchemaChoices[controlSchema])
Beispiel #4
0
def InitRecording():
    # Condition is ALWAYS 1 here.
    pptExtension.STATE = 0
    pptExtension.ARMS_LIMIT_STATE = 0
    pptExtension.LEGS_LIMIT_STATE = 0

    # BL:start
    global testRun
    testRun = vizinput.ask("Is this a test run?")

    global participantID, controlSchema, controlSchemaChoices, isLeftHanded

    controlSchemaChoices = ["BimanualControl", "UnimanualControl", "HeadControl"]  # ['Wrist rotation', 'Asymmetric']
    participantID = "No_ID"
    controlSchema = 2

    if not testRun:
        participantID = vizinput.input("Participant ID: ")
        controlSchema = vizinput.choose("Choose the control schema", controlSchemaChoices)

    isLeftHanded = 0  # vizinput.ask('Is the user left-handed?')
    global gender
    genderChoices = ["female", "male"]
    gender = 0  # vizinput.choose('Gender: ', genderChoices)

    global appendage
    wcChoices = ["Third Arm", "Cylinder", "Floating hand", "Floating ball"]
    appendage = 0  # vizinput.choose('Which appendage would you like to use?', wcChoices)

    global skin, skinChoices
    skinChoices = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10"]
    skin = 0  # viz.choose('Skin Color? (1 = lightest, 10 = darkest)',skinChoices)
    # BL:end

    # 	global filePointerForAvatarRecording, filePointerForRuntimeScoringRecording
    # 	touchcube.openRuntimeScoringTimesRecordingFile(participantID, controlSchemaChoices[controlSchema])
    hf_playback.openAvatarRecording(participantID, controlSchemaChoices[controlSchema])
Beispiel #5
0
def setup():
	global leftWristPPT, rightWristPPT, lfPPT, rfPPT, headPPT, viewLink, navigationNode
	global lhSphere, rhSphere
	global hmdLink
	#add more trackers for trying things out
	global rightFingersPPT, leftFingersPPT, leftForeArmPPT, rightForeArmPPT, rightHandViveController, leftHandViveController
	
	#nvis.nvisorSX111();
	#nvis.nvisorSX60();
	#try the oculus rift
	hmd = None
	headOriTracker = None
	
	if some_global_variables.PPT1:
		vrpn = viz.add('vrpn7.dle')

	#trying to connect the vive now
	if not some_global_variables.DONT_USE_VIVE:
		hmd = steamvr.HMD()
		headOriTracker = hmd.getSensor()
	headPosTracker = None
	headPosLink = None

	if headOriTracker is None:
		print "HTC Vive is not connected. Trying Oculus Rift now"
		hmd = oculus.Rift()
		headOriTracker = hmd.getSensor()
		if headOriTracker is None:
			print "Rift is also not connected!"
		else:
			print "Connected to Rift!"
			vizact.onkeydown('r',headOriTracker.reset)
			if some_global_variables.PPT1:
				headPosTracker = vrpn.addTracker('PPT0@' + some_global_variables.PPT_HOSTNAME, some_global_variables.PPT_HEAD_VIRTUAL_ID - 1)
				headPosTrackerNode = viz.addGroup()
				headPosLink = viz.link(headPosTracker, headPosTrackerNode)
				headPosLink.preTrans(list(EYE_VECTOR))
	else:
		print "Connected to Vive!"

	#Merge position and orientation links for the head tracker, if needed
	if headPosLink is not None:
		#using DK2 in PPT1 with a PPT marker for head tracking
		headPPT = viz.mergeLinkable(headPosLink,headOriTracker)
	else:
		#like using vive, or DK2 outside PPT1
		headPPT = headOriTracker

	if headOriTracker is not None:
		some_global_variables.headTrackingActive = True

	viz.mouse.setVisible(False)
	#viz.cursor(viz.OFF);
	view = viz.MainView

	viewLink = None
	navigationNode = viz.addGroup()
	viewLink = viz.link(navigationNode, viz.MainView)
	if headPPT is not None:
		viewLink.preMultLinkable(headPPT)
		
	if not some_global_variables.PPT1:
		viewLink.setOffset([0,1.4,0])
#		viewLink = viz.link(headPPT, viz.MainView)
	#viewLink.postTrans([EYE_VECTOR[0], EYE_VECTOR[1], EYE_VECTOR[2]])
	#hmdLink.preTrans(EYE_VECTOR)
	#view.preTrans(EYE_VECTOR)
	#headPPT.preTrans([0,10,0]);
	
	#now add the PPT hands tracker
	if some_global_variables.PPT1:
		rightForeArmPPT = vrpn.addTracker('PPT0@' + some_global_variables.PPT_HOSTNAME, some_global_variables.PPT_RIGHT_FOREARM_VIRTUAL_ID-1)
		if rightForeArmPPT is not None: print "right forearm tracker is active with virtual PPT ID = " + str(some_global_variables.PPT_RIGHT_FOREARM_VIRTUAL_ID)

		leftForeArmPPT = vrpn.addTracker('PPT0@' + some_global_variables.PPT_HOSTNAME, some_global_variables.PPT_LEFT_FOREARM_VIRTUAL_ID-1)
		if leftForeArmPPT is not None: print "left forearm tracker is active with virtual PPT ID = " + str(some_global_variables.PPT_LEFT_FOREARM_VIRTUAL_ID)
		
		appendageControlWithVive = vizinput.choose('Using Vive controllers or a bunch of PPT markers?', ['Vive','4 extra PPT marker!'])
		
		if appendageControlWithVive == 0: #using vive hand controllers
			some_global_variables.usingViveHandControllers = True
			viveHandControllerList = steamvr.getControllerList()
			controllerCount = 0
			for controller in steamvr.getControllerList():
				controllerCount += 1
				#Right Hand Controller Setup
				if controllerCount == 1:
				  rightHandViveController = viveHandControllerList[0]
				#Left Hand Controller Setup
				elif controllerCount == 2:
				  leftHandViveController = viveHandControllerList[1]
		else: #using four extra PPT markers - could be noisy due to interference
			rightFingersPPT = vrpn.addTracker('PPT0@' + some_global_variables.PPT_HOSTNAME, some_global_variables.PPT_RIGHT_FINGERS_VIRTUAL_ID-1)
			if rightFingersPPT is not None: print "right fingers tracker is active with virtual PPT ID = " + str(some_global_variables.PPT_RIGHT_FINGERS_VIRTUAL_ID)

			leftFingersPPT = vrpn.addTracker('PPT0@' + some_global_variables.PPT_HOSTNAME, some_global_variables.PPT_LEFT_FINGERS_VIRTUAL_ID-1)
			if leftFingersPPT is not None: print "left fingers tracker is active with virtual PPT ID = " + str(some_global_variables.PPT_LEFT_FINGERS_VIRTUAL_ID)

			rightWristPPT = vrpn.addTracker('PPT0@' + some_global_variables.PPT_HOSTNAME, some_global_variables.PPT_RIGHT_WRIST_VIRTUAL_ID-1)
			if rightWristPPT is not None: print "right wrist tracker is active with virtual PPT ID = " + str(some_global_variables.PPT_RIGHT_WRIST_VIRTUAL_ID)

			leftWristPPT = vrpn.addTracker('PPT0@' + some_global_variables.PPT_HOSTNAME, some_global_variables.PPT_LEFT_WRIST_VIRTUAL_ID-1)
			if leftWristPPT is not None: print "left wrist tracker is active with virtual PPT ID = " + str(some_global_variables.PPT_LEFT_WRIST_VIRTUAL_ID)

			
	
	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
import viz
import viztask
import json
import logging
import vizinput
import sys, os
import time
import steamvr
import Queue
import threading
import numpy

#from telloVideo import telloVideo
#from tello import Tello

choice = vizinput.choose('Select Experiment Mode',
                         ['Online', 'Offline', 'Simulate Online'])

# Load the presettings file
presettingfile = open('PreSettings_Single.json')
settings = json.load(presettingfile)
stimulationLength = settings[u'stimulationLength'][0]
stimuliLoop = settings[u'stimuliLoop'][0]
frequence = settings[u'frequence']
phase = settings[u'phase']
size = settings[u'squaresize'][0]
keepsize = settings[u'keepsize'][0]
cuelen = settings[u'cuelen'][0]
textList = settings[u'controlCommand']
textposition = settings[u'textposition']
position = settings[u'position']
#framerate = settings[u'framerate'][0]
carlist = []
pivot = [0, 0, 0]
carchoice = 1
currentcar = 'Mini'
speed = 0.0
steer = 0.0
motion = 0
rotateY = 0.0
rotateX = 0.0
viz.clip(0.1, 30000)
vizconnect.go('camera.py')
viz.splashScreen('assets/tracksplash.jpg')
viz.phys.enable()
#carchoiceinit = vizinput.choose('Choose a car:', ['Mini','BMW','Ford Thunderbird','Ford Focus','Lamborghini Murcielago','TVR Speed 12','Dodge Challenger', 'Caterham Seven'])
#carchoice = carchoiceinit + 1
environmentchoice = vizinput.choose('Select time of day:', ['Day', 'Night'])
viz.message(
    'Arrow Keys to steer. Z to go down a gear, X to go up a gear. G to swap between automatic/manual. Up to accelerate, Down to reverse (Automatic only). Spacebar to brake.'
)
#import Drivingfunctions
track = viz.addChild('assets/environment/track.osgb')
station = viz.addChild('assets/environment/gasStation.fbx')
#buildings = viz.addChild('assets/environment/City.osgb')
tower = viz.addChild('assets/environment/Building.fbx')
if environmentchoice == 0:
    environment = viz.addChild('sky_day.osgb')
else:
    environment = viz.addChild('sky_night.osgb')
environment.setScale(10, 10, 10)
track.setScale(5, 0, 5)
station.setScale(5, 5, 5)
Beispiel #8
0
		

#toggle billboarding of the mustache man toward the user (if you don't turn this on, he is facing away from the user)	
def billboardToggle():
	global BILLBOARD
	if BILLBOARD:
		mustacheMan.billboard(viz.OFF)
		BILLBOARD = False
	else:
		mustacheMan.billboard(viz.BILLBOARD_YAXIS)
		BILLBOARD = True

		
placeMirror()

AVATAR_BODY = ['Female1','Female2','Female3','Female4', 'Female5', 'Male1', 'Male2', 'Male3', 'Male4', 'Male5'][vizinput.choose('Which avatar would you like to begin with?',['Female1','Female2','Female3','Female4', 'Female5', 'Male1', 'Male2', 'Male3', 'Male4', 'Male5'])]

vizconnect.go('vizconnect_config_vive_proteus.py')

viz.window.setSize(1900,1000)
if AVATAR_BODY == 'Male1':
	currentAvatar = vizconnect.getRawAvatar('white_male')
if AVATAR_BODY == 'Female1':
	currentAvatar = vizconnect.getRawAvatar('black_female')
if AVATAR_BODY == 'Male2':
	currentAvatar = vizconnect.getRawAvatar('old_white_male')
if AVATAR_BODY == 'Male3':
	currentAvatar = vizconnect.getRawAvatar('black_male')
if AVATAR_BODY == 'Female2':
	currentAvatar = vizconnect.getRawAvatar('blonde_female')
if AVATAR_BODY == 'Female3':
Beispiel #9
0
import viz, viztask, vizact, vizinput, vizshape
import math
import random
import oculus
import time
import datetime
from datetime import date
from string import maketrans
import itertools, csv, time

#start vrpn
vrpn = viz.addExtension('vrpn7.dle')

#Ask for mode
presentations = ['oculus', 'normal']
presentationMode = vizinput.choose('Presentation Mode', presentations)

#Prompt for the participant's demographic

subject = vizinput.input('What is the participant number?')
age = vizinput.input('age?')
sex = ['male', 'female']
sex_choice = vizinput.choose('Sex', sex)
handedness = ['right', 'left', 'both']
handedness_choice = vizinput.choose('Handedness', handedness)
run = vizinput.input('Which run?')
ts = time.time()

##create demographic data file
demographic_data = open('demographic_data.csv', 'w')
with open('data/demographic_data.csv', 'a') as f:
"""

import viz, viztask, vizact, vizinput, vizshape
import math
import random
import oculus
import time
import datetime
from datetime import date
from string import maketrans
import itertools, csv, time
import numpy

#Ask for mode
presentations = ['oculus','normal']
presentationMode = vizinput.choose('Presentation Mode', presentations)

#Prompt for the participant's demographic
def participantInfo():

	subject = vizinput.input('What is the participant number?')
	age = vizinput.input('age?')
	sex = ['male','female']
	sex_choice = vizinput.choose('Sex',sex)
	handedness = ['right','left','both']
	handedness_choice = vizinput.choose('Handedness',handedness)
	ts = time.time()

	##create demographic data file
	demographic_data = open('demographic_data_rod_frame.csv','w')
	with open('data/demographic_data_rod_frame.csv', 'a') as f:
# Start Vizard with a prompt dialog box
viz.go(viz.PROMPT)

import vizinfo
vizinfo.add('This script demonstrates how to gather input from the user at startup.')

#Retrieve text from the prompt
speed = viz.get(viz.INITMESG)

#Ask user for name
name = vizinput.input('What is your name?')

choices = ['Blue','Green','Orange']
colors = [[0,0,1],[0,1,0],[1,0.5,0]]
#Ask user for favorite color
favColor = vizinput.choose('Which of the following colors is your most favorite?',choices)

#Create text object of user name
text = viz.addText(name)
text.setPosition([0,3,7])
text.color(colors[favColor])

# Try to convert the text into a number.
# If the text is invalid, then set the rotation speed to 90.
try:
    rotateSpeed = float(speed)
except:
    rotateSpeed = 90

# Add the ball and move it in front of the viewer
ball = viz.addChild('beachball.osgb')