I'm trying to work with proximity sensors and I encountered a problem with the sim.checkProximitySensor function : it seems that it always detects the object I'm passing as argument.
My scene is very simple : a ray type proximity sensor is attached to a robot leg. A static, respondable shape is approached to the sensor until contact (I do this manually).
Here is my code:
Code: Select all
-- attached to each leg tip function sysCall_init() prox_FL = sim.getObjectHandle("prox_FL") -- proximity sensor on leg tip -- sensor range is 0.002m in front of leg tip dummy_tip_FL = sim.getObjectHandle("dummy_tip_FL") tar = sim.getObjectHandle("tar") -- target cub = sim.getObjectHandle("Cuboid") -- static cube shape end function sysCall_sensing() res_FL, dist_FL, det_pt_FL = sim.checkProximitySensor(prox_FL, cub) if res_FL then -- we detect the cube in front of the foot print(dist_FL) end end
The strange thing is that dist_FL is "nil" when the cube is not in the sensor range, which contradicts the fact that res_FL is 1 (ref. to the function documentation).
Explicit handling or not doesn't change the output.
I think I don't understand how the sim.checkProximitySensor is supposed to work. Can you help me with that?