Line Following

Published on 11 April 2024 at 08:27

Sensors

At the front of the robot, we attached a circuit board with 5 evenly spaced sensors facing the ground as shown. These sensors would return a boolean (True or False) if they detect the black tape. 

The goal of the robot is to only have the central sensor True as that means the robot is traveling along the tape.

The sensors are initialised by loading them into a list, then they are all set into input mode meaning they take an input from the outside, check for black.


Rotation

To rotate we check for when a sensor that is not the central one detects black, this means that the robot is no longer directly on the black line as the line is turning away from the direction it is going. 

To correct this we give each sensor a value (1 to 5) and take an average of the values of the sensors that are triggered 

This average is then outputed and can be used to determin how much the robot needs to rotate to return back ontop of the line.

Here we see that the average is compared to the value of the middle line (3) and depending on the difference the speed of the motors is changed. 
If only the 3rd (middle) sensor is triggered the average would be 3 which would result in error_val being 0 meaning the robot does not rotate at all, as it is already following the line.


Iteritive testing

A problem we encountered was that the turning of the robot was too slow, meaning it could not turn fast enough before it went completely off the black line, which was not wanted. To fix this, we tested several k_p values, the k_p value represents the rate of the turning.

This represents the robots movement with a lower k_p value, the movement is smoother (has a lower frequency) but less reactive to sharp corner or turns

This represents the robot with a higher k_p value, the movement is more jagged (higher frequency) but that in turn makes it more reactive to turns and corners

Furthermore, we had to lower the speed of the robot for it was not able turn fast enough on our practice cource. Lowering the speed allowed it to turn for longer resulting in it staying on the line at all times.
At the end of our testing a speed of 45% and a k_p value of 0.35 allowed the robot to navigate the entire practice cource. These values can be changed easily to adapt to sharper turns or try to make a robot faster in a less tasking cource. 


Add comment

Comments

There are no comments yet.