I began week 6 by planning different ways that I could make a robot follow a line. The most obvious was to have the light sensor measure colour, and steer different directions based upon which colour it was detecting (Black or White). However, after some experimentation, I could not find a way in which this worked successfully. My second idea was to use the built-in ‘Reflected Light Intensity’ measurements that could be made by the robot. So I began creating a program utilizing this idea. By myself, as usual (despite asking for some of the others to help me numerous times).
The problem I encountered straight away was that the measurements taken seemed to range wildly. The returned value on the white paper seemed to vary between 40 when sensor was in the robot’s shadow, and 70 when the robot was in direct light. The value on the black line was consistently around 8 or so. The value on the edge of the line (the important measurement) varied between 20 and 40 (again based on whether it was in the robots shadow or not). The basic idea for the program was to make the robot turn one direction (say right) when the light intensity matched white, and the other direction (left) when the robot’s reading matched black. When the reading was that of the edge of the line, the robot would continue in a straight line. Having no idea how to implement this smoothly, I looked for similar programs on online forums. One idea (from this video) was to connect the readings directly to the speed of each wheel motor. However, this required some modification of values, as the current values meant that the robot drove way to quickly for it to measure consistently. So following the program demonstrated in the video, I added the required mathematical processes (inverting and halving the values to accommodate for our robots motors (which due to the design, are backwards)) and the robot now seems to follow the line. The first iteration of this code is pictured below.
The custom block at the start is a calibration module which calibrates the light sensors values to be 0 on black, and ~100 on white. Unfortunately, this needs to be done every time the program is run. The Calibration program is pictured below.