Page 1 of 1

Reading Proximity Sensor Value

Posted: 15 Aug 2018, 08:57
by lukegalea16
Hi all,

I am new to V-REP and currently I am trying to use it to develop a project about swarm robotics.

Could someone please shed some light about reading the value of the proximity sensor? I am using a ray type for the time being. Using the function listed below I am able to detect whether the proximity sensor has detected an object or not (if front_mid is greater than 0).

Code: Select all

front_mid=sim.readProximitySensor(frontMidSensor)
Can anyone please guide me towards obtaining a reading depending on the object's distance from the proximity sensor? Similar to a real life scenario.

Thanks and regards
Luke

Re: Reading Proximity Sensor Value to obtain distance from object

Posted: 15 Aug 2018, 13:45
by lukegalea16
For those interested, I managed to make this work.
  • r stands for result
  • d stands for distance
  • dP stands for detectedPoint

Code: Select all

r,d,dP=sim.checkProximitySensor(frontMidSensor,sim.handle_all)
print(r,d,dP)
Taken from the documentation:
  • result: -1 (error), 0 (not detected) or 1 (detected)
  • distance: distance from the sensor origin to the detected point. Is nil if result is different from 1
  • detectedPoint: position of the detected point relative to the sensor origin. Is nil if result is different from 1