![]() |
|
#1
|
|||
|
|||
You need to post the code using the [code][/code] tags. This will preserve the indentation, which is necessary for running Python code.
|
#2
|
|||
|
|||
sorry, i'm new to this format so i thought it would preserve the tabs that were in place. here's the code again:
import viz import vizact import time import math import random import winsound ground = viz.add('Models/ground_2m.ive') pit = viz.add('Models/ground_pit_new.ive') viz.go(viz.STEREO | viz.FULLSCREEN) light1 = viz.addLight() #Add an overhead light light1.setEuler(0,90,0) ## Prompt for the participant's identification number - generally keep this uncommented! ## keyControl = viz.input('Using Tracker? 1 = Yes, 2 = No') #subject = viz.input('What is the participant number?') if keyControl == 1: eyeohd = viz.input('What is the participants IOD?') viz.fov(43,1.395) #Cybermind specs ##Rename the main view ## view = viz.MainView #Link viewpoint with tracker, initialize boresite if keyControl == 1: #If you're using the tracker headTrack = viz.addSensor('intersense')#Ignore documentation stating you need "intersense.dls" - this is correct ##################################### #Initialize parameters for keyboard control MOVE_SPEED = 1.3 #m/s TURN_SPEED = 60 #deg/s #NOTE: Default eye height for keyboard control is 6', doesn't affect tracked viewpoint viz.phys.enable() # Enable physics viz.MainView.gravity (0) #This turns mouse control of view and mouse pointer off - very disconcerting for subjects! # Generally keep both viz.OFF, unless you have a specific need. viz.mouse(viz.OFF) viz.cursor(viz.OFF) Risen = True def masterLoop(num): global Risenviz.callback(viz.TIMER_EVENT,masterLoop) #This starts the timer. First value (0) is a timer identifier, second (1/60) is the refresh rate, third (viz.FOREVER) is how long it lasts viz.starttimer(0,1/60.0,viz.FOREVER) Reply With Quote |
#3
|
|||
|
|||
I get a syntax error when trying to run your code. It doesn't seem like you used the [code][/code] tags. Just copy the contents of your script and paste them in between the tags.
|
#4
|
|||
|
|||
are there additional tags to indicate that the code is starting and ending? they are not clearly marked in any of the message options.
Code:
import viz import vizact import time import math import random import winsound viz.go(viz.STEREO | viz.FULLSCREEN) light1 = viz.addLight() #Add an overhead light light1.setEuler(0,90,0) ## Prompt for the participant's identification number - generally keep this uncommented! ## keyControl = viz.input('Using Tracker? 1 = Yes, 2 = No') #subject = viz.input('What is the participant number?') if keyControl == 1: eyeohd = viz.input('What is the participants IOD?') viz.fov(43,1.395) #Cybermind specs ##Rename the main view ## view = viz.MainView #Link viewpoint with tracker, initialize boresite if keyControl == 1: #If you're using the tracker headTrack = viz.addSensor('intersense')#Ignore documentation stating you need "intersense.dls" - this is correct linkedTracker = viz.link(headTrack, view) #Link the sensor to the view. linkedTracker.preTrans([0,-.15,.14]) #Boresite function - translates the viewpoint from the tracker position to eyepoint position # viz.link(headTrack, view) #Link the sensor to the view. viz.eyeheight(0.0) view.translate(0,-.19,.14) #Boresite function - translates the viewpoint from the tracker position to eyepoint position viz.ipd(eyeohd/100.0) ##################################### #Initialize parameters for keyboard control MOVE_SPEED = 1.3 #m/s TURN_SPEED = 60 #deg/s #NOTE: Default eye height for keyboard control is 6', doesn't affect tracked viewpoint viz.phys.enable() # Enable physics viz.MainView.gravity (0) #This turns mouse control of view and mouse pointer off - very disconcerting for subjects! # Generally keep both viz.OFF, unless you have a specific need. viz.mouse(viz.OFF) viz.cursor(viz.OFF) Risen = True def masterLoop(num): global Risen fallAction = vizact.fall(-28.18) riseAction = vizact.fall(1.82) if view.getPosition(mode=viz.ABS_GLOBAL)[0] > -1 and view.getPosition(mode=viz.ABS_GLOBAL)[0] < 1: view.add(fallAction) Risen = False if view.getPosition(mode=viz.ABS_GLOBAL)[2] > 5.375: view.add(fallAction) Risen = False elif view.getPosition(mode=viz.ABS_GLOBAL)[2] < 4.625 and view.getPosition(mode=viz.ABS_GLOBAL)[2] > -1.625: view.add(fallAction) Risen = False elif view.getPosition(mode=viz.ABS_GLOBAL)[2] < -2.375: view.add(fallAction) Risen = False else: view.add(riseAction) Risen = False print 'back up' elif (view.getPosition(mode=viz.ABS_GLOBAL)[0] < -1 or view.getPosition(mode=viz.ABS_GLOBAL)[0] > 1) and Risen == False: view.add(riseAction) Risen = True print 'normal view' ###### KEYBOARD CONTROL MODULE - DON'T TOUCH ###### if keyControl == 2: #If you're using the keyboard; defined at top if viz.iskeydown(viz.KEY_UP): #If the up key is depressed view.move(0,0,MOVE_SPEED*viz.elapsed(),viz.BODY_OR I) # Move view to z coordinate specified by speed*elapsed time elif viz.iskeydown(viz.KEY_DOWN): #And so on and so forth view.move(0,0,-MOVE_SPEED*viz.elapsed(),viz.BODY_ORI) if viz.iskeydown(viz.KEY_RIGHT): view.rotate(0,1,0,TURN_SPEED*viz.elapsed(),viz.BOD Y_ORI,viz.RELATIVE_WORLD) elif viz.iskeydown(viz.KEY_LEFT): view.rotate(0,1,0,-TURN_SPEED*viz.elapsed(),viz.BODY_ORI,viz.RELATIVE _WORLD) ############################################# viz.callback(viz.TIMER_EVENT,masterLoop) #This starts the timer. First value (0) is a timer identifier, second (1/60) is the refresh rate, third (viz.FOREVER) is how long it lasts viz.starttimer(0,1/60.0,viz.FOREVER) Reply With Quote |
#5
|
|||
|
|||
here is the code that should have all the tabs in the right place
Code:
import viz import vizact import time import math import random import winsound ground = viz.add('Models/ground_2m.ive') pit = viz.add('Models/ground_pit_new.ive') viz.go(viz.STEREO | viz.FULLSCREEN) light1 = viz.addLight() #Add an overhead light light1.setEuler(0,90,0) ## Prompt for the participant's identification number - generally keep this uncommented! ## keyControl = viz.input('Using Tracker? 1 = Yes, 2 = No') #subject = viz.input('What is the participant number?') if keyControl == 1: eyeohd = viz.input('What is the participants IOD?') viz.fov(43,1.395) #Cybermind specs ##Rename the main view ## view = viz.MainView #Link viewpoint with tracker, initialize boresite if keyControl == 1: #If you're using the tracker headTrack = viz.addSensor('intersense')#Ignore documentation stating you need "intersense.dls" - this is correct linkedTracker = viz.link(headTrack, view) #Link the sensor to the view. linkedTracker.preTrans([0,-.15,.14]) #Boresite function - translates the viewpoint from the tracker position to eyepoint position # viz.link(headTrack, view) #Link the sensor to the view. viz.eyeheight(0.0) view.translate(0,-.19,.14) #Boresite function - translates the viewpoint from the tracker position to eyepoint position viz.ipd(eyeohd/100.0) ##################################### #Initialize parameters for keyboard control MOVE_SPEED = 1.3 #m/s TURN_SPEED = 60 #deg/s #NOTE: Default eye height for keyboard control is 6', doesn't affect tracked viewpoint viz.phys.enable() # Enable physics viz.MainView.gravity (0) #This turns mouse control of view and mouse pointer off - very disconcerting for subjects! # Generally keep both viz.OFF, unless you have a specific need. viz.mouse(viz.OFF) viz.cursor(viz.OFF) Risen = True def masterLoop(num): global Risen fallAction = vizact.fall(-28.18) riseAction = vizact.fall(1.82) if view.getPosition(mode=viz.ABS_GLOBAL)[0] > -1 and view.getPosition(mode=viz.ABS_GLOBAL)[0] < 1: if view.getPosition(mode=viz.ABS_GLOBAL)[2] > 5.375: view.add(fallAction) Risen = False elif view.getPosition(mode=viz.ABS_GLOBAL)[2] < 4.625 and view.getPosition(mode=viz.ABS_GLOBAL)[2] > -1.625: view.add(fallAction) Risen = False elif view.getPosition(mode=viz.ABS_GLOBAL)[2] < -2.375: view.add(fallAction) Risen = False else: view.add(riseAction) Risen = False print 'back up' elif (view.getPosition(mode=viz.ABS_GLOBAL)[0] < -1 or view.getPosition(mode=viz.ABS_GLOBAL)[0] > 1) and Risen == False: view.add(riseAction) Risen = True print 'normal view' ###### KEYBOARD CONTROL MODULE - DON'T TOUCH ###### if keyControl == 2: #If you're using the keyboard; defined at top if viz.iskeydown(viz.KEY_UP): #If the up key is depressed view.move(0,0,MOVE_SPEED*viz.elapsed(),viz.BODY_ORI) # Move view to z coordinate specified by speed*elapsed time elif viz.iskeydown(viz.KEY_DOWN): #And so on and so forth view.move(0,0,-MOVE_SPEED*viz.elapsed(),viz.BODY_ORI) if viz.iskeydown(viz.KEY_RIGHT): view.rotate(0,1,0,TURN_SPEED*viz.elapsed(),viz.BODY_ORI,viz.RELATIVE_WORLD) elif viz.iskeydown(viz.KEY_LEFT): view.rotate(0,1,0,-TURN_SPEED*viz.elapsed(),viz.BODY_ORI,viz.RELATIVE_WORLD) ############################################# viz.callback(viz.TIMER_EVENT,masterLoop) #This starts the timer. First value (0) is a timer identifier, second (1/60) is the refresh rate, third (viz.FOREVER) is how long it lasts viz.starttimer(0,1/60.0,viz.FOREVER) |
#6
|
|||
|
|||
again note that i've put in a model just so that i can tell where i am in the world, can be replaced with any generic ground plane.
|
#7
|
|||
|
|||
I just ran your script using an Intersense InertiaCube2 and it ran fine. What kind of Intersense device are you connecting to?
|
![]() |
Thread Tools | |
Display Modes | Rate This Thread |
|
|