Cart pendulum
- 4 state
- 1 control
- 2 variable
- Mayer cost
- free final time
- 2 state box
- 1 control box
- 1 variable box
- 5 boundary
- OptimalControl valid
- JuMP valid
The cart-pole swing-up problem is a classical benchmark in underactuated optimal control. It consists of swinging a pendulum mounted on a cart from its downward equilibrium to the upright position while controlling the horizontal motion of the cart. The objective is to reach the upright position in minimum time, subject to cart and pendulum constraints. This problem is widely used to test trajectory optimisation and control algorithms for underactuated systems.
Mathematical formulation
The problem can be stated as
The auxiliary functions defining the dynamics are
These represent the intermediate computations:
The function
computes the pendulum’s angular acceleration due to cart acceleration and gravity. The variable
represents the acceleration of the pendulum’s centre of gravity. The variable
is the net force vector acting on the pendulum. The variable
combines pendulum and cart dynamics to determine the net horizontal force for the system.
The system parameters are:
| Parameter | Symbol | Value |
|---|---|---|
| Pendulum mass | 1 kg | |
| Cart mass | 0.5 kg | |
| Pendulum length | 1 m | |
| Pendulum inertia | 0.0833 kg·m² | |
| Gravity | 9.81 m/s² | |
| Effective cart mass | 0.5 kg | |
| Maximum force | 5 N | |
| Maximum cart position | 1 m | |
| Maximum cart velocity | 2 m/s |
Qualitative behaviour
The optimal control trajectory typically follows a bang–singular–bang pattern:
Maximum force is initially applied to accelerate the pendulum and cart (bang arc).
A singular arc follows, balancing the pendulum energy to reach the upright position.
Maximum force is applied again to stabilise and position the cart.
The pendulum angle evolves from downward (
Characteristics
Nonlinear, underactuated dynamics.
Serves as a benchmark for trajectory optimisation and control of underactuated systems.
References
Åström, K. J., & Furuta, K. (2000). Swinging up a pendulum by energy control. Automatica, 36(2), 287–295. doi.org/10.1016/S0005-1098(99)00140-5 This seminal paper introduces energy-based control strategies for swinging up an inverted pendulum, emphasising the critical role of the pivot's acceleration relative to gravity. It provides foundational insights into the challenges of controlling underactuated systems.
Vanroye, L., Sathya, A., De Schutter, J., & Decré, W. (2023). FATROP: A Fast Constrained Optimal Control Problem Solver for Robot Trajectory Optimisation and Control. arXiv preprint arXiv:2303.16746. arxiv.org/abs/2303.16746 This paper presents FATROP, a solver designed to efficiently handle constrained optimal control problems, including the cart-pole swing-up. It demonstrates how modern numerical methods can compute minimum-time trajectories while respecting state and control constraints, making it highly relevant for implementing the problem in practice.
Source code files for the Cart-Pendulum problem. This repository contains the implementation of the cart-pendulum problem used in the FATROP benchmarks, providing practical examples of state, control, and dynamics formulations.
Tedrake, R. (2024). Underactuated Robotics: Algorithms for Walking, Running, Swimming, Flying, and Manipulation (Course Notes for MIT 6.832). underactuated.mit.edu/ This comprehensive resource offers detailed discussions on the cart-pole system, including its dynamics, control strategies, and applications in robotics. It serves as an excellent reference for understanding the theoretical and practical aspects of underactuated systems.
Parameters
| Parameter | Default value | Unit | Meaning |
|---|---|---|---|
t0 | 0 | s | initial time |
g | 9.81 | m/s² | gravitational acceleration |
L | 1 | m | length of the pendulum |
m | 1 | kg | mass of the pendulum |
mcart | 0.5 | kg | mass of the cart |
Fex_l | -5 | N | lower bound of the force Fex on the cart |
Fex_u | 5 | N | upper bound of the force Fex on the cart |
x_l | -1 | m | lower bound of the position of the cart |
x_u | 1 | m | upper bound of the position of the cart |
v_l | -2 | m/s | lower bound of the velocity of the cart |
v_u | 2 | m/s | upper bound of the velocity of the cart |
tf_l | 0.1 | s | lower bound of the final time |
x_t0 | 0 | m | initial position of the cart |
θ_t0 | 0 | rad | initial angle of the pendulum |
ω_t0 | 0 | rad/s | initial angular velocity of the pendulum |
θ_tf | π | rad | final angle of the pendulum (upright) |
ω_tf | 0 | rad/s | final angular velocity of the pendulum |
Every modeling takes other values with the keyword parameters, merged with these: cart_pendulum(backend; parameters=(t0=…,)).
Reference objective
The best objective among the solves that converged, in each modeling, on the default grid of the modeling: the modelings are independent, each has its own reference. See how the references are computed.
| Modeling | Scheme | Grid | Reference objective | Solves | Distinct solutions | Configurations agree |
|---|---|---|---|---|---|---|
| JuMP | :trapeze | 500 | 1.743966794 | 8 | 1 | yes, within 7.0e-07 |
| OptimalControl | :trapeze | 500 | 1.743965799 | 18 | 1 | yes, within 1.6e-06 |