WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rating: Thread Rating: 2 votes, 5.00 average. Display Modes
  #1  
Old 09-14-2009, 09:54 AM
Elittdogg Elittdogg is offline
Member
 
Join Date: Aug 2007
Posts: 77
Offset Problem

I'm was playing around with my program and I realized that when the bird (i'm using a flock of birds) is at rest, Vizard is registering it as if it were pitching x degrees.

So I was wondering if I could just offset the pitch by "zeroing" it out at the beginning. So I set this up:

Code:
offset = 0				# redefined later

def DoSample0():
	global flock1, flock2, flock3, flock4, MainView, myMaze, offset, data1 #, CurrentLocation #, CheckHeading
	#Collect sample here
	data1 = flock1.get()
	#CurrentLocation = data1
	data2 = flock2.get()
	data3 = flock3.get()
	data4 = flock4.get()
	
	HEADLAT = data1[0]
	HEADVERT = data1[1]
	HEADAP = data1[2]
	HEADYAW = data1[3]
	HEADPITCH = data1[4]
	HEADROLL = data1[5]
	
	HIPLAT = data2[0]								
	HIPVERT = data2[1]								
	HIPAP = data2[2]								
	HIPYAW = data2[3]								
	HIPPITCH = data2[4]								
	HIPROLL = data2[5]								

	KNEELAT = data3[0]								
	KNEEVERT = data3[1]								
	KNEEAP = data3[2]								
	KNEEYAW = data3[3]								
	KNEEPITCH = data3[4]							
	KNEEROLL = data3[5]								
	
	ANKLELAT = data4[0]								
	ANKLEVERT = data4[1]							
	ANKLEAP = data4[2]								
	ANKLEYAW = data4[3]								
	ANKLEPITCH = data4[4]							
	ANKLEROLL = data4[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)
	hip_data = str(Subnum) + '\t' + str(Trial) + '\t' + str(HIPAP) + '\t' +str(HIPLAT) + '\t' +str(HIPVERT) + '\t' +str(HIPYAW) + '\t' +str(HIPPITCH) + '\t' +str(HIPROLL) +'\n'					
	tracking_data2.write(hip_data)																																								
	knee_data = str(Subnum) + '\t' + str(Trial) + '\t' + str(KNEEAP) + '\t' +str(KNEELAT) + '\t' +str(KNEEVERT) + '\t' +str(KNEEYAW) + '\t' +str(KNEEPITCH) + '\t' +str(KNEEROLL) +'\n'			
	tracking_data3.write(knee_data)																																								
	ankle_data = str(Subnum) + '\t' + str(Trial) + '\t' + str(ANKLEAP) + '\t' +str(ANKLELAT) + '\t' +str(ANKLEVERT) + '\t' +str(ANKLEYAW) + '\t' +str(ANKLEPITCH) + '\t' +str(ANKLEROLL) +'\n'	
	tracking_data4.write(ankle_data)
	
	MainView.translate(data1[0],data1[1]+1,data1[2])
	if myMaze.mazeType == 7:
		# No distortion for baseline
		MainView.rotate(data1[3], (data1[4] - offset) ,data1[5])
	else:
		MainView.rotate(-data1[3], -(data1[4] - offset) ,data1[5])
		
		
def onkeydown(key):	
	global pressed_S, pressed_Q, maze7, offset, data1
#	global StartTime
	if key == ' ':
		#Mazetracking.start()
		#Writeflag( )
		offset = data1[4]

However, I keep getting an error that says global variable data1 is not defined...and I'm confused because I thought I defined it and I thought I made it available where necessary. Am I missing something?

The other option is that my function to calculate the pitch is off. Any suggestions? Here is my pitch function:

Code:
	def findPitch(self, ptFrom=[0,0,0], ptTo=[0,0,0]):
		lenHypot 	= vizmat.Distance(ptFrom, ptTo)#, dimensions=3)	#
		lenRise		= ptFrom[1] - ptTo[1]			#
		if (lenRise == 0):
			return (0) # pitch = zero if two points are at equal height
		pitch = math.asin(float(abs(lenRise)) / float(lenHypot) )	# Determine magnitude of pitch
		pitch *= [-1, 1][(lenRise <= 0)]	# Determine sign of pitch
		return ((pitch/math.pi) * 180)
		#print lenHypot
		#print lenRise
Reply With Quote
  #2  
Old 09-15-2009, 07:28 AM
Elittdogg Elittdogg is offline
Member
 
Join Date: Aug 2007
Posts: 77
Ok...so the global error I was getting is fixed. At the beginning of my script when I defined data1 I misspelled it and that's why the program wasn't recognizing it.

I managed to fix the offset problem for the most part, except for one target. All the other targets and hotspots work fine (i.e. the hotspot for target 1 is around target 1, the hotspot for target 2 is around target 2, etc.); except for one target. The target is in the right location but the hotspot is offset a little bit above the target. This offset is significant enough that I can't just extend my hotspot area. But I'm very confused--why would everything work properly except for this one target. Furthermore, I tried having different targets there (e.g. A instead B, 1 instead of 2, etc.) and as such I've seemingly ruled out the possibility that it's the target and not the location.

Does anyone have any ideas why only this one would be offset and if so how do I correct it? (I can't move the target up to where the hotspot is because the hotspot is supposed to be based on the target location--so if I move the target the hotspot will move too).
Any help would be greatly appreciated. Thanks.
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
Vertex shader performance problem Joran Vizard 2 11-17-2008 02:29 AM
export problem bazelaisr Vizard 2 05-28-2008 11:19 AM
5DT Data Glove 5 Ultra Problem bjgold Vizard 1 08-08-2006 05:08 PM
problem with female animations vmonkey Vizard 1 10-07-2005 11:36 AM
PROBLEM: Picture-in-Picture breaks textures?!? vcarlson Vizard 4 10-05-2004 05:22 PM


All times are GMT -7. The time now is 02:41 AM.


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