Labels

Friday, March 29, 2013

Distance sensor data gathering

So I was able to start gathering sensor data last night.  I wanted to start gathering information on the two distance sensors in order to be able to calibrate the system.  I have enough errors propagating around, I just wanted to understand a little more about the IR and Ultrasonic Distance Sensors themselves and how they behave and how well they measure distance.
In the picture below, you can see the IR distance sensor (GP2D12).  I was able to modify the Arduino code to give me values output on the LCD display.  My measurements were from the front of the sensor housing, that means that I will need to add the offset from the front of the sensor housing to the center of the servo rotation point to get an accurate reading on the measurements.



For the ultrasonic distance sensor (HC-SR04) the measurements will be the same.  I will measure from the front of the sensor housing to the target and will add the distance from the front of the sensor housing to the center of the servo rotation point.



Wires: now that I have everything hooked up on the Lexan plate, the wire jumble on the top of the Arduino breadboard is pretty much a mess.  I am thinking of getting a proto board and putting headers on it in order to not have the jumble on top.  You can see what I mean by the picture below.



When I took the values from the IR distance sensor, I was surprised to notice how much the value changed with each sample.  The measurements are as follows:

Distance Measure1 Measure2 Measure3
2 7.24 7.22 7.26
2.25 6.76 6.72 6.72
2.5 6.84 6.91 6.82
2.75 7.54 7.64 7.68
3 8.23 8.66 8.57
3.25 9.23 9.18 9.15
3.5 9.97 9.97 9.36
3.75 10.95 10.92 10.85
4 11.39 11.32 11.46
4.25 12.28 12.24 12.24
4.5 12.84 13.05 12.84
4.75 13.72 13.72 13.72
5 14.39 14.29 14.24
5.5 15.67 15.73 15.67
5.75 16.63 16.26 16.5
6 17.08 17.14 17.08
6.25 17.96 17.89 17.89
6.5 18.47 18.4 18.18
6.75 19.01 18.7 19.01
7 19.9 20.15 19.98
7.25 20.33 20.24 20.33
7.5 21.52 21.42 21.42
7.75 21.81 21.71 21.9
8 23.26 23.04 23.04
9 25.9 25.51 26.03
10 28.63 28.79 29.11
11 32.89 32.29 33.5
12 36.64 36.4 35.92
13 35.92 31.92 36.4
14 40.65 40.65 40.65


Even though I took three measurements at each distance, the values pretty much vary pretty wildly.  A simplified graph of these measurements are as follows:

Actually, I should probably try and swap the x and y axis.  The x axis is the distance and the y axis is the measured values.  True to the data sheet, values that approach around 2 inches from the front of the sensor will change up and values over about 12 inches seem to start varying wildly.  In between, from 2 to 12 inches, the values seem to be steady and are almost linear given the formula in the sampling routine.  The values that return from the Ultrasonic sensor seem to vary even more crazily (see video below).

What I am learning from this is that I might have to rethink how the robot will follow the wall with the sensor data that I am seeing.