![]() |
|
#1
|
|||
|
|||
Hi Jeff,
thanks for that, the joystick position is updating fine now once I took the textbox out of the timer loop. No, for the second part the code for the joystick position is working fine but what I am getting up on the screen at the moment is obviously the raw data of the joystick output - which is pretty meaningless to the observer, additionally it appears in the co ordinate system format of [0.0 0.0 0.0], wheareas I'm only really interested in the y co ordinate. Therefore I'm trying to multiply the raw data of the joystick that's already acquired so that it appears in a meaningful context on the screen, say as mph or kph - which is what I'm having difficulty with |
#2
|
|||
|
|||
this should update the speed in just the y direction every time the timer function is called
Code:
#add textbox and set position on screen text_speed = viz.addTextbox(parent = viz.SCREEN) text_speed.setPosition(.15, .9 ) text_speed.fontSize (30) old_posY = 0 def showSpeed(): global old_posY current_pos = viz.MainView.getPosition() current_posY = current_pos[1] distance = abs(current_posY - old_posY) #get speed in meters/sec speed = distance/viz.elapsed() #get speed in km/hour speed = speed/1000*3600 old_posY = current_posY #enter speed in textbox rounded to 1 digit after decimal text_speed.message(str(round(speed,1)) + 'km/hour') vizact.ontimer(.25, showSpeed) |
#3
|
|||
|
|||
Hi Jeff,
thanks for that - unfortunately it doesn't update and I constantly get 0.0km/hr on the screen - even though its moving along the road. I tried inserting joy.getPosition() in place of viz.MainView.getPosition() to see whether the code in principle functions and whilst that does produce a change in km/hr when either accelerating or deccelerating, because this piece of code is looking at a difference between outputs - when the joystick is held constant; there is no difference and so 0.0km/hr appears on the screen |
#4
|
|||
|
|||
That code should give you 0 km/hour if you are not moving along the y-axis which is the height. I think you may be wanting to get the speed along the z-axis. If that's the case then just dind the difference in z coordinates rather than the y coordinates.
|
#5
|
|||
|
|||
just to clarify, in the joystick navigation code, when you move the joystick on its y-axis that moves Vizard's viewpoint forward or backward which is Vizard's z axis. So to get the current z position just do
Code:
current_posZ = current_pos[2] |
#6
|
|||
|
|||
you're a star Jeff - thank you!! Is there any reason that I'm getting a continual drift of the viewpoint to the right though, even if I'm not using the joystick?
|
#7
|
|||
|
|||
Don't worry Jeff - its sorted! Cheers for your help!
|
![]() |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
output data to screen | Saz | Vizard | 1 | 12-19-2008 04:59 PM |
Flagging the Data | Elittdogg | Vizard | 5 | 04-11-2008 11:40 AM |
Data Files | betancourtb82 | Vizard | 6 | 05-04-2006 02:43 PM |
Obtaining Positional Data | Plasma | Vizard | 40 | 04-04-2006 11:31 AM |
tracking using quaternarion data | jfreeman | Vizard | 2 | 06-01-2005 08:48 AM |