a line-following robot using p5.js early prototype
link https://setapolo.github.io/PaMa/Td-jGcvAWZc.html
This simulation is designed to visually replicate a line-following robot using p5.js. The core idea is to have a robot track a thick, sine-wave line by dynamically adjusting its trajectory based on sensor feedback. The system is organized into two main components: the Path class and the Robot class.
In the Path class, a series of points is generated to form a sine-wave pattern that is drawn with a thick stroke. This deliberate increase in line width ensures that the robot’s sensors can reliably detect the line, minimizing detection errors.
The Robot class simulates a robot equipped with left and right sensors. Each update cycle involves measuring the pixel brightness at sensor locations and comparing these values to a preset threshold. If a sensor detects a darker area (indicating the line), the algorithm computes an error value. Using proportional control, the robot then adjusts its angle incrementally based on this error before moving forward. The reduced speed helps in smoothing out the robot's movements.
Currently, the robot tends to oscillate or veer back and forth, indicating that the control strategy is still quite basic. While the proportional control approach provides a rudimentary line-following capability, it results in continuous corrections that prevent stable tracking.
Looking ahead, further challenges include refining the control algorithm by incorporating a full PID controller, implementing noise reduction and filtering on sensor data, and enhancing path estimation methods. These improvements aim to achieve smoother, more precise line tracking, moving beyond the current simple oscillatory behavior. This simulation serves as an educational step toward understanding the complexities involved in autonomous navigation and control in robotics.