Trigger callback functions

Child scripts, or customization scripts can include a trigger callback function (which is one of many system callback functions), when associated with a vision sensor or a proximity sensor.

Some conditions apply as to the location of the trigger callback function: if a trigger callback function is present in a child script as well as in a customization script, both attached to the object triggering, then the child script will be called first, and the customization script second.

A vision sensor can generate the trigger signal inside of the vision callback function. The trigger callback (if present) is then called as in following example:

function sysCall_trigger(inData) -- We have: -- inData.handle : the handle of the vision sensor. -- inData.packedPackets : an array of data packets, packed (use sim.unpackFloatTable to unpack) -- the first data packet always contains 15 auxiliary values about the acquired image: -- - minimum of {intensity, red, green blue and depth value} -- - maximum of {intensity, red, green blue and depth value} -- - average of {intensity, red, green blue and depth value} local outData={} outData.trigger=true return outData end

A proximity sensor generates the trigger signal when an object is detected. The trigger callback (if present) is then called as in following example:

function sysCall_trigger(inData) -- We have: -- inData.handle : the handle of the proximity sensor. -- inData.detectedObjectHandle : handle of detected object -- inData.detectedPoint : detected point, relative to sensor frame -- inData.normalVector : normal vector at detected point, relative to sensor frame local outData={} outData.trigger=true return outData end

In Python, a trigger callback function can only be implemented via a non-threaded script, and it should be explicitly activated with a luaExec command:

#python #luaExec additionalFuncs={'sysCall_trigger'} def sysCall_trigger(inData): pass