def RollupSC (): def open_SCblind(): #ABRE LA PERSIANA DE FORMA CORRIDA dpos = Rollup_SC_GEODE.getPosition(viz.ABS_GLOBAL) new_dpos = [dpos[0], dpos[1]+ 0.5, dpos[2]] Rollup_SC_GEODE.setPosition(new_dpos, viz.ABS_GLOBAL) #luzAmbiente.enable() def close_SCblind(): #CIERRA LA PERSIANA DE FORMA CORRIDA dpos = Rollup_SC_GEODE.getPosition(viz.ABS_GLOBAL) new_dpos = [dpos[0], dpos[1]- 0.5, dpos[2]] Rollup_SC_GEODE.setPosition(new_dpos, viz.ABS_GLOBAL) #luzAmbiente.disable() global state_rollupsc print 'estoy en rollupsc' # if e.gesture == rightHand.getSensor().returnOpen[0]: # print 'nada' # else: if state_rollupsc == 1: #CERRAR vizact.ontimer2(1,3, close_SCblind) state_rollupsc = 0 else: #ABRIR vizact.ontimer2(1,3, open_SCblind) state_rollupsc = 1
def objectBasketed(e): global rhandtar, lhandtar, rSelectedNode, lSelectedNode, rhGrabber, lhGrabber, ALL_GRABBED_EVENT global yMove, basketBounding selectedNode = e.__dict__['released'] # if e.target == rhandtar: # selectedNode = rSelectedNode # elif e.target == lhandtar: # selectedNode = lSelectedNode if selectedNode != None: globals_oa.AUDIO_SUCCESS.play() yMove = 0.02 basketBounding = globals_oa.basket.getBoundingBox() vizact.ontimer2(0.001, 400, dropObject, selectedNode) rhGrabber.removeItems([selectedNode]) lhGrabber.removeItems([selectedNode]) # if e.target == rhandtar: # rhGrabber.release() # elif e.target == lhandtar: # lhGrabber.release() currentListOfGrabables = rhGrabber.getItems() print "currentListOfGrabables = " + str(currentListOfGrabables) if currentListOfGrabables == []: viz.sendEvent(ALL_GRABBED_EVENT)
def RollupKit (): def open_Kitblind(): #ABRE LA PERSIANA DE FORMA CORRIDA dpos1 = Rollup_kit_GEODE.getPosition(viz.ABS_GLOBAL) new_dpos1 = [dpos1[0], dpos1[1]+ 0.5, dpos1[2]] Rollup_kit_GEODE.setPosition(new_dpos1, viz.ABS_GLOBAL) dpos2 = Rollup_kit2_GEODE.getPosition(viz.ABS_GLOBAL) new_dpos2 = [dpos2[0], dpos2[1]+ 0.5, dpos2[2]] Rollup_kit2_GEODE.setPosition(new_dpos2, viz.ABS_GLOBAL) #luzAmbiente.enable() def close_Kitblind(): #CIERRA LA PERSIANA DE FORMA CORRIDA dpos1 = Rollup_kit_GEODE.getPosition(viz.ABS_GLOBAL) new_dpos1 = [dpos1[0], dpos1[1]- 0.5, dpos1[2]] Rollup_kit_GEODE.setPosition(new_dpos1, viz.ABS_GLOBAL) dpos2 = Rollup_kit2_GEODE.getPosition(viz.ABS_GLOBAL) new_dpos2 = [dpos2[0], dpos2[1]- 0.5, dpos2[2]] Rollup_kit2_GEODE.setPosition(new_dpos2, viz.ABS_GLOBAL) #luzAmbiente.disable() global state_rollupkit print 'estoy en rollupkitchen' # if e.gesture == rightHand.getSensor().returnOpen[0]: # print 'nada' # else: if state_rollupkit == 1: #CERRAR vizact.ontimer2(1,4, close_Kitblind) state_rollupkit = 0 else: #ABRIR vizact.ontimer2(1,4, open_Kitblind) state_rollupkit = 1
def doorSalon (): def openDoorSalon (): dpos = DoorSalon_GEODE.getPosition(viz.ABS_GLOBAL) new_dpos = [dpos[0] + 0.6, dpos[1], dpos[2]] DoorSalon_GEODE.setPosition(new_dpos, viz.ABS_GLOBAL) cpos = DoorSal_frame_GEODE.getPosition(viz.ABS_GLOBAL) new_cpos = [cpos[0] + 0.6, cpos[1], cpos[2]] DoorSal_frame_GEODE.setPosition(new_cpos, viz.ABS_GLOBAL) def closeDoorSalon (): dpos = DoorSalon_GEODE.getPosition(viz.ABS_GLOBAL) new_dpos = [dpos[0] - 0.6, dpos[1], dpos[2]] DoorSalon_GEODE.setPosition(new_dpos, viz.ABS_GLOBAL) cpos = DoorSal_frame_GEODE.getPosition(viz.ABS_GLOBAL) new_cpos = [cpos[0] - 0.6, cpos[1], cpos[2]] DoorSal_frame_GEODE.setPosition(new_cpos, viz.ABS_GLOBAL) global state_doorsal print 'estoy en doorsalón' # if e.gesture == rightHand.getSensor().returnOpen[0]: # print 'nada' # else: if state_doorsal == 1: #CERRAR vizact.ontimer2(1, 2, closeDoorSalon) state_doorsal = 0 else: #ABRIR vizact.ontimer2(1,2,openDoorSalon) state_doorsal = 1
def onEnter(e): global rightHandTarget, leftHandTarget print 'working' if e.target == rightHandTarget: vizact.ontimer2(.004, 100, vibrateRightHand) if e.target == leftHandTarget: vizact.ontimer2(.004, 100, vibrateLeftHand)
def main(): global initialStep # if initialStep: time.sleep(3) text1.setPosition(0,1.6,4) print "START" vizact.ontimer2(0.33, 2, getInitial) vizact.ontimer(1/60, checkStep)
def step(): global prevStep prevStep = "UP" print prevStep walk = vizact.walkTo([male.getPosition()[0] + 1, 0,male.getPosition()[2]], walkSpeed = 1) male.runAction(walk) # viz.MainView.velocity(0,0,1) vizact.ontimer2(.9,0,setDown)
def step(): global prevStep prevStep = "UP" x,y,z = unitVector(math.cos(math.radians(aveYaw+90)), 0, math.sin(math.radians(aveYaw+90))) viz.MainView.velocity(x, y, z) vizact.ontimer2(.9,0,setDown)
def step(): global prevStep, stepCount, finalYaw prevStep = "UP" x,y,z = unitVector(math.cos(math.radians(finalYaw+90)), 0, math.sin(math.radians(finalYaw+90))) viz.MainView.velocity(x, y, z) stepCount += 1 print stepCount vizact.ontimer2(.9,0,setDown)
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 training_display(rt,acc): print "acc",acc if acc: msg = "RIGHT" correct_sound.play() else: msg = "WRONG" incorrect_sound.play() block_text.message(msg + " %.2fs"%rt) vizact.ontimer2(rate=MESSAGE_TIME, repeats=0,func=clear_text)
def step(): global prevStep, stepCounter prevStep = "UP" x,y,z = unitVector(math.cos(math.radians(aveYaw+90)), 0, math.sin(math.radians(aveYaw+90))) view.velocity(x, y, z) stepCounter += 1 print stepCounter vizact.ontimer2(.9,0,setDown)
def step(): global prevStep, lastX, lastZ prevStep = "UP" x, z = calcUnitVector() viz.MainView.velocity(lastX, 0, lastZ) lastX = x lastZ = z walk = vizact.walkTo([x + male.getPosition()[0], 0, z + male.getPosition()[2]], walkSpeed=1) viz.MainView.lookAt([male.getPosition()[0], 2, male.getPosition()[2]]) male.runAction(walk) vizact.ontimer2(0.9, 0, setDown)
def grabObject(e): global rSelectedNode, lSelectedNode, rhGrabber, lhGrabber if e.grabber == rhGrabber: rSelectedNode = e.grabbed globals_oa.rhViveTracker.setVibration(0.004) vizact.ontimer2(0.004, 25, vibrateHandController, 2) elif e.grabber == lhGrabber: lSelectedNode = e.grabbed globals_oa.lhViveTracker.setVibration(0.004) vizact.ontimer2(0.004, 25, vibrateHandController, 1) globals_oa.AUDIO_PICKUP.play()
def testex(nothing): global rxplode global lxplode fire1.visible(1) fire2.visible(1) rxplode.visible(1) rxplode.setAnimationTime(0.1) rxplode.setAnimationState(0) vizact.ontimer2(0.6, 0, hide1, 0) lxplode.visible(1) lxplode.setAnimationTime(0.1) lxplode.setAnimationState(0) vizact.ontimer2(0.6, 0, hide2, 0)
def testex(nothing): global rxplode global lxplode fire1.visible(1) fire2.visible(1) rxplode.visible(1) rxplode.setAnimationTime(0.1) rxplode.setAnimationState(0) vizact.ontimer2(0.6,0,hide1,0) lxplode.visible(1) lxplode.setAnimationTime(0.1) lxplode.setAnimationState(0) vizact.ontimer2(0.6,0,hide2,0)
def explode(): print('apply spin') # fire.setPosition(0,0,0) # fire.applyForce( dir=[0,0,-0.01],duration=0.001) # fire.addAction(vizact.spin(1,1,0,500,viz.FOREVER)) # fire.setScale([2,2,2]) # fire.setScale([4,4,4]) # fire.setAnimationSpeed(20) box1.visible(1) box1.setAnimationTime(0) box1.setAnimationState(0) fire.visible(1) vizact.ontimer2(0.6,0,hide,0)
def playNarrationFile( obj=None ): #global selector #selector.disable() selector.removeOnDeselectCallback(RADIO) selector.removeOnSelectCallback(RADIO) selector.disable() print 'narrating' audio = obj.narrationFile[0] sound = viz.addAudio(audio) duration = sound.getDuration() sound.play() print "playing " + str(audio) vizact.ontimer2(duration+DELAY_UNTIL_NARRATION, 0, checkForNextEvent, obj) del obj.narrationFile[0]
def grabObject(e): global rSelectedNode, lSelectedNode, rhtool, lhtool, objectName print "e.grabbed.id = " + str(e.grabbed.id) if e.grabber == rhtool: rSelectedNode = e.grabbed globals_oa.rhViveTracker.setVibration(0.004) vizact.ontimer2(0.004, 25, vibrateHandController, 2) elif e.grabber == lhtool: lSelectedNode = e.grabbed globals_oa.lhViveTracker.setVibration(0.004) vizact.ontimer2(0.004, 25, vibrateHandController, 1) #globals_oa.lhModel.disable(viz.RENDERING) #globals_oa.lhClosedModel.visible(True) globals_oa.AUDIO_PICKUP.play() objectName = getObjectName(e.grabbed)
def EnablePlayer1ForMultiInput (self, secInput): if self._player == 1 and len(self.PLAYERS) == 1 and self._collabAction == '': self._collabAction = ', '+secInput #add second action for 1P conditions self._collabIcon.texture(self._collabTextures[0]) self._collabIcon.addAction(vizact.fadeTo(0, begin=1, time=5, interpolate=vizact.easeInCircular)) self._collabTimer = vizact.ontimer2(5, 1, self.DisablePlayer1ForMultiInput) print "PLAYER1: Preparing to execute multi-input action!"
def InitFire(): global fireActivated reportFireTime() viztask.waitTime(1) fire = viz.add('fire_small2.osg') fire.setPosition([-1.35, 1.5, -2.75]) fire.hasparticles() fire.setScale(1, .5, .5) fire.addAction(vizact.spin(0,1,0,360)) ignition = fire.playsound('ignite.wav') ignition.volume(.25) explosion = fire.playsound('explosion.wav') explosion.volume(.25) firecracking = fire.playsound ('longfire.wav') firecracking.volume(.25) vizact.ontimer2(5, 1, KillFire, fire, ignition, explosion, firecracking) fireActivated = True
def ShowFlagAtSnail(e): global rhandtar, lhandtar rightFlagVisible = globals_oa.rhModelFlag.getVisible() leftFlagVisible = globals_oa.lhModelFlag.getVisible() if (e.target == rhandtar) and rightFlagVisible: print "A snail is touched!" sourceNode = e.sensor.getSource()._node print "sourceNode = " + str(sourceNode) for snailAndFlagItem in globals_oa.snailAndFlagItemsInZone1: if snailAndFlagItem.snailItemFromZoneModel == sourceNode: snailVisible = snailAndFlagItem.flagItemFromZoneModel.getVisible() if not snailVisible: # print "snailAndFlagItem.flagItemFromZoneModel.getVisible() before = " + str(snailAndFlagItem.flagItemFromZoneModel.getVisible()) snailAndFlagItem.flagItemFromZoneModel.visible(viz.ON) # globals_oa.AUDIO_PICKUP.play() touchedSnail() vibrateHandController(2) globals_oa.rhViveTracker.setVibration(0.004) vizact.ontimer2(0.004, 25, vibrateHandController, 2) globals_oa.rhFlagCheck = False globals_oa.rhModelFlag.visible(False) # print "snailAndFlagItem.flagItemFromZoneModel.getVisible() after = " + str(snailAndFlagItem.flagItemFromZoneModel.getVisible()) # testForZone1SpeciesCountCompletion() break if (e.target == lhandtar) and leftFlagVisible: print "A snail is touched!" sourceNode = e.sensor.getSource()._node print "sourceNode = " + str(sourceNode) for snailAndFlagItem in globals_oa.snailAndFlagItemsInZone1: if snailAndFlagItem.snailItemFromZoneModel == sourceNode: snailVisible = snailAndFlagItem.flagItemFromZoneModel.getVisible() if not snailVisible: # print "snailAndFlagItem.flagItemFromZoneModel.getVisible() before = " + str(snailAndFlagItem.flagItemFromZoneModel.getVisible()) snailAndFlagItem.flagItemFromZoneModel.visible(viz.ON) # globals_oa.AUDIO_PICKUP.play() touchedSnail() vibrateHandController(1) globals_oa.lhViveTracker.setVibration(0.004) vizact.ontimer2(0.004, 25, vibrateHandController, 1) globals_oa.lhFlagCheck = False globals_oa.lhModelFlag.visible(False) # print "snailAndFlagItem.flagItemFromZoneModel.getVisible() after = " + str(snailAndFlagItem.flagItemFromZoneModel.getVisible()) # testForZone1SpeciesCountCompletion() break
def cross_block(list_of_trials,training=False): # keep track of trial results results = [] successes = 0 block_text.message("DEADLINE: %.2f"%list_of_trials[0][2]) vizact.ontimer2(rate=MESSAGE_TIME, repeats=0,func=clear_text) # Loop over the rest of the trials for trial in list_of_trials[1:]: res = yield cross_trial(*trial,training=training) results.append(res) successes += results[-1]["success"] # Display successes at the end yield end_block(successes,len(list_of_trials)) yield viztask.waitTime(4) # Clear the message block_text.message("") viztask.returnValue( results )
def failedToDetect(self): print 'Failed to detect' viz.clearcolor(viz.RED) # Temporarily stop presenting numbers self.stopPresentingNumbers() vizact.ontimer2(self.updateRateSecs,0,viz.clearcolor,viz.BLACK) vizact.ontimer2(self.updateRateSecs,0,self.startPresentingNumbers) import winsound Freq = 200 # Set Frequency To 2500 Hertz Dur = 150 # Set Duration To 1000 ms == 1 second winsound.Beep(Freq,Dur) if( networkingOn ): netClient.send(message='numberTaskError')
def newActivity(): viz.playSound('Full_Body_Bip001/fire_siren_horn.wav') select.enable( viz.RENDERING ) select.enable( viz.COLLIDE_NOTIFY ) global globalSelected globalSelected = 0 RandomSelection() viz.playSound('Full_Body_Bip001/fire3.wav',viz.LOOP) global game_timer game_timer = vizact.ontimer2(30, 0, ShowResults)
def endTrial(self): endOfTrialList = len(self.blocks_bl[self.blockNumber].trials_tr) #print 'Ending block: ' + str(self.blockNumber) + 'trial: ' + str(self.trialNumber) if( self.trialNumber < endOfTrialList ): recalAfterTrial_idx = self.blocks_bl[self.blockNumber].recalAfterTrial_idx if( recalAfterTrial_idx.count(self.trialNumber ) > 0): soundBank.gong.play() vizact.ontimer2(0,0,self.toggleEyeCalib) # Increment trial self.trialNumber += 1 self.killtimer(self.maxFlightDurTimerID) self.eventFlag.setStatus(6) if( self.trialNumber == endOfTrialList ): # Increment block # arg2 of 1 allows for overwriting eventFlag 6 (new trial) self.eventFlag.setStatus(7,True) self.blockNumber += 1 self.trialNumber = 0 # Increment block or end experiment if( self.blockNumber == len(self.blocks_bl) ): # Run this once on the next frame # This maintains the ability to record one frame of data vizact.ontimer2(0,0,self.endExperiment) return if( self.inProgress ): print 'Starting block: ' + str(self.blockNumber) + ' Trial: ' + str(self.trialNumber) self.currentTrial = self.blocks_bl[self.blockNumber].trials_tr[self.trialNumber]
def updateCounter(objBeingSold): global counter, SELLABLES, sellNarrative, selector, APARTMENT, SCENE if objBeingSold in SELLABLES: counter.decrementValue(LABEL_DATA, objBeingSold.cost, DAYS_PASS_PER_SELL) LABEL_DATA[1].value -= objBeingSold.cost LABEL_DATA[0].value -= DAYS_PASS_PER_SELL print "decremented" print LABEL_DATA[1].value print LABEL_DATA[0].value if LABEL_DATA[0].value == 0: yield viztask.waitTime(1) finalEvictNarrative.play() selector.disable() duration = finalEvictNarrative.getDuration() yield viztask.waitTime(duration) vizact.ontimer2(0.1,10,Events.addFlickeringLight,APARTMENT,SCENE) Events.stopFan(APARTMENT, SCENE) else: yield viztask.waitTime(1) viz.playsound(PLEASE_SELL_AUDIO)
def setActive(value): global active if value == True: waterSound.play() waterSound.loop() choir_sound.play() waterPlane.setPosition([0, -2.0, 0]) for obj in obj_vis: obj.visible(viz.ON) active = True else: for obj in obj_vis: obj.visible(viz.OFF) effect.setEnabled(viz.OFF) updateHandle.setEnabled(viz.OFF) timer.setEnabled(viz.OFF) viz.fog(0) waterSound.stop() choir_sound.stop() vizact.ontimer2(35, 0, resetBubbles) active = False
def selectObject(e): global rhandtar, lhandtar, rhtool, lhtool, objectName, yMove selectedNode = e.__dict__['released'] # if e.target == rhandtar: # selectedNode = rSelectedNode # elif e.target == lhandtar: # selectedNode = lSelectedNode # if globals_oa.tempPromptScreen.getVisible(): # return if selectedNode != None: #Do not remove onDeleseltCallback from node, otherwise crosshair will not change back to normal #foundSound = loadAudioFile(AUDIO_DIRECTORY + 'ding.wav') #foundSound.play() globals_oa.AUDIO_SUCCESS.play() #if objectName is not None: datacollection.recordScavengerHuntObjectFound(globals_oa.currentZoneNumber, objectName, 'bucketed') yMove = 0.002 vizact.ontimer2(0.001, 400, dropSlowly, selectedNode) # selectedNode.visible(False) rhtool.removeItems([selectedNode]) lhtool.removeItems([selectedNode]) updateScore(selectedNode) # if e.target == rhandtar: # rhtool.release() # elif e.target == lhandtar: # lhtool.release() #selectedNode.remove() print "HOORAY YOU FOUND SOMETHING\n" # if not globals_oa.isDemo: # fileOutputAtSpeciesFound() global speciesIndex if numFound == numObjectsToFind[speciesIndex]: disableGrabber() print "TASK COMPLETE" viz.sendEvent(ALL_FOUND_EVENT)
def ShowInfoPanel(self, flag, map=False): self._infoPanel.setPanelVisible(flag) self._infoTimer.setEnabled(0) if flag: #show alert panel for 10 secs and then dismiss it self._infoTimer = vizact.ontimer2(10, 1, self.ShowInfoPanel, False) try: #this runs only for players having a _mapWin property self._infoPanel.setText(self._mapWin._infoPanel.getText()) except: pass #RUNS ONLY FROM MAP: update the info panels of the remaining players if map: for p in self.PLAYERS.values(): p.ShowInfoPanel(flag)
def moveFlashlightToCar(scene=viz.MainScene, walkTime=10): global currSpotExponent, spotExponentEnd, flashlight, timeToReachWindow timeToReachWindow = walkTime currSpotExponent = 1 spotExponentEnd = 0.5 behindCarPOS = [-1.08, 1.38, 3.7] nextToCarPOS = [1.75, 1.38, -1.8] flashlight = addPoliceLights(scene) shortenLight = vizact.ontimer2((timeToReachWindow / spotExponentEnd), spotExponentEnd, changeSpotExponent) moveToCar = vizact.moveTo(nextToCarPOS, begin=behindCarPOS, time=timeToReachWindow) simulatePoliceVisit = vizact.parallel(shortenLight, moveToCar) global footstepsAudio footstepsAudio = flashlight.playsound("resources/audio/Footsteps.wav", viz.LOOP) flashlight.add(simulatePoliceVisit)
def grabObject(e): global rSelectedNode, lSelectedNode, rhGrabber, lhGrabber, notGrabbed, moleculeManager, NUM_CO2, lhandtarget, rhandtarget, overOceanSensor print "Grabber" #vibrate correct hand controller if e.grabber == rhGrabber: rSelectedNode = e.grabbed globals_oa.rhViveTracker.setVibration(0.004) vizact.ontimer2(0.004, 25, vibrateHandController, 2) moleculeManager.addTarget(rhandtarget) print "activated lhandtarget" elif e.grabber == lhGrabber: lSelectedNode = e.grabbed globals_oa.lhViveTracker.setVibration(0.004) vizact.ontimer2(0.004, 25, vibrateHandController, 1) moleculeManager.addTarget(lhandtarget) print "activated rhandtarget" #stabilize molecule and initiate proximity manager NUM_CO2 -= 1 print "still ungrabbed", co2models print "obj", e.grabbed co2models.remove(e.grabbed) print "targets: ", moleculeManager.getTargets() print "sensors: ", moleculeManager.getSensors() moleculeManager.onExit(overOceanSensor, ExitProximity)
def DisplayLocalMessage(self, mes, toolComp=None): try: #deactivate the previously enabled timer self._localTimer.setEnabled(False) except: pass if mes == None: #no feedback defined for this action if toolComp[0] == 'hand': mes = self.tooltips['hand_use'] % self.tooltips[toolComp[1]] else: mes = self.tooltips['tool_use'] % (self.tooltips[toolComp[0]], self.tooltips[toolComp[1]]) elif len(mes.split(' ')) == 1: #if only one word is passed mes = self.tooltips[mes] mes = '\n'.join(textwrap.wrap(mes, 18)) self._message.message(mes) self._localTimer = vizact.ontimer2(10, 1, self.DismissMessage)
def CreateInfoPanels (self): #add the alert messages panel self._alertPanel = vizinfo.InfoPanel('Factory Alerts', window=self._window, align=viz.ALIGN_LEFT_BOTTOM) self._alertPanel.getPanel().fontSize(14) self._alertPanel.getPanel().setCellPadding(5) self._alertPanel.getPanel().setMargin(1) self._alertIcons = {'a': viz.add('textures/alert_icon.png'), 'w': viz.add('textures/danger_icon.png')} self._alertPanel.setIconTexture(self._alertIcons['a']) self._alertThemes = {'a': viz.getTheme(), 'w': viz.getTheme()} self._alertThemes['a'].borderColor = (.5,0.5,0,1) self._alertThemes['w'].borderColor = (.5,0,0,1) self._alertPanel.setPanelVisible(0) #add the info messages panel self._infoPanel = vizinfo.InfoPanel(self.tooltips['welcome'], window=self._window, align=viz.ALIGN_LEFT_TOP) self._infoPanel.getPanel().fontSize(14) self._infoPanel.getPanel().setCellPadding(5) self._infoPanel.getPanel().setMargin(1) self._infoPanel.setIconTexture(viz.add('textures/info_icon.png')) self._infoTheme = viz.getTheme() self._infoTheme.borderColor = (0,0,.5,1) self._infoPanel.getPanel().setTheme(self._infoTheme) self._infoTimer = vizact.ontimer2(10, 1, self.ShowInfoPanel, False)
import viz import vizact #Enable full screen anti-aliasing (FSAA) to smooth edges viz.setMultiSample(4) viz.go() #Increase the Field of View viz.MainWindow.fov(60) viz.move([0, 0, -8]) piazza = viz.addChild('piazza.osgb') plants = [] for x in [-3, -1, 1, 3]: for z in [4, 2, 0, -2, -4]: plant = viz.addChild('plant.osgb', cache=viz.CACHE_CLONE) plant.setPosition([x, 0, z]) plants.append(plant) spin = vizact.spin(0, 1, 0, 15) spinPlant = lambda plant: plant.addAction(spin) vizact.ontimer2(0.5, 19, spinPlant, vizact.choice(plants))
def end_block(correct,ntrials): block_text.message("SCORE: %i/%i"%(correct,ntrials)) vizact.ontimer2(rate=MESSAGE_TIME, repeats=0,func=clear_text)
def UpdateViz(root, q, savestring, q3): # timeold = time.time() while not endflag.isSet(): global cursorR global cursorL global HistBallR global histzR global HistBallL global histzL global boxL global boxR global targettol global targetR global targetL global steplengthL global steplengthR global psudoR global psudoL global RCOUNT global LCOUNT global Rtop global Rhsp global Ltop global Lhsp global catchflag global stridecounter global Rgorb global Lgorb global R global R2 global RHS global LHS global RTO global LTO global Rlist global Llist global scaling global cpps #get some data root = q.get() data = ParseRoot(root) FN = int(data["FN"]) Rz = float(data["Rz"]) Lz = float(data["Lz"]) try: RHIPY = float(data["RGT"][1]) / 1000 LHIPY = float(data["LGT"][1]) / 1000 except: RHIPY = float(data["RHIP"][1]) / 1000 LHIPY = float(data["LHIP"][1]) / 1000 RANKY = float(data["RANK"][1]) / 1000 LANKY = float(data["LANK"][1]) / 1000 cursorR.setScale(0.1, ((abs(RHIPY + LHIPY) / 2) - RANKY), 0.01250) #alpha cursorL.setScale(-0.1, ((abs(RHIPY + LHIPY) / 2) - LANKY), 0.01250) #determine if we need to hide the cursor if ((abs(RHIPY + LHIPY) / 2) - RANKY < 0) | (Rz < -30): cursorR.visible(0) else: cursorR.visible(1) if ((abs(RHIPY + LHIPY) / 2) - LANKY < 0) | (Lz < -30): cursorL.visible(0) else: cursorL.visible(1) if (catchflag == 0) | (stridecounter > 12): if (Rz <= -30) & (histzR > -30): #RHS condition HistBallR.setPosition( [0.2, ((abs(RHIPY + LHIPY) / 2) - RANKY), 0]) #update yellow history ball when HS happens steplengthR = (abs(RHIPY + LHIPY) / 2) - RANKY stridecounter = stridecounter + 1 #this line of code will not appear in Left foot section, as we want 12 strides after catch for each side Rhsp = (abs(RHIPY + LHIPY) / 2) - RANKY psudoR = psudoR + 1 RHS = 1 RTO = 0 #if successful step was taken, keep track of it if (abs(steplengthR - targetR) <= targettol): RCOUNT = RCOUNT + 1 rightcounter.message(str(RCOUNT)) Rgorb = 1 #flag this step as good or bad # boxR.color( viz.WHITE ) boxR.visible(0) HistBallR.visible(0) if (abs(steplengthR - targetR) < (targettol / 3)): fire1.visible(1) rxplode.visible(1) rxplode.setAnimationTime(0.1) rxplode.setAnimationState(0) vizact.ontimer2(0.6, 0, hide1, 0) else: Rgorb = 0 boxR.color(1, 0.2, 0) # boxR.color( viz.BLUE ) elif (Rz >= -30) & (histzR < -30): #RTO #calculate Toe-Off position Rtop = (abs(RHIPY + LHIPY) / 2) - RANKY RHS = 0 RTO = 1 if (psudoR >= 5): #if it's time to update target value # targetR = 0.5*(abs(Rtop)+abs(Rhsp)) targetR = abs(Rhsp) + (1 / (1 + R)) * (abs(Rtop) - (R * Rhsp)) Rlist.append(targetR) Rlist.pop(0) print('targetR') print(targetR) psudoR = 1 boxR.setPosition([0.2, targetR, 0]) else: RHS = 0 RTO = 0 if (Lz <= -30) & (histzL > -30): #LHS condition HistBallL.setPosition( [-0.2, ((abs(RHIPY + LHIPY) / 2) - LANKY), 0]) #update yellow history ball when HS happens steplengthL = (abs(RHIPY + LHIPY) / 2) - LANKY stridecounter = stridecounter + 1 #this line of code will not appear in Left foot section, as we want 12 strides after catch for each side Lhsp = (abs(RHIPY + LHIPY) / 2) - LANKY psudoL = psudoL + 1 LHS = 1 LTO = 0 #if successful step was taken, keep track of it if (abs(steplengthL - targetL) <= targettol): LCOUNT = LCOUNT + 1 leftcounter.message(str(LCOUNT)) Lgorb = 1 #flag this step as good or bad # boxL.color( viz.WHITE ) boxL.visible(0) HistBallL.visible(0) if (abs(steplengthL - targetL) < (targettol / 3)): fire2.visible(1) lxplode.visible(1) lxplode.setAnimationTime(0.1) lxplode.setAnimationState(0) vizact.ontimer2(0.6, 0, hide2, 0) else: boxL.color(1, 0.2, 0) Lgorb = 0 elif (Lz >= -30) & (histzL < -30): #LTO #calculate Toe-Off position Ltop = (abs(RHIPY + LHIPY) / 2) - LANKY LHS = 0 LTO = 1 if (psudoL >= 5): #if it's time to update target value # targetR = 0.5*(abs(Rtop)+abs(Rhsp)) targetL = abs(Lhsp) + (1 / (1 + R2)) * (abs(Ltop) - (R2 * Lhsp)) Llist.append(targetL) Llist.pop(0) print('targetL') print(targetL) psudoL = 1 boxL.setPosition([-0.2, targetL, 0]) else: LHS = 0 LTO = 0 elif (catchflag == 1) & (stridecounter <= 12): if (Rz <= -30) & (histzR > -30): #RHS condition HistBallR.setPosition([ 0.2, -1 * ((abs(RHIPY + LHIPY) / 2) - RANKY) * scaling, 0 ]) #update yellow history ball when HS happens steplengthR = (abs(RHIPY + LHIPY) / 2) - RANKY stridecounter = stridecounter + 1 #this line of code will not appear in Left foot section, as we want 12 strides after catch for each side Rhsp = (abs(RHIPY + LHIPY) / 2) - RANKY psudoR = psudoR + 1 RHS = 1 RTO = 0 #if successful step was taken, keep track of it if (abs(steplengthR - targetR) <= targettol): RCOUNT = RCOUNT + 1 rightcounter.message(str(RCOUNT)) Rgorb = 1 #flag this step as good or bad boxR.visible(0) HistBallR.visible(0) if (abs(steplengthR - targetR) < (targettol / 3)): fire1.visible(1) rxplode.visible(1) rxplode.setAnimationTime(0.1) rxplode.setAnimationState(0) vizact.ontimer2(0.6, 0, hide1, 0) else: Rgorb = 0 boxR.color(1, 0.2, 0) # boxR.color( viz.BLUE ) elif (Rz >= -30) & (histzR < -30): #RTO #calculate Toe-Off position Rtop = (abs(RHIPY + LHIPY) / 2) - RANKY RHS = 0 RTO = 1 if (psudoR >= 5): #if it's time to update target value # targetR = 0.5*(abs(Rtop)+abs(Rhsp)) # targetR = abs(Rhsp)+(1/(1+R))*(abs(Rtop)-(R*abs(Rhsp))) Rlist.append(targetR) Rlist.pop(0) print('targetR') print(targetR) psudoR = 1 boxR.setPosition([ 0.2, targetR, 0 ]) #targetR doesn't change immediately with catchflag on else: RHS = 0 RTO = 0 if (Lz <= -30) & (histzL > -30): #LHS condition HistBallL.setPosition( [-0.2, ((abs(RHIPY + LHIPY) / 2) - LANKY), 0]) #update yellow history ball when HS happens steplengthL = (abs(RHIPY + LHIPY) / 2) - LANKY stridecounter = stridecounter + 1 #this line of code will not appear in Left foot section, as we want 12 strides after catch for each side Lhsp = (abs(RHIPY + LHIPY) / 2) - LANKY psudoL = psudoL + 1 LHS = 1 LTO = 0 #if successful step was taken, keep track of it if (abs(steplengthL - targetL) <= targettol): LCOUNT = LCOUNT + 1 leftcounter.message(str(LCOUNT)) Lgorb = 1 #flag this step as good or bad boxL.visible(0) HistBallL.visible(0) if (abs(steplengthL - targetL) < (targettol / 3)): fire2.visible(1) lxplode.visible(1) lxplode.setAnimationTime(0.1) lxplode.setAnimationState(0) vizact.ontimer2(0.6, 0, hide2, 0) else: Lgorb = 0 boxL.color(1, 0.2, 0) # boxL.color( viz.BLUE ) elif (Lz >= -30) & (histzL < -30): #LTO #calculate Toe-Off position (X) # Ltop = LHIPY-LANKY Ltop = (abs(RHIPY + LHIPY) / 2) - LANKY LHS = 0 LTO = 1 if (psudoL >= 5): #if it's time to update target value # targetR = 0.5*(abs(Rtop)+abs(Rhsp)) # targetL = abs(Lhsp)+(1/(1+R2))*(abs(Ltop)-(R2*abs(Lhsp))) Llist.append(targetL) Llist.pop(0) print('targetL') print(targetL) psudoL = 1 boxL.setPosition([-0.2, targetL, 0]) else: LHS = 0 LTO = 0 histzR = Rz histzL = Lz savestring = [ FN, Rz, Lz, RHS, LHS, RTO, LTO, Rgorb, Lgorb, (abs(RHIPY + LHIPY) / 2) - RANKY, (abs(RHIPY + LHIPY) / 2) - LANKY, targetR, targetL, (abs(RHIPY + LHIPY) / 2), RANKY, LANKY ] #organize the data to be written to file q3.put(savestring) # q3.join() cpps.kill() print('R targets: ', Rlist) print('L targets: ', Llist) print('Mean R targets: ', sum(Rlist) / len(Rlist)) print('Mean L targets: ', sum(Llist) / len(Llist)) print("All data has been processed")
def success_display(rt): #block_text.message("Success") #vizact.ontimer2(rate=MESSAGE_TIME, repeats=0,func=clear_text) correct_sound.play() block_text.message("GOOD %.2fs"%rt) vizact.ontimer2(rate=MESSAGE_TIME, repeats=0,func=clear_text)
def fail_display(failtype,rt): #block_text.message("Failure") #vizact.ontimer2(rate=MESSAGE_TIME, repeats=0,func=clear_text) incorrect_sound.play() block_text.message(failtype + " %.2fs"%rt) vizact.ontimer2(rate=MESSAGE_TIME, repeats=0,func=clear_text)
def UpdateViz(root, q, savestring, q3): # timeold = time.time() while not endflag.isSet(): global rsci global lsci global R global R2 global histzR global histzL global Rhsp global Lhsp global Rtop global Ltop global RCOUNT global LCOUNT global catchflag global Rgorb global Lgorb global stridecounter global psudoL global psudoR global RHS global LHS global Rlist global Llist global fakeTargetR global fakeTargetL global distheta global widetheta global distRZ global wideRX global distLZ global wideLX global RTO global LTO global xR global xL global n global cpps #get some data root = q.get() data = ParseRoot(root) FN = int(data["FN"]) Rz = float(data["Rz"]) Lz = float(data["Lz"]) try: RHIPY = float(data["RGT"][1]) / 1000 LHIPY = float(data["LGT"][1]) / 1000 except: RHIPY = float(data["RHIP"][1]) / 1000 LHIPY = float(data["LHIP"][1]) / 1000 RANKY = float(data["RANK"][1]) / 1000 LANKY = float(data["LANK"][1]) / 1000 #determine if we need to hide the cursor if ((abs(RHIPY + LHIPY) / 2) - RANKY < 0) | (Rz < -30): cursorR.visible(0) else: cursorR.visible(1) if ((abs(RHIPY + LHIPY) / 2) - LANKY < 0) | (Lz < -30): cursorL.visible(0) else: cursorL.visible(1) cursorR.setScale(0.1, rsci * ((abs(RHIPY + LHIPY) / 2) - RANKY), -0.001) cursorL.setScale(-0.1, lsci * ((abs(RHIPY + LHIPY) / 2) - LANKY), -0.001) if (catchflag == 0) | (stridecounter > 8): # (stridecounter > 8): #detect gait events if (Rz <= -30) & (histzR > -30): #RHS HistBallR.setPosition([ wideRX, rsci * ((abs(RHIPY + LHIPY) / 2) - RANKY) - 0.25, distRZ - 1.001 ]) HistBallR.setScale(wideRX, rsci * 0.01, 0.001) stridecounter = stridecounter + 1 RHS = 1 RTO = 0 Rhsp = (abs(RHIPY + LHIPY) / 2) - RANKY #update the alpha value xL = (abs(RHIPY + LHIPY) / 2) - LANKY #position of left leg at RHS # print("Right error is: ",abs(RHIPY-RANKY)-fakeTargetR) if (abs((abs(RHIPY + LHIPY) / 2) - RANKY - fakeTargetR) <= targetto2): RCOUNT = RCOUNT + 1 rightcounter.message(str(RCOUNT)) # boxR2.color( viz.WHITE ) boxR.visible(0) boxR2.visible(0) HistBallR.visible(0) Rgorb = 1 #flag this step as good or bad if (abs((abs(RHIPY + LHIPY) / 2) - RANKY - fakeTargetR) <= targettol): # boxR.color( viz.WHITE ) fire1.visible(1) rxplode.visible(1) rxplode.setAnimationTime(0.1) rxplode.setAnimationState(0) vizact.ontimer2(0.6, 0, hide1, 0) else: boxR.color(1, 0.2, 0) # boxR2.color(1,0.2,0) Rgorb = 0 elif (Rz >= -30) & (histzR < -30): #RTO #calculate Toe-Off position RTO = 1 Rtop = (abs(RHIPY + LHIPY) / 2) - RANKY #update beta value if (psudoR == 5): rsci = 0.25 * (1 / (Rhsp + ( (n / (1 + R)) * (abs(xR) - R * Rhsp)))) #find new scale factor fakeTargetR = Rhsp + (n / (1 + R)) * ( abs(xR) - R * Rhsp) #find the theoretical target # print('fakeTargetR is:') # print(fakeTargetR) Rlist.append(rsci) #add the scale to the end of the list Rlist.pop(0) #remove the oldest one distRZ = rsci * 2 * targettol / (2 * math.tan(distheta / 2)) # print("distRZ is: ",distRZ) # print("wideRX is: ",wideRX) wideRX = 2 * (distRZ) * math.tan(widetheta / 2) #change target sizes and such boxR.setPosition(wideRX, 0, distRZ - 1) boxR.setScale(wideRX, 2 * rsci * targettol, 0) boxR2.setPosition(wideRX, 0, distRZ - 1) boxR2.setScale(wideRX, 2 * rsci * targetto2, 0) # HistBallR.setPosition([wideRX,rsci*Rhsp-0.25,distRZ-1.001]) psudoR = 1 psudoR = psudoR + 1 RHS = 0 else: RHS = 0 RTO = 0 if (Lz <= -30) & (histzL > -30): #LHS HistBallL.setPosition([ -wideLX, lsci * ((abs(RHIPY + LHIPY) / 2) - LANKY) - 0.25, distLZ - 1.001 ]) HistBallL.setScale(wideLX, lsci * 0.01, 0.001) stridecounter = stridecounter + 1 LHS = 1 LTO = 0 Lhsp = (abs(RHIPY + LHIPY) / 2) - LANKY #update the alpha value xR = (abs(RHIPY + LHIPY) / 2) - RANKY #position of right leg at SHS if (abs((abs(RHIPY + LHIPY) / 2) - LANKY - fakeTargetL) <= targetto2): LCOUNT = LCOUNT + 1 leftcounter.message(str(LCOUNT)) # boxL2.color( viz.WHITE ) boxL.visible(0) boxL2.visible(0) Lgorb = 1 #flag this step as good or bad if (abs((abs(RHIPY + LHIPY) / 2) - LANKY - fakeTargetL) <= targettol): fire2.visible(1) lxplode.visible(1) lxplode.setAnimationTime(0.1) lxplode.setAnimationState(0) vizact.ontimer2(0.6, 0, hide2, 0) else: boxL.color(1, 0.2, 0) # boxL2.color(0.2,0.8,1) Lgorb = 0 elif (Lz >= -30) & (histzL < -30): #RTO #calculate Toe-Off position Ltop = (abs(RHIPY + LHIPY) / 2) - LANKY #update beta value LTO = 1 LHS = 0 if (psudoL == 5): lsci = 0.25 * (1 / (Lhsp + ( (n / (1 + R2)) * (abs(xL) - R2 * Lhsp)))) #find new scale factor fakeTargetL = Lhsp + (n / (1 + R2)) * ( abs(xL) - R2 * Lhsp) #find the theoretical target # print('fakeTargetL is:') # print(fakeTargetL) Llist.append(lsci) #add the scale to the end of the list Llist.pop(0) #remove the oldest one distLZ = lsci * 2 * targettol / (2 * math.tan(distheta / 2)) wideLX = 2 * (distLZ) * math.tan(widetheta / 2) #change target sizes and such boxL.setPosition(-wideLX, 0, distLZ - 1) boxL.setScale(wideLX, 2 * lsci * targettol, 0) boxL2.setPosition(-wideLX, 0, distLZ - 1) boxL2.setScale(wideLX, 2 * lsci * targetto2, 0) # HistBallL.setPosition([-wideLX,lsci*Lhsp-0.25,distLZ-1.001]) psudoL = 1 psudoL = psudoL + 1 else: LHS = 0 LTO = 0 elif (catchflag == 1) & (stridecounter <= 8): HistBallL.visible(0) HistBallR.visible(0) cursorL.visible(0) cursorR.visible(0) boxL.visible(0) boxL2.visible(0) boxR.visible(0) boxR2.visible(0) # #detect gait events if (Rz <= -30) & (histzR > -30): #RHS #HistBallR.setPosition([wideRX,rsci*(RHIPY-RANKY)-0.25,distRZ-1.001]) #HistBallR.setScale(wideRX,rsci*0.01,0.001) stridecounter = stridecounter + 1 RHS = 1 RTO = 0 Rhsp = (abs(RHIPY + LHIPY) / 2) - RANKY #update the alpha value xL = (abs(RHIPY + LHIPY) / 2) - LANKY # print("Right error is: ",abs(RHIPY-RANKY)-fakeTargetR) if (abs((abs(RHIPY + LHIPY) / 2) - RANKY - fakeTargetR) <= targetto2): RCOUNT = RCOUNT + 1 # boxR2.color( viz.WHITE ) Rgorb = 1 #flag this step as good or bad # if (abs(RHIPY-RANKY-fakeTargetR) <= targettol): # boxR.color( viz.WHITE ) # else: # boxR.color( 0,0,1 ) else: # boxR.color(0,0,1) # boxR2.color(0.2,0.8,1) Rgorb = 0 elif (Rz >= -30) & (histzR < -30): #RTO #calculate Toe-Off position Rtop = (abs(RHIPY + LHIPY) / 2) - RANKY #update beta value RTO = 1 if (psudoR == 5): rsci = 0.25 * (1 / (Rhsp + ( (n / (1 + R)) * (abs(xR) - R * Rhsp)))) #find new scale factor fakeTargetR = abs(Rhsp) + (n / (1 + R)) * ( abs(xR) - (R * Rhsp)) #find the theoretical target # print('fakeTargetR is:') # print(fakeTargetR) Rlist.append(rsci) #add the scale to the end of the list Rlist.pop(0) #remove the oldest one distRZ = rsci * 2 * targettol / (2 * math.tan(distheta / 2)) # print("distRZ is: ",distRZ) # print("wideRX is: ",wideRX) wideRX = 2 * (distRZ) * math.tan(widetheta / 2) #change target sizes and such # boxR.setPosition(wideRX,0,distRZ-1) # boxR.setScale(wideRX,2*rsci*targettol,0) psudoR = 1 psudoR = psudoR + 1 RHS = 0 else: RHS = 0 RTO = 0 if (Lz <= -30) & (histzL > -30): #LHS #HistBallL.setPosition([-wideLX,lsci*(LHIPY-LANKY)-0.25,distLZ-1.001]) #HistBallL.setScale(wideLX,lsci*0.01,0.001) stridecounter = stridecounter + 1 LHS = 1 LTO = 0 Lhsp = (abs(RHIPY + LHIPY) / 2) - LANKY #update the alpha value xR = (abs(RHIPY + LHIPY) / 2) - RANKY if (abs((abs(RHIPY + LHIPY) / 2) - LANKY - fakeTargetL) <= targetto2): LCOUNT = LCOUNT + 1 # boxL2.color( viz.WHITE ) Lgorb = 1 #flag this step as good or bad # if (abs(LHIPY-LANKY-fakeTargetL) <= targettol): # boxL.color( viz.WHITE ) # else: # boxL.color( 0,0,1 ) else: # boxL.color(0,0,1) # boxL2.color(0.2,0.8,1) Lgorb = 0 elif (Lz >= -30) & (histzL < -30): #RTO #calculate Toe-Off position Ltop = (abs(RHIPY + LHIPY) / 2) - LANKY #update beta value LTO = 1 if (psudoL == 5): lsci = 0.25 * (1 / (Lhsp + ( (n / (1 + R2)) * (abs(xL) - R2 * Lhsp)))) #find new scale factor fakeTargetL = abs(Lhsp) + (n / (1 + R2)) * ( abs(xL) - (R2 * Lhsp)) #find the theoretical target # print('fakeTargetL is:') # print(fakeTargetL) Llist.append(lsci) #add the scale to the end of the list Llist.pop(0) #remove the oldest one distLZ = lsci * 2 * targettol / (2 * math.tan(distheta / 2)) wideLX = 2 * (distLZ) * math.tan(widetheta / 2) #change target sizes and such # boxL.setPosition(-wideLX,0,distLZ-1) # boxL.setScale(wideLX,2*lsci*targettol,0) psudoL = 1 psudoL = psudoL + 1 LHS = 0 else: LHS = 0 LTO = 0 histzR = Rz histzL = Lz savestring = [ FN, Rz, Lz, RHS, LHS, RTO, LTO, Rgorb, Lgorb, (abs(RHIPY + LHIPY) / 2) - RANKY, (abs(RHIPY - LHIPY) / 2) - LANKY, rsci, lsci, (abs(RHIPY + LHIPY) / 2), RANKY, LANKY, fakeTargetR, fakeTargetL, xL, xR, ((abs(RHIPY + LHIPY) / 2) - RANKY) - xL, ((abs(RHIPY + LHIPY) / 2) - LANKY) - xR ] #organize the data to be written to file # print(sys.getsizeof(savestring)) q3.put(savestring) # q3.join() cpps.kill() print("R scales: ", Rlist) print("L scales: ", Llist) print("Mean R scales: ", sum(Rlist) / len(Rlist)) print("Mean L scales: ", sum(Llist) / len(Llist)) print("All data has been processed")
# time.sleep(10) # delay [sec] # perturbations variables stp = 80 # 80steps initial instead of random.randint(step_range[0], step_range[1]) Lstp_flag = 0 # identify swing phase Rstp_flag = 0 stp_counter = 0 belt = belt_vec[0] # initialization ptb_max = len(belt_vec) # max number of perturbations ptb = 1 # current perturbation # out = serializepacket(speed_S[0],speed_S[1],200,200,0) # s.sendall(out) vizact.ontimer2(0, viz.FOREVER, AnkleTracking, flagL, flagR, LeftAnkle, RightAnkle, LeftGTO, RightGTO, ankleHeightL, ankleHeightR, successL_count, successR_count) vizact.ontimer2(0, viz.FOREVER, acquireVelocity) ###################################################################################################################### # # ? IMPROVEMENTS ? # # Use bars/lines instead of the black dots for feedback # Create a countdown screen before treadmill starts/stops # Change the success to percentage # Add a success condition to apply perturbations, if success<threshold no perturbation # Better integrate "check_steps" and "StepLength" functions (steps counter, "check_steps" as interruption) # ######################################################################################################################
# time.sleep(10) # delay [sec] # perturbations variables stp = 10 # 80steps initial instead of random.randint(step_range[0], step_range[1]) Lstp_flag = 0 # identify swing phase Rstp_flag = 0 stp_counter = 0 belt = belt_vec[0] # initialization ptb_max = len(belt_vec) # max number of perturbations ptb = 1 # current perturbation out = serializepacket(speed_S[0],speed_S[1],200,200,0) s.sendall(out) vizact.ontimer2(0,viz.FOREVER,StepLength,COP_L,COP_R,width=0.05,length=0.05) vizact.ontimer2(0,viz.FOREVER,check_steps) vizact.ontimer2(0,viz.FOREVER,acquireVelocity) ###################################################################################################################### # # ? IMPROVEMENTS ? # # Use bars/lines instead of the black dots for feedback # Create a countdown screen before treadmill starts/stops # Change the success to percentage # Add a success condition to apply perturbations, if success<threshold no perturbation # Better integrate "check_steps" and "StepLength" functions (steps counter, "check_steps" as interruption) #
if qualisysOn: # Initial condition updateViewHQ() # time.sleep(10) out = serializepacket(speed_S[0], speed_S[1], 100, 100, 0) s.sendall(out) # time.sleep(2) # delay [sec] repeats = 20000 vizact.ontimer2( 0, repeats, StepLength, filename, stepLengthLeft, stepLengthRight, COP_L, COP_R, width=0.05, length=0.05, ) ###################################################################################################################### # # IMPROVEMENTS ? # # Possibly control QTM acquisition with the lab jack # Make it stop the treadmill when it's over (use time variable instead of "repeats") # Optimize file output # ######################################################################################################################
markerList = qualisys.getMarkerList() print markerList return qualisys temp = raw_input('Initiate Quialisys?<y/n>') if temp == 'y': qualisys = qualisysInit() qualisysOn = True if qualisysOn: # Initial condition updateViewHQ() # time.sleep(10) # out = serializepacket(speed_S[0],speed_S[1],100,100,0) # s.sendall(out) # time.sleep(2) # delay [sec] repeats = 20000 vizact.ontimer2(0, repeats, updateViewHQ) vizact.ontimer2(0, repeats, StepLength, flagL, flagR, stepLengthLeft, stepLengthRight, L=LeftAnkle, R=RightAnkle, width=0.05, length=0.05)