WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rating: Thread Rating: 3 votes, 5.00 average. Display Modes
  #1  
Old 11-29-2007, 09:28 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Also, your framerate should usually be 60. What is your framerate when you run the following basic script?
Code:
import viz
viz.go()
Reply With Quote
  #2  
Old 11-29-2007, 10:17 AM
Elittdogg Elittdogg is offline
Member
 
Join Date: Aug 2007
Posts: 77
Hopefully you can run it now:

Code:
import viz					
import math					
import whrandom 			
import string				

viz.go(viz.PROMPT)			

# Get subject number from prompt box
promptMesg = viz.get(viz.INITMESG)		
if promptMesg == "":					
	Subnum 	= 999						
	Trial	= 100						
	
else:									
	text = string.split(promptMesg)		
	Subnum = int(text[0])  				
	Trial = int(text[1]) 				
	
print "Subnum =", Subnum				
print "Trial =", Trial					

PORT_FOB = 1
NUM_FOB = 6								
NUM_DOTS = 900							
RADIUS = .5								
DATA = 2								
AMPLITUDE = .05							
X1 = 0									
X2 = 64									

MAX_SAMPLES = 60.0 * 30.0
SAMPLE_RATE = 1.0 / 30.0
samples = 0

viz.startlayer(viz.POINTS)				
viz.vertexcolor(1,1,1)					
viz.pointsize(4)						

for i in range(0, NUM_DOTS):			
  x = whrandom.random() - 0.5			 
  y = whrandom.random() - 0.5			
  z = whrandom.random() - 0.5			
  length = math.sqrt(x*x + y*y + z*z)	
  x = x / length * RADIUS				
  y = y / length * RADIUS				
  z = z / length * RADIUS				
  viz.vertex(x, y, z)					

sphere = viz.endlayer()					
sphere.translate(0,1.8,.2)				

flock1 = viz.add('flockofbirds.dls')	
#flock2 = viz.add('flockofbirds.dls')
#flock3 = viz.add('flockofbirds.dls')	
#flock4 = viz.add('flockofbirds.dls')	

flock1.command(6)						
#flock2.command(6)						
#flock3.command(6)						
#flock4.command(6)						

tracking_data = open('openloopsine_complex/headdata_'+ str(Subnum) + " " + str(Trial) + '.txt', 'a')			
#tracking_data2 = open('openloopsine_complex/hipdata_'+ str(Subnum) + " " + str(Trial) + '.txt', 'a')			
#tracking_data3 = open('openloopsine_complex/kneedata_'+ str(Subnum) + " " + str(Trial) + '.txt', 'a')			
#tracking_data4 = open('openloopsine_complex/ankledata_'+ str(Subnum) + " " + str(Trial) + '.txt', 'a')			

def mytimer(num):								
	if num == 0:								
		global AMPLITUDE, TOTALCYCLES, X1, X2, samples	
		
		data1 = flock1.get()							
				
		HEADLAT = data1[0]								
		HEADVERT = data1[1]								
		HEADAP = data1[2]								
		HEADYAW = data1[3]								
		HEADPITCH = data1[4]							
		HEADROLL = data1[5]								
	
		head_data = str(Subnum) + '\t' + str(Trial) + '\t' + str(HEADAP) + '\t' +str(HEADLAT) + '\t' +str(HEADVERT) + '\t' +str(HEADYAW) + '\t' +str(HEADPITCH) + '\t' +str(HEADROLL) +'\n'			
		tracking_data.write(head_data)																																								
	
	if num == 4:												
		xmove = AMPLITUDE*math.sin(2*(math.pi/180)*X1) + AMPLITUDE*math.sin(2.5*(math.pi/180)*X1) + AMPLITUDE*math.sin(3.5*(math.pi/180)*X1) + AMPLITUDE*math.sin(1.75*(math.pi/180)*X1) + AMPLITUDE*math.sin(2*(math.pi/180)*X1) + AMPLITUDE*math.sin(2.5*(math.pi/180)*X1) + AMPLITUDE*math.sin(3*(math.pi/180)*X1) + AMPLITUDE*math.sin(2.5*(math.pi/180)*X1)+ AMPLITUDE*math.sin(2*(math.pi/180)*X1) + AMPLITUDE*math.sin(1.75*(math.pi/180)*X1)		
		X1 = X1 + 1												
#		print xmove
		sphere.translate(0,1.8,.2+.3*xmove, viz.ABSOLUTE)		
		
	if num == 3:							
		viz.quit()							

	if num == 1:
		
		#TODO: Process sample
		
		#Increment samples
		samples += 1
		if samples < MAX_SAMPLES:
			viz.starttimer(1,SAMPLE_RATE)
		else:
			print 'Finished collecting samples'
			
viz.callback(viz.TIMER_EVENT,mytimer)

def onkeydown(key):
	if key == ' ':
		viz.starttimer(0,(1.0/30.0), viz.FOREVER)
		#Clear samples and start timer
		samples = 0
		MAX_SAMPLES = 60 * 30
		viz.starttimer(1,SAMPLE_RATE)
		viz.starttimer(4,(1.0/30.0),viz.FOREVER)

viz.callback(viz.KEYDOWN_EVENT,onkeydown)
Reply With Quote
  #3  
Old 11-29-2007, 10:20 AM
Elittdogg Elittdogg is offline
Member
 
Join Date: Aug 2007
Posts: 77
When I run that simple script my fram rate is essentially 60 (it constantly changes between 59 and 60).
Reply With Quote
  #4  
Old 11-29-2007, 03:04 PM
Elittdogg Elittdogg is offline
Member
 
Join Date: Aug 2007
Posts: 77
So now the question is why am I not getting consistent data collection results?
Reply With Quote
  #5  
Old 11-29-2007, 03:05 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
I'm not sure, it might be a framerate issue. Did the sample script I posted above give you better results?
Reply With Quote
  #6  
Old 11-30-2007, 08:37 AM
Elittdogg Elittdogg is offline
Member
 
Join Date: Aug 2007
Posts: 77
The sample script didn't really do anything. Maybe I'm not implementing it correctly, but I can't seem to get consistent results. When I'm running a script other than just that simple script the frame rate fluctuates around 49. Anyway, is there a way that I'm supposed to put your sample script within the code I have to make it work? Because what I did didn't do anything.
Reply With Quote
  #7  
Old 11-30-2007, 02:45 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Cool

Did you place your code for collecting samples in the DoSample function? That function will be called at the specified rate.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Flock of Birds recognized, but no data sent sjroorda Vizard 9 03-01-2016 08:48 PM
Using vrpn_server with Flock of birds sylvain Precision Position Tracker (PPT) 3 11-30-2007 09:45 AM
Flock of Birds Elittdogg Vizard 9 10-02-2007 01:53 PM
Flock of birds extended range problem theuberk Vizard 4 07-30-2007 09:31 AM
Adding more than one Flock of Birds asimbh Vizard 3 12-15-2006 01:48 AM


All times are GMT -7. The time now is 11:14 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC