Log in

View Full Version : output data to screen


Saz
12-19-2008, 02:48 AM
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

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!

Jeff
12-19-2008, 04:59 PM
if you use viz.SCREEN the text will be fixed on the screen

import viz
viz.go()

#Add text to the screen.
text_2D = viz.addText( 'on the screen', viz.SCREEN )
text_2D.setPosition(.05, .9 ) #2D text only needs x and y.