Beispiel #1
0
    def __init__(self, Cave):
        viz.EventClass.__init__(self)

        #self.__speed = 0.223 #metres per frame. equates to 13.4 m/s therefore 30mph.
        #8ms = 8/60 = .1333
        self.__speed = 8.0  #m./s
        self.__heading = 0.0
        self.__pause = -50  #pauses for 50 frames at the start of each trial

        self.__view = Cave
        # self.__view = viz.MainView.setPosition(0,1.20,0) #Grabs the main graphics window
        # self.__view = viz.MainView
        # self.__view.moverelative(viz.BODY_ORI)

        self.__automation = False

        self.__dir = 1.0  # direction of the vehicle (+: )

        #self.callback(viz.TIMER_EVENT,self.__ontimer)
        self.callback(viz.KEYDOWN_EVENT,
                      self.keyDown)  #enables control with the keyboard
        self.callback(vizjoy.BUTTONDOWN_EVENT, self.joyDown)
        self.callback(vizjoy.MOVE_EVENT, self.joymove)

        #self.txtSWA = viz.addText("SWA",parent=viz.SCREEN)
        self.txtSWA = viz.addText("  ", parent=viz.SCREEN)
        self.txtSWA.setPosition(.45, .4)
        self.txtSWA.fontSize(36)

        #self.starttimer(0,0,viz.FOREVER)

        global joy
        joy = vizjoy.add()
    def __init__(self, Cave, Distractor):
        viz.EventClass.__init__(self)

        #self.__speed = 0.223 #metres per frame. equates to 13.4 m/s therefore 30mph.
        #8ms = 8/60 = .1333
        self.__speed = 8  #m./s =30mph
        self.__heading = 0.0
        self.__pause = 0  #pauses for 50 frames at the start of each trial
        self.gearPressed = False  #a second way to measure gearpaddown, for distractor end of trial.

        self.__Wheel_yawrate_adjustment = 0  #difference between real steering angle and virtual yaw-rate.

        self.__Distractor = Distractor  #distractor class for callbacks.

        self.__view = Cave
        # self.__view = viz.MainView.setPosition(0,1.20,0) #Grabs the main graphics window
        # self.__view = viz.MainView
        # self.__view.moverelative(viz.BODY_ORI)

        self.__automation = False

        self.__dir = 1.0  # direction of the vehicle (+: )

        #self.callback(viz.TIMER_EVENT,self.__ontimer)
        self.callback(viz.KEYDOWN_EVENT,
                      self.keyDown)  #enables control with the keyboard
        self.callback(vizjoy.BUTTONDOWN_EVENT, self.joyDown)
        self.callback(vizjoy.MOVE_EVENT, self.joymove)
        #self.starttimer(0,0,viz.FOREVER)

        global joy
        joy = vizjoy.add()
Beispiel #3
0
 def __init__ (self, win, PlayViewObj=None, device='RUMBLEPAD'):
     self.joystick = vizjoy.add()
     self.view = win.getView()
     self.window = win
     self.toolActive = 0
     self.moveCursor = False 
     self.filter = LowPassDynamicFilter(0.5, 5, 10.0, 200.0)
     self.player = PlayViewObj
     #Call super class constructor to create different callbacks for every joystick
     viz.EventClass.__init__(self)
     self.callback(vizjoy.BUTTONDOWN_EVENT, self.joydown)
     self.callback(vizjoy.BUTTONUP_EVENT, self.joyup)
     self.callback(vizjoy.HAT_EVENT, self.joyhat)
     #decide the button actions based on the joystick
     self._updateFunc = vizact.onupdate(0, self.UpdateJoystick)
     if 'Rumblepad' in self.joystick.getName():
         self.device = 'RUMBLEPAD'
         self.actions = {'prev':[1,5], 'next':[3,6], 'pick':[2, 7, 8, 11, 12], 'drop':4, 'hud':9}
     elif 'XBOX' in self.joystick.getName().upper():
         self.device = 'XBOX'
         self.actions = {'prev':[3], 'next':[2], 'pick':[1, 9, 10, 5, 6], 'drop':4, 'hud':7}
         self.triggerActive = True   #False after trigger buttons are pressed
         #Create a callback to handle the expiring trigger (de)activation events
         self.callback(viz.TIMER_EVENT, self.timerExpire)
     else:
         self.device = 'XBOX'
         vizinput.message('Joystick not detected! Xbox will be used instead with limited functionality.')
