Sensors

We used 5 short range and 1 long range infra-red sensors on the robot. 3 short range sensors were placed on the front and 2 were on the left side. The remaining long range sensor was placed on the right.

Figure 1: Top view of robot with sensor placement

 

Figure 2: Side view of robot with sensor placement

 

 

The reason for having 2 short range sensors on the left was so that our robot would be able to use the left wall to align itself since we chose to use a left wall-hugging strategy for our algorithm. Without 2 sensors on the left, we would have to get the robot to frequently turn left to use the front sensors for alignment, which is a waste of time.

The maximum threshold for the robot to align is when both sensors are at a maximum of 1 empty block distance away from a wall/obstacle.

Fig 3: Raw data from sensors

 

To calibrate the sensors, we linearised the voltage reading against the distance. We plotted 1/(Distance + R) against voltage, where R is a constant. For sensors 1-5, we observed that we could use a linear equation to fit the graph. We initially attempted to fit the graph of sensor 6 using a linear equation too, however we found that the readings calculated had a larger error margin compared to sensors 1-5. Hence, for sensor 6, we fit the graph using a logarithmic curve and found that the readings we calculated had a lower error margin.

Fig 4: Plotted graphs for each sensor with equation used to determine distance using voltage

 

In order to find the R value for each sensor, we used python to run a script to vary different R values from 0 to 20 in incremental steps of 0.01.

 

The code used to find the smallest R value is represented by the pseudocode below

x = [voltage array]
y = [distance array]
for i in range(1, 2001) {
R = i * 0.01
plot best fit line using 1/ (y+R) and x
use gradient and intercept to find new y value using old x value
find RMSE of new y value and old y value
store RMSE in array
}
find smallest RMSE value in array
get corresponding R value for smallest RMSE