Cartpole

This project was initially my second-semester project for my AT Physics, Engineering, and Technology course during my senior year of high school. I got somewhat obsessed. It essentially taught me 70% of what I know about control theory. Here's the original report. To be clear, I know that there is a decent number of misunderstandings and plain incorrect statements here; I have continued learning (and discovered many bugs) since I wrote this.

Highlights

Here's MPC performing a swing-up maneuver. This was an early and somewhat flawed method for control, but it worked a little. It was my first ever MPC implementation, made with CasADi+IPOPT+HSL MA57. It was a very naive implementation - direct single shooting, no warmstarting, and complicated constraints - but it did kind of work. It discretized the one-second lookahead horizon into five 0.2s intervals, and solved in 0.02-0.07s, depending on the state. The solver ran on my 2019 macbook pro and communicated with the test setup via serial, adding some delay, and there were also a few bugs in the firmware I had yet to remove, but somehow it could deal with it.

and here's a complete demo of the swing up and down maneuvers with balancing at both stationary points. Recorded July 2023. Turn audio on for nice beep boop whoosh zoom robot noises! (this was before switching to a trinamic stepper driver; the A4988 I was using creates a very nostalgic robot noise) You can hear a key bug with my fixed-point math when balancing vertically - the minimum speed reachable by my stepper driving software was around 1 cm/s, which limited my ability to make ultra-fine adjustments.

moving forward

since that video, I've made the following changes:

here's the new CAD:

and here's the new top pivot. look at those nice PCBs. marvel in the glory of EAGLE, FlatCAM, and babysitting a cnc router to change out tiny tools for an hour.

with these changes, I'm hoping to implement swing-up and balancing for the double pendulum! However winter break just ended and I don't fancy having a two-meter-long contraption in my dorm room, so the physical setup has been left at home. Here are my todos for this project in the meantime: