WorldViz User Forum Offset Problem
 Register FAQ Search Today's Posts Mark Forums Read

#1
09-14-2009, 08:54 AM
 Elittdogg 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()

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]

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```
#2
09-15-2009, 06:28 AM
 Elittdogg 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.

 Thread Tools Display Modes Rate This Thread Linear Mode Rate This Thread: 5 : Excellent 4 : Good 3 : Average 2 : Bad 1 : Terrible

 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 Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements Vizard Precision Position Tracker (PPT) Plug-in development

 Similar Threads Thread Thread Starter Forum Replies Last Post Joran Vizard 2 11-17-2008 01:29 AM bazelaisr Vizard 2 05-28-2008 10:19 AM bjgold Vizard 1 08-08-2006 04:08 PM vmonkey Vizard 1 10-07-2005 10:36 AM vcarlson Vizard 4 10-05-2004 04:22 PM

All times are GMT -7. The time now is 03:28 PM.