WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 11-17-2016, 02:45 AM
jelly jelly is offline
Member
 
Join Date: Feb 2016
Posts: 38
Dear Jeff,

thank you for the help, this seems like the way to go! But I have some problems with it:

I noticed that adding the line

Code:
viztask.schedule(proximityTask())
makes the event happen only once, upon entering the sensor for the first time.

My question would be how do I make it happen everytime, like it was the case when I used

Code:
manager.onEnter(SensorIndexFinger,EnterProximity_IndexFinger)
I tried the following (somehow adding the function that specifies the delay to the manager):

Code:
SensorIndexFinger = vizproximity.Sensor(vizproximity.Box([0.03,0.03,0.03],center=[0,0,0]),IndexFinger) 
manager.addSensor(SensorIndexFinger)

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

def EnterProximity_IndexFinger(e): # decide what happens on sensor entry
	global handstate
	e.sensor == SensorIndexFinger 
	print "activate proximityTask"
manager.onEnter(SensorIndexFinger,proximityTask())
But I get an error "TypeError: 'generator' object is not callable."

I would be very happy to hear if you had any suggestions on how to call the action (with delay) every time the sensor was entered, as I can't seem to find a way to implement it
Reply With Quote
  #2  
Old 11-17-2016, 03:29 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
You can add a loop inside the task function:

Code:
def proximityTask():

	while True:
		yield vizproximity.waitEnter(SensorIndexFinger)
		print 'entered sensor'
		yield viztask.waitTime(2)
		print 'two seconds elapsed'

viztask.schedule(proximityTask())
Reply With Quote
  #3  
Old 11-18-2016, 08:48 AM
jelly jelly is offline
Member
 
Join Date: Feb 2016
Posts: 38
Smile

Thank you so much, Jeff, this works perfectly!
Reply With Quote
Reply

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 Sensing Using Kinect JamesCakes Vizard 6 06-24-2016 05:52 AM
Orientation selective (Viewing Vector) Proximity Sensor lmGehrke Vizard 2 03-17-2015 12:31 PM
Proximity Sensor Problem kmkm Vizard 3 03-04-2014 11:54 AM
Phase Space and Proximity Sensors snovob93 Vizard 3 06-13-2012 12:32 PM
Packager manager Chapre Vizard 1 04-29-2011 09:16 AM


All times are GMT -7. The time now is 05:21 AM.


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