Skip to content

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:

ParameterSymbolValue
Pendulum mass1 kg
Cart mass0.5 kg
Pendulum length1 m
Pendulum inertia0.0833 kg·m²
Gravity9.81 m/s²
Effective cart mass0.5 kg
Maximum force5 N
Maximum cart position1 m
Maximum cart velocity2 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 ( ) to upright ( ), while the cart remains within its bounds. Underactuation makes the problem challenging because the pendulum cannot be actuated directly and the control must exploit coupled dynamics.

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 ​

ParameterDefault valueUnitMeaning
t00sinitial time
g9.81m/s²gravitational acceleration
L1mlength of the pendulum
m1kgmass of the pendulum
mcart0.5kgmass of the cart
Fex_l-5Nlower bound of the force Fex on the cart
Fex_u5Nupper bound of the force Fex on the cart
x_l-1mlower bound of the position of the cart
x_u1mupper bound of the position of the cart
v_l-2m/slower bound of the velocity of the cart
v_u2m/supper bound of the velocity of the cart
tf_l0.1slower bound of the final time
x_t00minitial position of the cart
θ_t00radinitial angle of the pendulum
ω_t00rad/sinitial angular velocity of the pendulum
θ_tfπradfinal angle of the pendulum (upright)
ω_tf0rad/sfinal 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.

ModelingSchemeGridReference objectiveSolvesDistinct solutionsConfigurations agree
JuMP:trapeze5001.74396679481yes, within 7.0e-07
OptimalControl:trapeze5001.743965799181yes, within 1.6e-06