Trigger callback functionsScript objects can include a trigger callback function (which is one of many system callback functions), when the script object's parent is a vision sensor or a proximity sensor. 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: #python
def 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}
"""
outData = {}
outData['trigger'] = True
return outData
--lua
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: #python
def 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
"""
outData = {}
outData['trigger'] = True
return outData
--lua
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
|