Double pendulum on a cart (dpc) simulation model
pip install scipy pip install numpy pip install sympy pip install matplotlib
- Matlab symbolic toolbox
- Symbolic package
Load symbolic package before running the code
pkg load symbolic
Executing the simulation
dpc_lagrange to generate the system dynamics function. The generated function will be created under the name
Then you can run
dpc_simulate to simulate and draw the animation.
You can also modify the parameters at the top of the simulation file.
In the subdirectory is a simplified version of the program where the parameters are hardcoded into the system equations. In this way the equations fit on a single page (for the web). This version is presented in the blog post. However, here we can not change the parameters easily in the simulation but have solve the Euler-Lagrange equations again with the modified parameters.
This version can be run using the
dpc_simple_simulate script (no code generation for the dynamics required).