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-26-2007, 11:37 AM
Elittdogg Elittdogg is offline
Member
 
Join Date: Aug 2007
Posts: 77
Flock of Birds question (again)

If I collect with the Birds through Vizard, I get a different number of data points each time I run the program. Even if I standardize the collection rate at "(1.0/30)" because I want it to collect at 30 Hz. So I should be getting 1800 data points all of the time. The problem is that sometimes I get 1700, sometimes 1800, often times a completely random value like 1793, etc.

def onkeydown(key):
if key == ' ':
viz.starttimer(0,(1.0/30),viz.FOREVER)
viz.starttimer(4,(1.0/30),viz.FOREVER)
viz.starttimer(3,60,1)

Is this a problem with the code or a processing speed problem? I'm using an old computer (and it happens to be the only one I can use) so if it's a problem with the processing speed of the computer then it could be a problem. Also the way the Birds are hooked up are that all 6 of them can be "plugged into" the other computer (the one with MotionMonitor) but on the computer with Vizard only Bird 1 can be plugged and subsequent birds are read through that. That being said, could that be contributing to a slow processing speed--the fact that everything has to be channelled through 1 Bird?

I hope it's something in the code that I'm missing because that would save me a lot of hassle. So If I'm trying to standardize my data collection and collect at 30 Hz for 60 seconds and get 1800 data points everytime (or at the very least some consistent amount of data points close to 1800) is there something in the code that I'm missing?

Sorry to be long-winded.

Thanks for the help in advance.
Reply With Quote
  #2  
Old 11-26-2007, 01:02 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
If you need exactly 1800 samples, then setup a counter that will stop the timer after the specified number of samples have been recorded. Here is some sample code that should show you how it works:
Code:
import viz
viz.go()

MAX_SAMPLES = 1800
SAMPLE_RATE = 1.0 / 30.0

samples = 0
def onTimer(num):
	global samples
	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,onTimer)


def onKeyDown(key):
	global samples
	if key == ' ':
		#Clear samples and start timer
		samples = 0
		viz.starttimer(1,SAMPLE_RATE)

viz.callback(viz.KEYDOWN_EVENT,onKeyDown)
Reply With Quote
  #3  
Old 11-26-2007, 01:08 PM
Elittdogg Elittdogg is offline
Member
 
Join Date: Aug 2007
Posts: 77
But I also need it to be flexible in the sense that if I collect for one minute so then I get 1800 samples at a rate of 30 Hz, but if I only collect for 30 seconds then I need 900 samples still at a rate of 30 Hz. Likewise if I only collect for 42 seconds at 30 Hz I need 1260 data points. Does this allow for that? Or will it continue to collect until all 1800 samples are obtained?
Reply With Quote
  #4  
Old 11-26-2007, 01:12 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Set the MAX_SAMPLES variable to however many samples you need, it's up to you. If you want to collect for only 45 seconds then set it to the following:
Code:
MAX_SAMPLES = 45 * 30
Reply With Quote
  #5  
Old 11-26-2007, 01:21 PM
Elittdogg Elittdogg is offline
Member
 
Join Date: Aug 2007
Posts: 77
I got that, but what if I need MAX SAMPLES to be variable...i.e. to be able to be changed depending on how long the participant takes to complete a task. I.e. to make a general code because I won't be able to know how long each trial will last. Trial 1 might last 30s, or 31s, or 27s, or 37s, etc. And there is no way to plan ahead. Or does it have to be fixed beforehand?
Reply With Quote
  #6  
Old 11-26-2007, 01:24 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
You can change the value of MAX_SAMPLES anytime you want. If you want to set it in your callback then you can do the following:
Code:
def onKeyDown(key):
	global samples, MAX_SAMPLES
	if key == ' ':
		#Clear samples and start timer
		samples = 0
		MAX_SAMPLES = 45 * 30
		viz.starttimer(1,SAMPLE_RATE)

viz.callback(viz.KEYDOWN_EVENT,onKeyDown)
Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 07:57 AM.


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