This repository contains an adaptive PID controller for LEGO SPIKE Prime robots, used in FIRST LEGO League (FLL).
| File | Description |
|---|---|
line_following_pid.py |
Main PID script for line following |
auto_tuning_line_following_PID.py |
Auto-tuning version for better corrections |
plot_pid.py |
Graphs PID values to analyze performance |
pid_log.txt |
Stores real-time PID data from the robot |
diagrams/ |
Flowcharts and explanations of PID behavior |
README.md |
Project documentation |
LICENSE |
Open-source license |
- Glossary: Learn about key terms like encoders, feedback loops, and auto-tuning.
- PID Theory: Understand how PID control works and how to tune it.
- Upload
line_following_pid.pyto your SPIKE Prime hub. - Run the script and let the robot follow the line.
- Retrieve
pid_log.txtand analyze it withplot_pid.py.
Run:
python plot_pid.pyThis will generate graphs of error, correction, and PID values over time.
Edit these values in line_following_pid.py:
P_BASE = 0.5 # Proportional gain (higher = faster response)
I_BASE = 0.001 # Integral gain (higher = fixes long-term drift)
D_BASE = 0.3 # Derivative gain (higher = smooths movement)Tune them based on logged performance data.
This project is licensed under the MIT License.