Optimal trajectory generation for the cartpole swing-up problem, formulated as a nonlinear program (NLP) in MATLAB.
Written by Luke Raus for Advanced Algorithms at Olin College.
To dig deeper, read the full writeup PDF or open the code! There are lots of comments :)
This project runs in MATLAB and uses the fmincon NLP solver included in the Optimization Toolbox.
example_swingup_optimization.m contains a ready-to-run example problem for testing the implementation.
This script calls the generate_swingup_trajectory function to perform the actual optimization, and then validates this solution using the simulate_cartpole function.
The optimization returns open-loop control sequences and associated state trajectories as functions of time:
Enjoy!
