WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Yield until joystick is deflected by a certain degree (https://forum.worldviz.com/showthread.php?t=5556)

Qiliang He 11-18-2015 08:56 AM

Yield until joystick is deflected by a certain degree
 
I've read the example scripts of yield statement, but I don't know how to realize this function: The function won't go to the next line until the user deflected the joystick beyond a certain degree. Here's my code:

HTML Code:

def pointing_task(joystick)
      some codes
      return angle,result  ##result is false means the joystick isn't deflected  beyond a certain threshold

def start_pointing():                       
      angle,result = pointing_task(joystick)
      yield result == True ??
      some codes

viztask.schedule(start_pointing())

My question is, how to use the yield statement to pause the program until a user deflect the joystick beyond a certain degree (result == True) and if he/she does, execute the following codes.

Thanks a lot!

lklab 11-18-2015 09:54 AM

have the pointing_task method be a loop that constantly is checking for joystick position. waits a few ms, then checks again.

something like

while( joystick position is not facing the right way)
yield viz.waittime(.01) #i forget the method

This way the loop will keep going and only exit until and continue with the rest of the program when the joystick is in position. the yield statement in the method makes other yield statement calling it actually wait and pause the program. (dont know why vizard does it this way but thats just how it is)

Qiliang He 11-18-2015 10:28 AM

Thanks a lot!


All times are GMT -7. The time now is 06:27 AM.

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