def checkStats(): stats = viz.getRenderStats() if stats.frameTime > 0.012: print viz.tick() print stats # vizact.onupdate(viz.PRIORITY_DEFAULT, checkStats)
def __trackResponse(self): readStart = 0 while True: if self.going: resp = self.T1.readAllResponse() for r in resp: sm = r.find('sm') if sm is not None and sm.text == FLMOCommands.ServerMessages.ActualValue: try: q = self.T1.MotorResponses[r.find('id').text] q.time = viz.tick() q.value = self.T1.device_to_si * float( r.find('v').text) self.readTime = viz.tick() - readStart readStart = viz.tick() viz.sendEvent(TREADMILL_STATE_UPDATED) except (ValueError): print "Warning (VTreadmill: could not parse value from" print " ", treadmill.ET.tostring(r) print "continuing" except (KeyError): print "Warning (VTreadmill: could not locate id from" print " ", treadmill.ET.tostring(r) print " id was: ", r.find('id').text print " available ids are:" for k, v in self.T1.MotorResponses.iteritems(): print " ", k print "continuing" elif sm is not None and sm.text == FLMOCommands.ServerMessages.ErrorMessage: viz.logWarn( "Warning (VTreadmill): Treadmill returned an error:\n ", treadmill.ET.tostring(r), "\n ", r.find('string').text) yield None
def PlaySound(self, audioindex): t = viz.tick() myaudio = self.AudioFiles[audioindex] viz.playSound(myaudio) print("PLAY SOUND: ", viz.tick() - t)
def run(self): exp = self.block.experiment lf = exp.left_finger rf = exp.right_finger # wait for the subject to touch the target sphere. yield self.block.experiment.wait_for_target() # target touched, now figure out which hand is doing the tracing. left_is_closer = distance(lf, exp.target) < distance(rf, exp.target) finger = lf if left_is_closer else rf self.trace_color = (1, 0, 0) if left_is_closer else (0, 1, 0) self.trace_name = 'left' if left_is_closer else 'right' # animate the target along the path, recording mocap data as we go. start = viz.tick() for i, v in enumerate(self.vertices): # ramp up the speed linearly from 0. s = min(1, 0.1 * (i+1)) * self.speed yield viztask.addAction(exp.target, vizact.moveTo(v, speed=s)) # keep track of the position of the tracing finger. finger_position = finger.getPosition() self.trace.append(finger_position) # record values from the simulation and from the mocap. fields = [i, viz.tick() - start] fields.extend(exp.target.getPosition()) fields.extend(finger_position) fields.extend(exp.head.get_pose().pos) for _, marker in sorted(exp.mocap.get_markers().iteritems()): fields.extend(marker.pos) fields.append(marker.cond) self.records.append(fields)
def timer3(): viz.playSound('boing!.wav') global reaction_timer_initial a=viz.tick() print('in timer!') global timer2 reaction_timer_initial=viz.tick()
def DetectAudioResponse(self): """Function determines whether there has been an appropriate response""" print("DetectAudioResponse called") print("currentaudio_type", self.currentaudio_type) t = viz.tick() if self.currentaudio_type == 'T': #should have responded. target_index = self.Trial_targets.index( self.currentaudio ) #retrieve index of target within current trial self.Trial_targetcounts[ target_index] += 1 #increment target count. if self.ppresp == 1: RT = self.ResponseStamp - self.Stimuli_PlayedStamp ResponseCategory = 1 #correctly responded. elif self.ppresp == 0: RT = -1 ResponseCategory = 2 #did not respond when should have. elif self.currentaudio_type == 'D': #should NOT have responded. if self.ppresp == 1: RT = self.ResponseStamp - self.Stimuli_PlayedStamp ResponseCategory = '3' #responded when shouldn't have. elif self.ppresp == 0: RT = -1 ResponseCategory = '4' #correct absence of response #the row size will change depending on target number. trialinfo = [ self.ppid, self.Trial_targetoccurence_prob, self.Trial_targetnumber, self.Trial_N ] currentresponse = [ viz.tick(), self.delay, self.currentaudio_type, self.currentaudio, RT, ResponseCategory ] Trial_targets_outputlist = list(self.Trial_targets) while len(Trial_targets_outputlist) < self.MaxTargetNumber: Trial_targets_outputlist.append(None) output = list(trialinfo) + list( currentresponse) + Trial_targets_outputlist # self.WithinTrial_Data.loc[self.Overall_Stimuli_Index-1,:] = output #this is takes about 3ms. Consider changing to csv writer. output = tuple(output) self.WithinTrial_Data_writer.writerow( output) #write row to output stream. #https://stackoverflow.com/questions/41888080/python-efficient-way-to-add-rows-to-dataframe print("DetectResposne: ", viz.tick() - t) self.SetNewStimuli()
def __update(self): msg = viz.addText("", parent=viz.SCREEN) t0 = 0 #for testing self.device.softReset() yield viztask.waitTime(1) print "Zeroing treadmill ... ", self.doZero() print "done" print "Started treadmill forceplates read" while self.going: results = self.device.getFeedback( self.feedbackArguments ) for j in range(self.numChannels): self.latestAinValues[j] = self.device.binaryToCalibratedAnalogVoltage(self.gainIndex, results[2+j]) self.lastForceMoments = list(self.latestForceMoments) self.latestForceMoments = self.M.dot(self.latestAinValues+self.zero) self.lastLeftOn = self.latestLeftOn self.lastRightOn = self.latestRightOn self.lastLeftCOP = list(self.latestLeftCOP) self.lastRightCOP = list(self.latestRightCOP) self.lastTime = self.latestTime self.latestTime = viz.tick() try: self.latestLeftOn = (self.latestForceMoments[2] < MIN_WEIGHT_NEWTONS) self.latestLeftCOP[0] = -1.0*self.latestForceMoments[4]/self.latestForceMoments[2] self.latestLeftCOP[1] = self.latestForceMoments[3]/self.latestForceMoments[2] self.latestRightOn = (self.latestForceMoments[8] < MIN_WEIGHT_NEWTONS) self.latestRightCOP[0] = -1.0*self.latestForceMoments[10]/self.latestForceMoments[8] self.latestRightCOP[1] = self.latestForceMoments[9]/self.latestForceMoments[8] except(ZeroDivisionError): print "div zero caught in ForcePlate ... ignoring" pass if self.recording: #self.data.append([viz.tick(), [x for x in self.latestAinValues]]) self.data.append([viz.tick(), [x for x in self.latestForceMoments]]) if self.lastLeftOn and not self.latestLeftOn: viz.sendEvent(LEFT_OFF_TREADMILL) if not self.lastLeftOn and self.latestLeftOn: viz.sendEvent(LEFT_ON_TREADMILL) if self.lastRightOn and not self.latestRightOn: viz.sendEvent(RIGHT_OFF_TREADMILL) if not self.lastRightOn and self.latestRightOn: viz.sendEvent(RIGHT_ON_TREADMILL) #testing t1 = t0 t0 = viz.tick() #msg.message("%3.3fs"%(t0-t1)) #msg.message("%6.3f %6.3f"%(self.latestLeftCOP[0], self.latestLeftCOP[1])) #if self.lastLeftOn: # msg.message("Left on") #elif self.lastRightOn: # msg.message("Right on") yield None
def draw_maze_task(self): # remove collide events viz.phys.disable() # position frame in front of subject after reorienting pos = self.subject.head_sphere.getPosition() self.scene.drawing_frame.setPosition( [pos[0] - .2, pos[1] - .5, pos[2] + .6]) self.scene.drawing_frame.visible(viz.ON) self.scene.change_instruction( "Bitte zeichnen Sie den Raum in den Rahmen ein.\nStart mit Klick.") print '!!! DRAWING TASK, TRIGGER TO START !!!' yield self.hide_inst_continue_trigger() print '!!! DRAWING STARTED, MOUSECLICK TO SAVE !!!' # enable drawing functionality self.subject.right_hand_sphere.alpha(1) self.subject.right_hand_sphere.setScale(2, 2, 2) self.subject.right_hand_sphere.color(viz.WHITE) draw_link = viz.link(self.subject.right_hand_sphere, self.scene.draw_tool) # drawing update function called every frame and handling states of input device self.scene.draw_tool.setUpdateFunction(self.draw) # send drawing task start marker self.log_exp_progress('type:drawing_start;') start = viz.tick() # wait until drawing is saved and continue with the experiment yield self.hide_inst_continue_left_mouse() print '!!! DRAWING SAVED !!!' # send drawing task end marker duration_drawing = viz.tick() - start self.log_exp_progress('type:drawing_end;duration_drawing:' + str(round(duration_drawing, 2)) + ';') # save screenshot of drawing filename = 'subject_' + str(self.subject_id) + '_sketchmap_' + str( self.current_maze) viz.window.screenCapture(filename + '.bmp') yield viztask.waitTime(0.5) # remove drawing and draw_tool self.scene.drawing_frame.visible(viz.OFF) draw_link.remove() self.scene.draw_tool.clear() self.subject.right_hand_sphere.alpha(0) self.subject.right_hand_sphere.setScale(1, 1, 1)
def keydown(key): if key == 'f': self.response = 'self motion' self.keyPressTime = viz.tick() # get time for keypress print(self.response, self.keyPressTime) self.STATE = 'State - self Motion' if key == 'j': self.response = 'object motion' self.keyPressTime = viz.tick() # get time for keypress print(self.response, self.keyPressTime) self.STATE = 'State - Object Motion'
def pointing(self, trial_start_time): duration_outward = viz.tick() - trial_start_time self.log_exp_progress( 'type:enter_local_landmark;num_local_landmark:' + str(self.local_landmark_hits) + \ ';duration_outward:' + str(round(duration_outward, 2)) + ';') self.scene.change_instruction("Bitte zeigen Sie zum Startpunkt.") self.pointing_task_on = True self.subject.right_hand_sphere.alpha(1) yield self.hide_inst_continue_trigger() self.log_exp_progress('type:pointing;') self.subject.right_hand_sphere.alpha(0) self.start_return = viz.tick() self.pointing_task_on = False
def getTargetAngle(self): gotAngle = 0 # log trial onset self.trialData['trialOnset'] = viz.tick() # show pointing target self.info.showTargetInfo(self.cTrial, self.trialCtr+1, len(self.trials)) while not gotAngle: keyObj = yield viztask.waitKeyDown(keys=None) if keyObj.key == ' ': trgAngle = viz.MainView.getEuler(viz.ABS_GLOBAL) print trgAngle[0] gotAngle = 1 # if keyObj.key == 't': # viz.MainView.lookAt( self.cTrial.getPos('trg', 'center') ) # self.cTrial.showBuilding('trg', 'opaque') # trueAngle = viz.MainView.getEuler(viz.ABS_GLOBAL) # print trueAngle[0] if keyObj.key == 'q': self.cTrial.src.toggleTransp() # hide buildings self.cTrial.hideBuildings() # hide pointing info self.info.resetMsg() # log trial end self.trialData['tChoiceMade'] = viz.tick() # log target angle self.trialData['measAngle'] = trgAngle[0] # measured self.refVert.lookAt( self.cTrial.getPos('trg', 'center') ) trueAngle = self.refVert.getEuler(viz.ABS_GLOBAL) print "refVert: ", trueAngle[0] self.trialData['trueAngle'] = trueAngle[0] # ground truth # DEBUGGING # print self.trialData # log data self.logHdl.logDictData(self.trialData) # start new trial viztask.schedule( self.startNewTrial() )
def update(self): '''Update our knowledge of the current data from phasespace.''' if self._lock.acquire(False): return now = viz.tick() #if now - math.floor(now) < 0.1 / self.frame_rate: # logging.info('%dus elapsed since last phasespace update', # 1000000 * (now - self._updated)) self._updated = now rigids = OWL.owlGetRigids() markers = OWL.owlGetMarkers() err = OWL.owlGetError() if err != OWL.OWL_NO_ERROR: hex = '0x%x' % err logging.debug('OWL error %s (%s) getting marker data', ERROR_MAP.get(err, hex), hex) return getting_at = viz.tick() - now sx, sy, sz = self.scale ox, oy, oz = self.offset def transform(x, y, z): return sz * z + oz, sy * y + oy, sx * x + ox def swizzle(w, a, b, c): return c, b, a, -w for marker in markers: t, o = marker.id >> 12, marker.id & 0xfff x, y, z = marker.x, marker.y, marker.z self.trackers[t].update_markers( o, Marker(pos=transform(x, y, z), cond=marker.cond), Marker(pos=(x, y, z), cond=marker.cond)) marker_at = viz.tick() - now for rigid in rigids: self.trackers[rigid.id].update_pose( Pose(pos=transform(*rigid.pose[0:3]), quat=swizzle(*rigid.pose[3:7]), cond=rigid.cond)) rigid_at = viz.tick() - now #logging.info('phasespace update: %dus -> %dus -> %dus', # 1000000 * getting_at, # 1000000 * marker_at, # 1000000 * rigid_at) self._lock.release()
def update(self): '''Update our knowledge of the current data from phasespace.''' if self._lock.acquire(False): return now = viz.tick() #if now - math.floor(now) < 0.1 / self.frame_rate: # logging.info('%dus elapsed since last phasespace update', # 1000000 * (now - self._updated)) self._updated = now rigids = OWL.owlGetRigids() markers = OWL.owlGetMarkers() err = OWL.owlGetError() if err != OWL.OWL_NO_ERROR: hex = '0x%x' % err logging.debug( 'OWL error %s (%s) getting marker data', ERROR_MAP.get(err, hex), hex) return getting_at = viz.tick() - now sx, sy, sz = self.scale ox, oy, oz = self.offset def transform(x, y, z): return sz * z + oz, sy * y + oy, sx * x + ox def swizzle(w, a, b, c): return c, b, a, -w for marker in markers: t, o = marker.id >> 12, marker.id & 0xfff x, y, z = marker.x, marker.y, marker.z self.trackers[t].update_markers(o, Marker(pos=transform(x, y, z), cond=marker.cond), Marker(pos=(x, y, z), cond=marker.cond)) marker_at = viz.tick() - now for rigid in rigids: self.trackers[rigid.id].update_pose(Pose( pos=transform(*rigid.pose[0:3]), quat=swizzle(*rigid.pose[3:7]), cond=rigid.cond)) rigid_at = viz.tick() - now #logging.info('phasespace update: %dus -> %dus -> %dus', # 1000000 * getting_at, # 1000000 * marker_at, # 1000000 * rigid_at) self._lock.release()
def testPhase(): results = [] if centerSensor not in manager.getActiveSensors(): yield vizproximity.waitEnter(centerSensor) sensor = sphereSensors[0] info.setText("Walk to the sphere now.") startTime = viz.tick() yield vizproximity.waitEnter(sensor) info.setText('Please return to the center of the room') elapsedTime = viz.tick() - startTime results.append((sensor.name, elapsedTime)) info.setText("You're all done now!") viztask.returnValue(results)
def update_thread(self): while self._running: self.update() try: elapsed = viz.tick() - self._updated except: tick = viz.tick() upd = self._updated wait = 1. / 1000 - elapsed if (wait > 0): time.sleep(wait)
def testPhase(): results = [] for i in range(0, 5): # Instruct participant where to go instruction = "Walk around for 5 seconds, see where you end up in this world. You can press 1, 2, or 3".format( sensor.name ) info.setText(instruction) # store the time at which this trial started startTime = viz.tick() position = viz.MainView.getPosition() before = str(subject) + "\t" + str(position) + "\n" # The yielded command returns a viz.Data object with information # about the proximity event such as the sensor, target involved yield vizproximity.wait(5) position = viz.MainView.getPosition() after = str(subject) + "\t" + str(position) + "\n" # save results results.append((before, after)) info.setText("Thank You. You have completed the experiment") # return results viztask.returnValue(results)
def update_thread(self): while self._running: self.update() elapsed = viz.tick() - self._updated wait = 1. / self.frame_rate - elapsed while wait < 0: wait += 1. / self.frame_rate
def __init__(self, server_name, freq=OWL.OWL_MAX_FREQUENCY, scale=(0.001, 0.001, 0.001), offset=(0, 0, 0), postprocess=False, slave=False): super(Phasespace, self).__init__() flags = 0 if postprocess: flags |= OWL.OWL_POSTPROCESS if slave: flags |= OWL.OWL_SLAVE if OWL.owlInit(server_name, flags) < 0: raise OwlError('phasespace') OWL.owlSetFloat(OWL.OWL_FREQUENCY, freq) OWL.owlSetInteger(OWL.OWL_STREAMING, OWL.OWL_ENABLE) logging.info('running phasespace at %.1f Hz', freq) self.scale = scale self.offset = offset self.trackers = [] self.frame_rate = freq self._updated = viz.tick() self._lock = threading.Lock() self._thread = None self._running = False
def runExperimentPathSet(self, pathNum, myTimeline=None): global speedMultiplier # speedMultipler = 1 # for ps in self.pathSets: print pathNum print len(self.pathSets) ps = self.pathSets[pathNum] if myTimeline != None: timeline = myTimeline else: timeline = self.timelines[pathNum] self.peopleset = [] newPs = PathSet() for personPath in ps.peoplePaths: p = people.a_person(speedMultiplier) p.custom_walk(personPath.getFullPath()) self.peopleset.append(p) tophat = people.a_person(speedMultiplier, 1) self.abe = tophat tophat.custom_walk(ps.abePath.getFullPath()) self.peopleset.append(tophat) self.starttime = viz.tick() self.errlist = [] self.timelist = [] # error_timer = vizact.ontimer(0.1/speedMultiplier,self.checkError,tophat,self.errlist) error_timer = vizact.onupdate(-10, self.checkError, tophat) yield self.runPathSet(self.peopleset, newPs, tophat, 1, timeline) vizact.removeEvent(error_timer)
def EnterProximity_end_sensor(end_sensor): start_node.translate(x_translate1,y_height1,z_depth1) right_node1.setPosition(0,100,0) right_node2.setPosition(0,100,0) right_node3.setPosition(0,100,0) sensor_data.write('\nEntered End sensor at:' + str(viz.tick())) print('Entered end_sensor')
def GameFinish (self, delay): self.info = vizinfo.add(self.tooltips['congrats']) self.info.visible(0) self.info.icon(viz.add('textures/c-olive_icon.png')) self.info.add(viz.TEXT3D, self.tooltips['finish']+'\n'+self.tooltips['produce'] % self._oil.getMessage()) self.info.add(viz.TEXT3D, self.tooltips['stats']) self.info.translate(0.1,0.95) self.info.alignment(vizinfo.UPPER_LEFT) self.info.scale(2.4,2.6) self.info.messagecolor(100,100,0) self.info.bgcolor(viz.BLACK, 0.8) self.info.bordercolor([100,100,0], .9) points = self.info.add(viz.TEXQUAD, self.tooltips['score']+': %s' % self._total.getMessage()) points.texture(viz.add('textures/total_icon.png')) time = self.info.add(viz.TEXQUAD, self.tooltips['time']+': %s' % self.ConvertTime(viz.tick())) time.texture(viz.add('textures/time_icon.png')) self.info.shrink() #hide all other panels self._scorePanel.visible(0) self._infoPanel.visible(0) self._alertPanel.visible(0) for p in self.PLAYERS.values(): p._infoPanel.visible(0) p._alertPanel.visible(0) p._hud.visible(0) time.addAction(vizact.waittime(delay)) time.addAction(vizact.call(self.info.visible, 1)) time.addAction(vizact.waittime(.1)) time.addAction(vizact.call(self.PlayVictory)) time.addAction(vizact.call(self.info.expand))
def record_data(self): self.records.append(( viz.tick() - self.start_tick, self.previous_target, self.current_target, self.suit.get_markers(), ))
def getData(): elapsed_time = viz.tick() - start_time position = viz.MainView.getPosition() #Make a string out of the data. data = "Time: " + str(elapsed_time) + '\t' + "Position: " + str(position) + '\n' #Write it to the tracking file. game_data.write(data)
def logSubjpos(self): # concat log file logFile = os.path.join(ct.PATH_TO_LOGFILE, self.subjPosLogFile) # create file if non existent if not os.path.exists(logFile): f = open(logFile, 'w') else: f = open(logFile, 'a') # get current time stamp cTstamp = viz.tick() # get current pos cSubjPos = viz.Vector(viz.MainView.getPosition()) str2write = "%s %s " % (round(cSubjPos.x, 2), round(cSubjPos.z, 2)) # add timestamp and new line string str2write = "%s " % round(cTstamp, 2) + str2write + '\n' # write to file f.write(str2write) f.close()
def ExitProximity_end_sensor(end_sensor): sensor_data.write('\nexited start plane at: ' + str(viz.tick())+'seconds') global times_entered_end_plane global scale_x1 global n times_entered_end_plane=+1 array_manipulator(control_array) n=n+1
def update_thread(self): while self._running: self.update() #time.sleep(1./1000) try: elapsed = viz.tick() - self._updated except: tick = viz.tick() upd = self._updated wait = 1. / 1000 - elapsed if( wait > 0 ): time.sleep(wait)
def keydown(self, button): """records a button press response to stimuli""" if self.ON == 1: self.ResponseStamp = viz.tick() #can press any button for response self.ppresp = 1
def recording(record, scene, condition, stimuli, trialNo): while True: data = str(scene) + ',' + str(condition) + ',' + str( stimuli) + ',' + str(trialNo) + ',' + str(viz.tick()) + ',' + str( view.getPosition()).strip('[]') + ',' + str( view.getEuler()).strip('[]') + '\n' record.write(data) yield viztask.waitTime(1 / 75)
def updatePos(self): rad_to_deg = math.pi / 180.0 msg = viz.addText("", parent=viz.SCREEN, pos=(0.05, 0.9, 0), scale=(0.25, 0.25, 0)) msg.setBackdrop(viz.BACKDROP_OUTLINE) self.readTime = 0 t0 = viz.tick() while True: if self.going: #self.T1.ReadBothBeltsPosition() #self.T1.ReadBothBeltsSpeed() self.lbp = self.T1.plabTreadmill.leftBeltPosition.value self.rbp = self.T1.plabTreadmill.rightBeltPosition.value self.lbs = self.T1.plabTreadmill.leftBeltSpeed.value self.rbs = self.T1.plabTreadmill.rightBeltSpeed.value if self.verbose: self.message = "Left: %6.6f, %6.6f\nRight: %6.6f, %6.6f\nReadTime: %6.6f ms"%(\ self.lbp, self.lbs, self.rbp, self.rbs, 1000.0*self.readTime) else: self.message = "" msg.message(self.message) dt = viz.tick() - t0 dtheta_dt = (self.lbs - self.rbs) / self.separation dr_dt = 0.5 * (self.lbs + self.rbs) spinner = vizact.spin(0, 1, 0, dtheta_dt, dt) mover = vizact.move(0, 0, dr_dt, dt) spinmove = vizact.parallel(spinner, mover) #print "gh1",dr_dt, dt self.track.addAction(spinmove) yield viztask.waitActionEnd(self.track, spinmove) t0 = viz.tick() #for the recording if self.recording: #time, left pos, left speed, right pos, right speed, head pos (xyz, dir) pp = self.track.getPosition() self.history.append( (viz.tick(), self.lbp, self.lbs, self.rbp, self.rbs, pp[0], pp[1], pp[2], self.track.getEuler()[0])) #yield viztask.waitTime(1.0/19.0) yield viztask.waitEvent(TREADMILL_STATE_UPDATED)
def update(num): if UPDATE: trialtimer = viz.tick() - trialstart if DEBUG: txtmode.message(str(onset) +'\n' + str(yr) + '\n' + str(round(trialtimer,2))) if AUTOFLAG: #read the corresponding entry on the playback_data if trialtimer <= onset: i, auto_row = next(playback_iter) #print(i, auto_row) dir = auto_row.bend new_swa = auto_row.swa * dir * bend #these columns are named slightly differently to the final experiment data new_yr = auto_row.yr * dir * bend #move the wheel. wheel.set_position(new_swa) #set steering wheel to else: #driver.setAutomation(False) new_yr = 0 #off-tangent failure else: new_yr = None #update position updatevals = driver.UpdateView(new_yr) #return the values used in position update #retrieve position and orientation pos = cave.getPosition() yaw = vizmat.NormAngle(cave.getEuler()[0]) #record data #columns = ('ppid', 'block','world_x','world_z','world_yaw','timestamp_exp','timestamp_trial','maxyr', 'onsettime', 'bend','dn','autoflag','yr_sec','yr_frames','distance_frames','dt','sw_value','wheelcorrection','sw_angle') output = (ppid, block, pos[0], pos[2], yaw, viz.tick(), trialtimer, yr, onset, bend, dn, int(AUTOFLAG), updatevals[0], updatevals[1],updatevals[2], updatevals[3],updatevals[4],updatevals[5], updatevals[4]*90) #output array #print(output) #self.OutputWriter.loc[self.Current_RowIndex,:] = output #this dataframe is actually just one line. OutputWriter.writerow(output) #output to csv. any quicker?
def recordResp(self): try: respTime = viz.tick() if self.Response[-1] == '': self.Response.pop() self.Response.append(respTime) else: self.Response[-1] = [self.Response[-1], respTime] except: pass
def __stride(self): leftDown = viztask.waitEvent(LEFT_ON_TREADMILL) leftUp = viztask.waitEvent(LEFT_OFF_TREADMILL) rightDown = viztask.waitEvent(RIGHT_ON_TREADMILL) rightUp = viztask.waitEvent(RIGHT_OFF_TREADMILL) while True: d = yield viztask.waitAny([leftDown, leftUp, rightDown, rightUp]) if self.enable: if d.condition is leftDown: self.leftDownTime = viz.tick() self.leftDownPos[0] = self.forceplates.latestLeftCOP[0] self.leftDownPos[1] = self.forceplates.latestLeftCOP[1] + CORRECT_LEFT st = self.leftDownTime - self.leftUpTime if st > MIN_STRIDE_TIME and st < MAX_STRIDE_TIME: self.leftStrideTime[0] = st self.leftStrideTime = np.roll(self.leftStrideTime, 1) self.leftStrideLength = math.sqrt((self.leftDownPos[0] - self.leftUpPos[0])**2 +\ (self.leftDownPos[1] - self.leftUpPos[1])**2) self.leftDistToDesired = self.leftDownPos[1] - DESIRED_POSITION if self.leftDistToDesired > MIN_DIST_TO_DESIRED: #set the left speed to be fast enough to get the foot back to the 'desired' while the right is up self.leftSpeed = FIXED_SPEED #self.leftSpeed = self.leftDistToDesired/np.mean(self.rightStrideTime + 1.e-6) #avoid 1/0 self.tmill.moveLeftBelt(spd=min([self.leftSpeed, MAX_SPEED]), mpss=ACCELERATION) self.history.append("%10.9g %10.9g leftdown"%(viz.tick(), min([self.leftSpeed, MAX_SPEED]))) elif d.condition is leftUp: self.tmill.moveLeftBelt(spd=0, mpss=DECELERATION) self.history.append("%10.9g %10.9g leftup"%(viz.tick(), 0)) self.leftUpTime = viz.tick() self.leftUpPos[0] = self.forceplates.latestLeftCOP[0] self.leftUpPos[1] = self.forceplates.latestLeftCOP[1] + CORRECT_LEFT if d.condition is rightDown: self.rightDownTime = viz.tick() self.rightDownPos[0] = self.forceplates.latestRightCOP[0] self.rightDownPos[1] = self.forceplates.latestRightCOP[1] st = self.rightDownTime - self.rightUpTime if st > MIN_STRIDE_TIME and st < MAX_STRIDE_TIME: self.rightStrideTime[0] = st self.rightStrideTime = np.roll(self.rightStrideTime, 1) self.rightStrideLength = math.sqrt((self.rightDownPos[0] - self.rightUpPos[0])**2 +\ (self.rightDownPos[1] - self.rightUpPos[1])**2) self.rightDistToDesired = self.rightDownPos[1] - DESIRED_POSITION if self.rightDistToDesired > MIN_DIST_TO_DESIRED: self.rightSpeed = FIXED_SPEED #self.rightSpeed = self.rightDistToDesired/np.mean(self.leftStrideTime + 1.e-6) #avoid 1/0 self.tmill.moveRightBelt(spd=min([self.rightSpeed, MAX_SPEED]), mpss=ACCELERATION) self.history.append("%10.9g %10.9g rightdown"%(viz.tick(), min([self.rightSpeed, MAX_SPEED]))) elif d.condition is rightUp: self.tmill.moveRightBelt(spd=0, mpss=DECELERATION) self.history.append("%10.9g %10.9g rightup"%(viz.tick(), 0)) self.rightUpTime = viz.tick() self.rightUpPos[0] = self.forceplates.latestRightCOP[0] self.rightUpPos[1] = self.forceplates.latestRightCOP[1]
def logAvatarPos(self): # function is called every 5 seconds # get timestamp cTstamp = viz.tick() # concat log file logFile = os.path.join(ct.PATH_TO_LOGFILE, self.avPosLogFile) # log avatar context once if not os.path.exists(logFile): f = open(logFile, 'w') charNameLine = '' ctxLine = '' for cAv in self.avatars: charNameLine = charNameLine + "%s " % (cAv.getCharName()) ctxLine = ctxLine + "%s " % (cAv.getCtx()) # add eol string charNameLine = charNameLine + '\n' ctxLine = ctxLine + '\n' # write to file f.write(charNameLine) f.write(ctxLine) f.close() # loop over avatars str2write = '' for cAv in self.avatars: if cAv.isVisible: x, _, z = cAv.getPosition() #print "context: ", cAv.getCtx() else: # avatar is invisible # -> get its clone's pos for cCl in self.actors: if cCl.getAvID() == cAv.getAvID(): x, _, z = cCl.getPosition() break str2write = str2write + "%s %s " % (round(x, 2), round(z, 2)) # add timestamp and new line string str2write = "%s " % round(cTstamp, 2) + str2write + '\n' # write to file f = open(logFile, 'a') f.write(str2write) f.close() # finally log subject's position self.logSubjpos()
def ExitProximity_start_sensor(start_sensor): # if times_entered_start_plane==1: start_node.translate(0,100,0) right_node1.setPosition(0,0,0) # elif times_entered_start_plane==2: # start_node.translate(0,100,0) # right_node2.setPosition(0,0,0) # elif times_entered_start_plane==3: # start_node.translate(0,100,0) # right_node3.setPosition(0,0,0) sensor_data.write('\nExited start_sensor1 at: ' + str(viz.tick()))
def SaveData(pos_x, pos_z, ori, steer): global out #what data do we want? RoadVisibility Flag. SWA. Time, TrialType. x,z of that trial These can be reset in processing by subtracting the initial position and reorienting. if out != '-1': # Create the output string currTime = viz.tick() out = out + str(float((currTime))) + '\t' + str( trialtype_signed) + '\t' + str(pos_x) + '\t' + str( pos_z) + '\t' + str(ori) + '\t' + str( steer) + '\t' + str(radius) + '\t' + str( trialbend.getVisible()) + '\n'
def SetNewStimuli(self): """Sets the delay and target for the next stimuli, based on the target occurence and current pool""" print("SetNewStimuli called") t = viz.tick() choices = ['T', 'D'] probabilities = [ self.Trial_targetoccurence_prob, 1 - self.Trial_targetoccurence_prob ] self.currentaudio_type = np.random.choice( choices, p=probabilities) #slow. ~ 1ms. if self.currentaudio_type == 'T': self.currentaudio = np.random.choice(self.Trial_targets) elif self.currentaudio_type == 'D': self.currentaudio = np.random.choice(self.Distractor_pool) self.Stimuli_PlayedStamp = viz.tick() print(self.currentaudio) audioindex = self.letters.index(self.currentaudio) af = self.AudioList[audioindex] viz.playSound(af) self.Stimuli_Timer = 0 self.ppresp = 0 ##set new delay. Random between 1-1.5 jitter = np.random.randint(0, 49) self.delay = 1.0 + (jitter / 100.0) self.Overall_Stimuli_Index += 1 self.Trial_Stimuli_Index += 1 print("SetNewStimuli: ", viz.tick() - t)
def walk_maze_task(self): """ Writes a start and end marker of walking phase. :param markerstream: :return: """ print '!!! HIT TRIGGER TO START REWALKING MAZE !!!' self.scene.change_instruction("Finden Sie das Ende des Pfades!\n" "Zum Starten und bestaetigen, Klick!") yield self.hide_inst_continue_trigger() # send walking phase start marker start_walk = viz.tick() self.log_exp_progress('type:rewalking_start;') # end walking phase yield self.hide_inst_continue_trigger() print '!!! REWALKING TASK: ESTIMATED END LOGGED !!!' # send walking phase end marker duration_walk = viz.tick() - start_walk self.log_exp_progress('type:rewalking_end;duration_walk:' + str(round(duration_walk,2)) + ';')
def ExitProximity_start_sensor(start_sensor): global right1 global x global reaction_timer_final right1=right1-50 start_node.translate(0,100,0) right_node1.translate(right1-50,0,0) left_node1.translate(right1-50,0,0) end_node.setPosition(0,0,0) # end_box.setPosition(x_translate_shifted1,y_height1,z_depth1) end_box.setPosition(x_translate_shifted1,y_height1,z_depth1) #CHANGED THIS. Let's see if it works! reaction_timer_final=viz.tick()
def flashing(self): self.taskHandle.StartTask() for nextColor in self.colors: self.taskHandle.WriteDigitalLines(1, 1, 5.0, DAQmx_Val_GroupByChannel, self.off, None, None) yield viztask.waitTime(self.lowTime) self.taskHandle.WriteDigitalLines(1, 1, 5.0, DAQmx_Val_GroupByChannel, nextColor, None, None) self.t.append(viz.tick()) self.Response.append('') yield viztask.waitTime(self.highTime)
def check_pulse(self): state = self.port.read() triggertime = viz.tick() if state: if state == TRIGGER_DOWN: viz.sendEvent(TRIGGER_EVENT) self.event_count += 1 self.received_triggers.append(triggertime) elif state == RIGHT_BUTTON_DOWN: viz.sendEvent(RIGHT_BUTTON_EVENT, triggertime) self.events.append((RIGHT_BUTTON_DOWN, triggertime)) elif state == LEFT_BUTTON_DOWN: viz.sendEvent(LEFT_BUTTON_EVENT, triggertime) self.events.append((LEFT_BUTTON_DOWN, triggertime))
def check_pulse(self): state = self.port.read() triggertime = viz.tick() if state: if state == TRIGGER_DOWN: viz.sendEvent(TRIGGER_EVENT) self.event_count += 1 self.received_triggers.append(triggertime) elif state == RIGHT_BUTTON_DOWN: viz.sendEvent(RIGHT_BUTTON_EVENT,triggertime) self.events.append((RIGHT_BUTTON_DOWN,triggertime)) elif state == LEFT_BUTTON_DOWN: viz.sendEvent(LEFT_BUTTON_EVENT,triggertime) self.events.append((LEFT_BUTTON_DOWN,triggertime))
def testPhase(): results = [] trials = [3,2,0,4,1] for i in trials: #Check to see if participant is already in room center. If not #wait until the centerSensor is activated if centerSensor not in manager.getActiveSensors(): yield vizproximity.waitEnter(centerSensor) #Get sensor for this trial sensor = sphereSensors[i] #Instruct participant where to go instruction = 'Walk to the {} sphere'.format(sensor.name) info.setText(instruction) #store the time at which this trial started startTime = viz.tick() #The yielded command returns a viz.Data object with information #about the proximity event such as the sensor, target involved yield vizproximity.waitEnter(sensor) info.setText('Please return to the center of the room') #calculate the time it took for the subject to find the correct object elapsedTime = viz.tick() - startTime #save results results.append((sensor.name, elapsedTime)) info.setText('Thank You. You have completed the experiment') #return results viztask.returnValue(results)
def setTimer(): global timerTicks, time if not isinstance(timerTicks, float): return ticks = int(viz.tick() - timerTicks) if ticks < 60: sec = ticks min = 0 else: sec = ticks % 60 min = ticks / 60 if sec < 10: sec = '0'+str(sec) if min < 10: min = '0'+str(min) time = str(min) + ':' + str(sec)
def check_hand_in_wall(self): """ wall touch (for hand collision only!) simulated by a flat sphere at the position of the wall """ # current feedback duration self.feedback_duration = viz.tick() - self.feedback_start_time if self.hand_in_wall: if self.feedback_duration > 2: self.scene.change_instruction('Hand zurueck ziehen!') if not self.hand_in_wall and self.feedback_duration > .7: self.new_touch_allowed = True self.feedback_hand.remove() self.feedback_start_time = 0
def update(self): '''Update our knowledge of the current data from phasespace.''' now = viz.tick() # logging.info('%dus elapsed since last phasespace update', # 1000000 * (now - self._updated)) self._updated = now rigids = OWL.owlGetRigids() markers = OWL.owlGetMarkers() err = OWL.owlGetError() if err != OWL.OWL_NO_ERROR: hex = '0x%x' % err logging.debug('OWL error %s (%s) getting marker data', ERROR_MAP.get(err, hex), hex) return sx, sy, sz = self.scale ox, oy, oz = self.origin def psPoseToVizardPose(x, y, z): # converts Phasespace pos to vizard cond return -sz * z + oz, sy * y + oy, -sx * x + ox # converts Phasespace quat to vizard quat def psQuatToVizardQuat(w, a, b, c): return -c, b, -a, -w for marker in markers: if (marker.cond > 0 and marker.cond < self.owlParamMarkerCondThresh): t, o = marker.id >> 12, marker.id & 0xfff x, y, z = marker.x, marker.y, marker.z self.trackers[t].update_markers( o, Marker(pos=psPoseToVizardPose(x, y, z), cond=marker.cond), Marker(pos=(x, y, z), cond=marker.cond)) for rigid in rigids: if (rigid.cond > 0 and rigid.cond < self.owlParamMarkerCondThresh): self.trackers[rigid.id].update_pose( Pose(pos=psPoseToVizardPose(*rigid.pose[0:3]), quat=psQuatToVizardQuat(*rigid.pose[3:7]), cond=rigid.cond))
def isActionReady(self): # is there any action running # that should be continued? if self.cActionT0 > 0: if viz.tick() > self.cActionT0 + ct.MIN_ANIMATION_DUR: self.cActionT0 = -1 return 1 else: # repeat last action viz.VizAvatar.addAction(self, self.cAction) return 0 # currently there is no action # that needs to be repeated # always return 1 else: return 1
def writing(trialNo): record = open('PBpath_P' + subject_no + '_Trial_' + str(trialNo) + time.strftime('_%Y-%m-%d_%H-%M-%S') + '.csv', 'a') #time.strftime('-%Y-%m-%d_%H-%M-%S') FrameNo = 1 data = 'FrameNo, TimeStamp, Head_x, Head_y, Head_z, Head_yaw, Head_pitch, Head_roll, Body_x, Body_y, Body_z, Body_yaw, Body_pitch, Body_roll, Head2_x, Head2_y, Head2_z' record.write(data + '\n') while True: data = [] data = str(FrameNo) + ',' + str(viz.tick()) + ',' + str( head.getPosition()).strip('[]') + ',' + str( head.getEuler()).strip('[]') + ',' + str( body.getPosition()).strip('[]') + ',' + str( body.getEuler()).strip('[]') + ',' + str( tracker.getPosition()).strip('[]') FrameNo += 1 record.write(data + '\n') yield viztask.waitTime(1 / 120)
def onbutton(obj,state): #Use our starting time variable to find out how much #time has elapsed. elapsed_time = viz.tick() - start_time #Create string lines to put in the data file, depending on which #button was pushed. if obj == yes_button: data = 'Subject ' + str(subject) + ' saw a pigeon.\t' if obj == no_button: data = 'Subject ' + str(subject) + ' did not see a pigeon.\t' #add elapsed time to data data = data + 'Elapsed time was: ' + str(round(elapsed_time,2)) + ' seconds\n' #Write the data to our file. question_data.write(data) #Flush the internal buffer. question_data.flush() #Close the world. viz.quit()
def update(self): '''Update our knowledge of the current data from phasespace.''' now = viz.tick() #logging.info('%dus elapsed since last phasespace update', # 1000000 * (now - self._updated)) self._updated = now rigids = OWL.owlGetRigids() markers = OWL.owlGetMarkers() err = OWL.owlGetError() if err != OWL.OWL_NO_ERROR: hex = '0x%x' % err logging.debug( 'OWL error %s (%s) getting marker data', ERROR_MAP.get(err, hex), hex) return sx, sy, sz = self.scale ox, oy, oz = self.origin def psPoseToVizardPose(x, y, z): # converts Phasespace pos to vizard cond return -sz * z + oz, sy * y + oy, -sx * x + ox def psQuatToVizardQuat(w, a, b, c): # converts Phasespace quat to vizard quat return -c, b, -a, -w for marker in markers: if( marker.cond > 0 and marker.cond < self.owlParamMarkerCondThresh ): t, o = marker.id >> 12, marker.id & 0xfff x, y, z = marker.x, marker.y, marker.z self.trackers[t].update_markers(o, Marker(pos=psPoseToVizardPose(x, y, z), cond=marker.cond), Marker(pos=(x, y, z), cond=marker.cond)) for rigid in rigids: if( rigid.cond > 0 and rigid.cond < self.owlParamMarkerCondThresh ): self.trackers[rigid.id].update_pose(Pose( pos=psPoseToVizardPose(*rigid.pose[0:3]), quat=psQuatToVizardQuat(*rigid.pose[3:7]), cond=rigid.cond))
def getdata(): #orientation = viz.MainView.getEuler() #position = viz.MainView.getPosition() #data = str(subject) + '\t' + str(orientation) + '\t' + str(position) + '\n' elapsed_time= starting_time-viz.tick()
self.counter2 = 0 #Store the model name in this class. self.modelName = modelName def myTimer( self, num ): #Add a model by the given name and place it according to the counter. #Advance the counter. self.counter += .1 data = ' ' + str(self.counter) time_data.truncate() time_data.write(data) starting_time= viz.tick() def getdata(): #orientation = viz.MainView.getEuler() #position = viz.MainView.getPosition() #data = str(subject) + '\t' + str(orientation) + '\t' + str(position) + '\n' elapsed_time= starting_time-viz.tick() vizact.ontimer(1,getdata) #Call the class. modelMaker('box.wrl') viz.move(0,1.5,2)
def cross_trial(start_time, wait_time, rt_deadline, remove, message="",training=False): """ Implements a single trial Parameters ========== start_time:float IF start_time == 0, wait for the next trigger pulse. Else, wait until start_time to begin the trial. wait_time:float time to wait until the cross should remove one of its lines rt_deadline:float if the subject did not respond more quickly than the deadline, tell them they blew it remove:str The portion of the cross to remove. Either "hbar" or "vbar". """ descr = {"onset":start_time, "duration":wait_time, "crossbar":remove} new_texture = hbar if remove == "vbar" else vbar if start_time == 0: yield vizact.waitsignal(TRIGGER_EVENT) else: while viz.tick() < start_time: yield viz.waitTime(0.01) # ---- If there's a message, display it for MESSAGE_TIME #block_text.message(message) #vizact.ontimer2(rate=MESSAGE_TIME, repeats=0,func=clear_text) # ---- Flash the cue quad.texture(cue) yield viztask.waitTime(0.5) quad.texture(cross) # ---- Wait the required time yield viztask.waitTime(wait_time) # ---- Set the new texture quad.texture(new_texture) #Wait for next frame to be drawn to screen d = yield viztask.waitDraw() #Save display time displayTime = d.time #Wait for a reaction reaction = yield viztask.waitAny( [HBAR_RESPONSE, VBAR_RESPONSE] ) time_at_response, = reaction.data.data[0] # How did they do?? # -> Hbar remains if reaction.condition is HBAR_RESPONSE: descr["acc_success"] = remove == "vbar" response = "hbar" # -> vbar remains if reaction.condition is VBAR_RESPONSE: descr["acc_success"] = remove == "hbar" response = "vbar" # print "removed:", remove,"responded:",response # Calculate reaction time reactionTime = time_at_response - displayTime descr["speed_success"] = reactionTime < rt_deadline success = descr["speed_success"] and descr["acc_success"] # What sort of feedback to give? #if training: # In training blocks, show the rt #yield training_display(reactionTime,descr["acc_success"]) #else: if success: yield success_display(reactionTime) else: failtype = "WRONG" if descr["speed_success"] else "TIMEOUT" yield fail_display(failtype, reactionTime) quad.texture(cross) descr["response"] = response descr["success"] = success descr["rt"] = reactionTime descr["rt_deadline"]= rt_deadline descr["changetime"] = d.time viztask.returnValue(descr)
def ExitProximity_end_sensor(end_sensor): time_data.write('\nexited start plane at: ' + str(viz.tick()))
# Wait until pigeon is found or time runs out wait_time = viztask.waitTask( TrialCountDownTask() ) wait_find = vizproximity.waitEnter(sensor) data = yield viztask.waitAny([wait_time,wait_find]) # Hide pigeon and remove proximity sensor pigeon_root.visible(False) hooting.pause() manager.remove() # Return whether pigeon was found viztask.returnValue(data.condition is wait_find) ##Challenge 3 of Day 2## start_time = viz.tick() game_data = open('D2c3_.txt', 'a') #Get the tracking data. def getData(): elapsed_time = viz.tick() - start_time position = viz.MainView.getPosition() #Make a string out of the data. data = "Time: " + str(elapsed_time) + '\t' + "Position: " + str(position) + '\n' #Write it to the tracking file. game_data.write(data) def MainTask(): """Top level task that controls the game"""
def ExitProximity_start_sensor(start_sensor): time_data.write('\nExited start_sensor1 at: ', viz.tick())
def __init__(self, config = None): super(phasespaceInterface, self).__init__() self.rbTrackers_rbIdx = []; # A list full of rigidBodyTrackers self.markerTrackers_mIdx = []; # Note that these are vectors of Phasespace marker objects self.config = config if config==None: print('***Debug mode***') self.phaseSpaceFilePath = 'Resources/' self.origin = [0,0,0]; self.scale = [0.001,0.001,0.001]; self.serverAddress = '192.168.1.230'; self.rigidFileNames_ridx= ['hmd-nvisMount.rb','paddle-hand.rb'] self.rigidAvgMarkerList_rIdx_mId = [[1,2],[3,5]] self.rigidOffset_ridx_XYZ = [[0,0,0],[0,0,0]] self.owlParamMarkerCount = 20 self.owlParamFrequ = OWL.OWL_MAX_FREQUENCY self.owlParamInterp = 0 self.owlParamMarkerCondThresh = 50 self.owlParamPostProcess = 0 self.owlParamModeNum = 1 print '**** Using default MODE #' + str(self.owlParamModeNum) + ' ****' else: self.phaseSpaceFilePath = 'Resources/' self.origin = self.config['phasespace']['origin'] self.scale = self.config['phasespace']['scale'] self.serverAddress = self.config['phasespace']['phaseSpaceIP'] self.rigidFileNames_ridx = self.config['phasespace']['rigidBodyList'] self.rigidOffset_ridx_XYZ = eval(self.config['phasespace']['rigidOffset_ridx_XYZ']) self.rigidAvgMarkerList_rIdx_mId = eval(self.config['phasespace']['rigidAvgMarkerList_rIdx_mId']) self.owlParamModeNum = self.config['phasespace']['owlParamModeNum'] self.owlParamMarkerCount = self.config['phasespace']['owlParamMarkerCount'] self.owlParamFrequ = self.config['phasespace']['owlParamFrequ'] self.owlParamInterp = self.config['phasespace']['owlParamInterp'] self.owlParamMarkerCondThresh = self.config['phasespace']['owlParamMarkerCondThresh'] self.owlParamRigidCondThresh = self.config['phasespace']['owlParamRigidCondThresh'] self.owlParamPostProcess = self.config['phasespace']['owlParamPostProcess'] # set default frequency if( self.owlParamFrequ == 0 ): self.owlParamFrequ = OWL.OWL_MAX_FREQUENCY; flags = 'OWL.OWL_MODE' + str(self.owlParamModeNum) if( self.owlParamPostProcess ): flags = flags + '|OWL.OWL_POSTPROCESS' initCode = OWL.owlInit(self.serverAddress,eval(flags)) #initCode = owlInit(self.serverAddress,0) if (initCode < 0): raise OwlError('phasespace') print "Mocap: Could not connect to OWL Server" exit() else: print '**** OWL Initialized with flags: ' + flags + ' ****' OWL.owlSetFloat(OWL.OWL_FREQUENCY, self.owlParamFrequ) OWL.owlSetInteger(OWL.OWL_STREAMING, OWL.OWL_ENABLE) OWL.owlSetInteger(OWL.OWL_INTERPOLATION, self.owlParamInterp) self.trackers = [] ###################################################################### ###################################################################### # Create rigid objects #head = mocap.track_rigid('Resources/hmd-nvisMount.rb', center_markers=(1,2)) # for all rigid bodies passed into the init function... for rigidIdx in range(len(self.rigidFileNames_ridx)): # initialize rigid and store in self.rbTrackers_rbIdx rigidOffsetMM_WorldXYZ = [0,0,0] rigidAvgMarkerList_mIdx = [0] if( len(self.rigidOffset_ridx_XYZ) < rigidIdx ): print 'Rigid offset not set! Using offset of [0,0,0]' else: rigidOffsetMM_WorldXYZ = self.rigidOffset_ridx_XYZ[rigidIdx] if( len(self.rigidAvgMarkerList_rIdx_mId) < rigidIdx ): print 'Average markers not provided! Using default (marker 0)' else: rigidAvgMarkerList_mIdx = self.rigidAvgMarkerList_rIdx_mId[rigidIdx] #rigidOffsetMM_WorldXYZ = self.rigidOffset_ridx_XYZ[rigidIdx] #rigidNameAndPathStr = self.phaseSpaceFilePath + self.rigidFileNames_ridx[rigidIdx] #self.rbTrackers_rbIdx.append( self.track_rigid(rigidNameAndPathStr , rigidAvgMarkerList_mId ) ) # rigidOffsetMM_WorldXYZ self.rbTrackers_rbIdx.append( self.track_rigid(self.rigidFileNames_ridx[rigidIdx],rigidAvgMarkerList_mIdx, rigidOffsetMM_WorldXYZ)) #def track_rigid(self, filename, markers=None, center_markers=None): ########################################################################### self._updated = viz.tick() self._thread = None self._running = False
def getdata(timer1,timer2): global var1 global var2 var1= viz.tick()-timer1 var2= (viz.tick()-timer2)