Beispiel #4
0
def initInputs(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
	#VC: place any general initialization code here
	rawInput = vizconnect.getRawInputDict()

	#VC: initialize a new input
	_name = 'r_hand_input'
	if vizconnect.isPendingInit('input', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: create the raw object
			import vizjoy
			rawInput[_name] = vizjoy.add()
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addInput(rawInput[_name], _name, make='Generic', model='Joystick')

	#VC: return values can be modified here
	return None
def initInputs(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawInput = vizconnect.getRawInputDict()

    #VC: initialize a new input
    _name = 'keyboard'
    if vizconnect.isPendingInit('input', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: set some parameters
            index = 0

            #VC: create the raw object
            d = viz.add('directinput.dle')
            device = d.getKeyboardDevices()[index]
            rawInput[_name] = d.addKeyboard(device)

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addInput(rawInput[_name],
                                _name,
                                make='Generic',
                                model='Keyboard')

    #VC: initialize a new input
    _name = 'joystick'
    if vizconnect.isPendingInit('input', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: create the raw object
            import vizjoy
            rawInput[_name] = vizjoy.add()

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addInput(rawInput[_name],
                                _name,
                                make='Generic',
                                model='Joystick')

    #VC: return values can be modified here
    return None
def initInputs(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
	#VC: place any general initialization code here
	rawInput = vizconnect.getRawInputDict()

	#VC: initialize a new input
	_name = 'joystick'
	if vizconnect.isPendingInit('input', _name, initFlag, initList):
		#VC: init the raw object
		if initFlag&vizconnect.INIT_RAW:
			#VC: create the raw object
			import vizjoy
			rawInput[_name] = vizjoy.add()
	
		#VC: init the wrapper (DO NOT EDIT)
		if initFlag&vizconnect.INIT_WRAPPERS:
			vizconnect.addInput(rawInput[_name], _name, make='Generic', model='Joystick')
		

	#VC: return values can be modified here
	return None
Beispiel #7
0
def initInputs(initFlag=vizconnect.INIT_INDEPENDENT, initList=None):
    #VC: place any general initialization code here
    rawInput = vizconnect.getRawInputDict()

    #VC: initialize a new input
    _name = 'joystick'
    if vizconnect.isPendingInit('input', _name, initFlag, initList):
        #VC: init the raw object
        if initFlag & vizconnect.INIT_RAW:
            #VC: create the raw object
            import vizjoy
            rawInput[_name] = vizjoy.add()

        #VC: init the wrapper (DO NOT EDIT)
        if initFlag & vizconnect.INIT_WRAPPERS:
            vizconnect.addInput(rawInput[_name],
                                _name,
                                make='Generic',
                                model='Joystick')

        #VC: init the mappings for the wrapper
        if initFlag & vizconnect.INIT_WRAPPER_MAPPINGS:
            #VC: on-state mappings
            if initFlag & vizconnect.INIT_MAPPINGS_ON_STATE:
                vizconnect.getInput(_name).setOnStateEventList([
                    vizconnect.onstate(
                        lambda rawInput: rawInput['joystick'].isButtonDown(1),
                        vizconnect.getInput(_name).setMode
                    ),  # make=Generic, model=Joystick, name=joystick, signal=Button 1
                ])

    #VC: set the name of the default
    vizconnect.setDefault('input', 'joystick')

    #VC: return values can be modified here
    return None
objectHeight = 0
#Create locations for all of the objects in the envirnoment
masterObjectLocations = [[-1.04082, objectHeight, 24],
	[-8.44218,objectHeight, 4.5714],
	[-15.2653,objectHeight, -9.90476],
	[1.04082,objectHeight, -11.8095],
	[12.6054,objectHeight, -21.7143],
	[15.6122 + xdif,objectHeight, -9.71429 + xdif * slopefromthreeto5]]

dojo = viz.addChild("ground_grass.osgb")
dojo.setScale(1.5,1.5,1.5)
sky = viz.addChild("sky_day.osgb")

#Add a joystick
joystick = vizjoy.add()

objectSet = 0

testingHeight = 0
#positions of cylinders for people to walk to and use to orient selves
masterTargetLocations = [[-17, testingHeight, 1.3333],
	[-7.17007, testingHeight, -11.2381],
	[1.04082, testingHeight, -23.8095],
	[8.21088, testingHeight, -15.619],
	[6.82313, testingHeight, -3.80952],
	[15.2653, testingHeight, 2.47619]]
targetLocations = []
#positions of arrows for people to face towards
offset = 2
fournegrecslope = -.7224
from numpy import array, append, resize, set_printoptions
from math import pow, sqrt
import time
import viz
import viztask
import vizinfo
import vizmat
import vizact
import vizjoy
import pandas as pd
import os.path

# launch vizard and enable physics and joystick
viz.go(viz.FULLSCREEN)
viz.phys.enable()
joy = vizjoy.add()

# disable numpy array printing threshold
set_printoptions(threshold='nan')

# define globals
coordinate_array = array([])
movement_time = 0
trial_number = 0
sub_trial_number = 0
collide_coords = []
subject_id_data = 0
signal = viztask.Signal()
maze = ''
maze_root = ''
condition = 0
#import viz
import vizcave
import viztracker
import vizact
import time
import array
import socket
import artTracker
import random
import math
import vizjoy

#IMPORTANT: Need to add a joystick. This will return the first detected joystick
joy = vizjoy.add()
#####################
#get Zepplin
import Zeppelin
from Zeppelin import ZEP

import Logo
from Logo import Logo


#####################
#setup CAVE
viz.multiSample = 4
polyMode = viz.POLY_WIRE
#viz.setFarPlane(1)
#viz.setMultiSample(config.multiSample) seems to give this error message
viz.window.setPolyMode(viz.POLY_WIRE)
viz.MainWindow.fov(50)