The following events are generated by a manager when a target enters/exits a sensor:
Event |
vizproximity.ENTER_PROXIMITY_EVENT |
vizproximity.EXIT_PROXIMITY_EVENT |
Both events provide a single event structure e with the following attributes:
Attribute |
Description |
sensor |
The sensor that was activated. |
target |
The activating target. |
manager |
The manager for the sensor/target involved. |
There are two ways to work with these events:
Use the following methods on the Manager object to register callback functions for proximity events:
Method |
Description |
<Manager>.onEnter(sensor, func, *args, **kw) |
Call the specified function when a target enters the proximity sensor. If sensor is not specified then all sensors will be allowed. |
<Manager>.onExit(sensor, func, *args, **kw) |
Call the specified function when a target exits the proximity sensor. If sensor is not specified then all sensors will be allowed. |
The following code shows how to register callback functions for proximity events:
Task functions, from the viztask library, are useful for controlling program flow. Use the following commands to create viztask conditions that wait for proximity events:
Command | Description |
vizproximity.waitEnter(sensor, target, manager) | viztask condition that waits for a proximity sensor enter event.
sensor - A Sensor object, list of Sensor objects, or None to allow any sensor target - A Target object, list of Target objects, or None to allow any target manager - A Manager object, list of Manager objects, or None to allow any manager |
vizproximity.waitExit(sensor, target, manager) | viztask condition that waits for a proximity sensor exit event.
sensor - A Sensor object, list of Sensor objects, or None to allow any sensor target - A Target object, list of Target objects, or None to allow any target manager - A Manager object, list of Manager objects, or None to allow any manager |
The following code shows to wait for a proximity event: