Reading Proximity Sensor Value

Typically: "How do I... ", "How can I... " questions
Post Reply
lukegalea16
Posts: 2
Joined: 11 Aug 2018, 15:17

Reading Proximity Sensor Value

Post 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

lukegalea16
Posts: 2
Joined: 11 Aug 2018, 15:17

Re: Reading Proximity Sensor Value to obtain distance from object

Post 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

Post Reply