-
Notifications
You must be signed in to change notification settings - Fork 0
IR distance sensor
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.
Details can be found at: https://www.phidgets.com/?tier=3&catid=5&pcid=3&prodid=70#Voltage_Ratio_Input
- IR Sensor: Sharp GP2D12 - 10-80cm Analog (non-RoHS)
- 1101 - IR Distance Adapter - functions as interface between Sharp IR distance sensors and Analog input of Phidget board
- Phidget board specs can be found at: https://www.phidgets.com/?tier=3&catid=2&pcid=1&prodid=1021
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°
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)
The formula to translate voltage into Distance for Sharp 10-80cm analog sensors is:
"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