Skip to content
This repository has been archived by the owner on Oct 18, 2019. It is now read-only.

IR distance sensor

Lasse Wolter edited this page Mar 14, 2019 · 12 revisions

Use

When an obstacle (person, object, etc.) goes in front or to the side of the robot it will cause the IR distance sensor to be triggered. As the robot moves in all 4 directions the sensors smartly only detect if there is an obstacle in the current front or side of the robot. Once the obstacle has been cleared the robot will wait a few seconds, to ensure that there are no new obstacles, and continue to its current destination.

Specs

Details can be found at: https://www.phidgets.com/?tier=3&catid=5&pcid=3&prodid=70#Voltage_Ratio_Input

Connection

The IR sensors come already connected to the Adapter. The adpater needs to be plugged into one of the analog inputs from the Phidget board CLOCKWISE looking at it from the top (using inputs 0-3 on the Phidget board).

  • 0 - 0°
  • 1 - 90°
  • 2 - 180°
  • 3 - 270°

Programming

Assuming that the following line is in the constructor of toddler.py
self.getSensors = IO.interface_kit.getSensors
readings of the analog inputs can be read by calling readSensors() which returns an array of length 8 (one number for each input)

Formula

The formula to translate voltage into Distance for Sharp 10-80cm analog sensors is:
screenshot_20190218_143359
"Make sure that the distance of the object being measured is within the distance range of the sensor. When the object is outside the valid sensor's distance range, the returned value should be discarded. You must be especially careful when the object is closer than it should be, as the returned value might be within the expected voltage range but is not meaningful." - https://www.phidgets.com/?tier=3&catid=5&pcid=3&prodid=70#Voltage_Ratio_Input

  • For now, invalid outputs are returned as "-1"
  • If the obstacle is closer than 10cm the value seems to be in the valid range most of the time, it's just not the right value which might not be the biggest issue since we would still detect the obstacle