Double Inverted Pendulum on a Cart
Example
DoubleInvertedPendulum/
Where you can find this pendulum
A. Bogdanov, “Optimal control of a double inverted pendulum on a cart,” Oregon Health and Science University, Tech. Rep. CSE-04-006, OGI School of Science and Engineering, Beaverton, OR, 2004.
Problem Description
Swing-up control of a double inverted pendulum on a cart is a benchmark problem for NMPC algorithms due to its high nonlinearity. The pendulum we want to swing up is:
-
The state vector of the system is x = [\theta_0,\dot{\theta}_0 , \theta_1 ,\dot{\theta}_1 ,\theta_2 ,\dot{\theta}_2]^{T}, where \theta_0 is the displacement of the cart, and where \theta_1, \theta_2 are the pendulum angles. The displacement is bounded by -0.1 \leq \theta_0 \leq 0.1.
-
The control force u is constrained with |u|\leq 10.
-
The system is modeled as D(\theta)\ddot{\theta}+C(\theta,\dot{\theta})\dot{\theta}+G(\theta)=Hu with \theta=[\theta_0,\theta_1,\theta_2]^T.
The task is to swing up the pendulum from the initial state x_0 = [0,\pi,\pi,0,0,0]^{T}.
OCP in ParNMPC
-
The state constraints are softened by introducing a slack variable s\geq 0 with a quadratic penalty on s.
-
A terminal penalty function is imposed to swing up the pendulum.
Closed-loop Simulation using ParNMPC
Step 1. NMPC problem formulation
See Workflow of ParNMPC > NMPC Problem Formulation.
Example
DoubleInvertedPendulum/NMPC_Problem_Formulation.m
Step 2. Code generation and deployment in Simulink
See Workflow of ParNMPC > Code Generation and Deployment > Simulink.
-
Code generation
Example
DoubleInvertedPendulum/Simu_Simulink_Setup.m
-
Deployment
Example
DoubleInvertedPendulum/Simu_Simulink.slx