Hey everyone,
I teach a summer robotics course at our high school for incoming freshman who are interested in engineering and programming, and/or want to be apart of the robotics team the following school year.
One of the topics I ALWAYS make sure to cover is implementing and designing a PID control loop. This is because I genuinely believe that going through this process is one of the best ways to help students get an intuitive understanding of the type of problem solving skills software engineers constantly utilize. Even though PID specifically won’t be used in the future by most of these kids (V5 motors kinda let you cheat), the software engineering process is generalized for use in any number of applications.
A few days ago, I got the idea to make a simulator app for testing control loops with a host of debugging and visualization tools, including a physical mockup, support for graphing position, velocity, and acceleration, that could potentially make my life during this year’s camp a whole lot easier. And well, I just about finished it. Here it is:
https://an-gg.github.io/PIDTrainer/
Boy, I sure wish I had one of these while I was learning.
There’s a visualization of the arm-motor-sensor setup in the bottom left.
And my favorite, the graph utility, which makes it oh so easy for students to see (and me to explain) the exact effect of each line of code in a given control loop. For example in this screenshot, you can see, immediately, what the derivative term does and how it helps reduce precession in the system:
You write your code in the editor on the right, in JavaScript. The API is just 5 methods, you can scroll down to see them. On first visit, the website will load a sample tuned PID loop so you can see how things work, but when you click run, the edits are stored in cache.
Now bear in mind, I’m not very good at making websites (in fact this was my first attempt) and this was a hack-together-in-a-day type of deal, so the source code is gonna be as ugly as it gets. If you find some sort of bug or want to add improvements or something like that, DM me. (I’m sure there’s a better way to do it with git; I’ll figure that out later)
Am sharing this in case others find this useful, whether you’re teaching or learning, or somewhere in between.