First, some pending matters from previous weeks:
The software was divided into: library back-end, robot modelling, app front-end and firmware.
Everything we code for LibScoutR can be found in the following link: ▪https://github.com/mizidoro/LibScoutR
Class diagram for the objects that model the robot:
Class diagram
The movement of the robot was coded by @Matheus Izidoro in Arduino and will be interfaced to the raspberry, where all the logic to where to move sits.
The line following code uses a PID algorithm to move the robot without any abrupt turns, this way we can have better readings of the camera.
The firmware execution is basically divided into two subroutines: Setup and Loop.
Setup subroutine is responsible to get all the sensors, motor interfaces and serial communication up for the robot to be able to move around the library, acquire positioning data and communicate with the Raspberry.
Loop is the main subroutine that will be running in almost the whole time. The Loop subroutine will be waiting for Raspberry to send commands then executing the actions that achieve the command desired result. The following flowchart describes how the firmware behavior in runtime:
As we want the robot to follow the lines the most accurate possible way allowing the cameras to get better images of the books borders, we needed to implement a kind of control that can correct the position of the robot proportionally to its difference to black lines, summed over time and responding the fastest as possible. That's what PID controllers do. PID stands for proportional, integral and derivative control.