View Single Post
  #1  
Old 12-19-2008, 02:48 AM
Saz Saz is offline
Member
 
Join Date: Nov 2008
Posts: 36
output data to screen

Hi,

I'm writing the position of the joystick data to a file and I want the same information to appear on the top left of the vizard screen so that the user can see it. However I'm moving down an infinite road which is constantly updating and therefore my joystick information has to also move along with that, so I guess that I have to assign the text as a child of the road (or ground). This is what I've come up with so far
Code:
file = open( 'speed_.txt' + str(subject),'w' )
def mytimer (num):
	joy_pos = str(joy.getPosition())
	out = str(joy_pos + '\n')
	file.write(out)
	file.flush()
	print out
	#Add text as child of road

	speed = viz.add(viz.TEXT3D,joy_pos, road)
	speed.alignment(viz.TEXT_LEFT_TOP)

#Text translation will be relative to road local coordinate system
	speed.translate(-1,1,-1)
	speed.color(0,0,0)
	speed.scale(.2, .2, 2)
viz.callback( viz.TIMER_EVENT, mytimer )
viz.starttimer( 0, 0.25, viz.FOREVER )
But the data is being constantly written over rather than updating, which I'm guessing will have something to do with the write function, plus it doesn't move as I'm travelling down the road (its also in the wrong position but that's just working out the co-ordinates)

Any help would be great!
Reply With Quote