WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 11-21-2016, 04:32 AM
jelly jelly is offline
Member
 
Join Date: Feb 2016
Posts: 38
delaying proximity reaction makes sensor unresponsive for the time of delay

In a recent post I had a problem implementing a delay in the proximity manager and Jeff has suggested the solution of using "vizproximity.waitEnter" and a while loop:

Code:
def proximityTask():
        global handstate
	while True:
		yield vizproximity.waitEnter(SensorIndexFinger)
		print 'entered sensor'
		yield viztask.waitTime(2)
		print 'two seconds elapsed'
                handstate = 1

viztask.schedule(proximityTask())
However, with this code I have a new problem and I decided to open up a new thread:

What happens now is that, once the sensor is entered, the action (change of the variable handstate from 0 to 1), will be delayed by two seconds. However if I happen to enter the sensor again very quickly, before these two 2 seconds have elapsed, nothing happens, as it seems that it is not registered that the sensor has been entered, until the first action takes place.

I wonder if there is a way around this? I tried to to the following: I will change a new variable upon entry but then I will make a new function where I say that IF the new variable "condition" is equal to 1 then after 2 seconds the handstate should change to 1 (= delayed action). This way I am hoping that I am not delaying the action itself in the proximity manager, I am delaying it outside of that function so that the proximity manager can freely register all entries.

Code:
def EnterProximity_IndexFinger(e): # decide what happens on sensor entry
	global handstate, condition
	e.sensor == SensorIndexFinger 
	condition = 1
	print condition
manager.onEnter(SensorIndexFinger,EnterProximity_IndexFinger)
with this I am just changing the variable condition and the I will try to use that in the following way:

Code:
def Handdelay():
	global handstate, condition
	print "now"
	if condition == 1:
		#yield vizproximity.waitEnter(SensorIndexFinger)
		yield viztask.waitTime(2)
		handstate = 1
		print "open hand"
	else:
		handstate = 0

viztask.schedule(Handdelay())
Unfortunately, the condition change is registered as soon as I enter the sensor, but the function which is supposed to call the delayed action (handstate changing to 1) is not working.

I would be very grateful for help!
Reply With Quote
 

Tags
proximity, proximity sensor, timing

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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 Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Proximity Manager - How to implement delay jelly Vizard 4 11-18-2016 09:48 AM
timer question Elittdogg Vizard 5 10-10-2007 03:49 PM


All times are GMT -7. The time now is 10:47 AM.


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