YANE-Framework Tutorial 1.1.0

# Mathematical Setting of the Example

The "Inverted Pendulum on a Cart" problem is given by the differential equation

with parameters , , and . Here, denotes the angle of the pendulum, the angular velocity of the pendulum, the position and the velocity of the cart. Within this system the second equation is numerically problematic for an adaptive differential equation solver:

Hence, this differential equation causes a reduction of the order of consistence of the differential equation solver to at points where the right hand side is not differentiable. Moreover, stability of the solver is lost at the discontinuity points.

Since we are going to use a receding horizon controller, i.e. a sample--and--hold strategy for the contol , we do not have to modify the term concerning the control since within the receding horizon controller setting the points of discontinuity are known in advance and can be added to the discretization grid. Hence, the order of consistence is preserved although is discontinuous.

For both other terms we use smooth approximations which allow us to mimic the behaviour of the original equation but retain the oder of consistence of the differential equation solver:

The dynamic of the system is implemented in the method InvertedPendulum::odeFunction.

The goal for this example is to stabilize the pendulum in the upright position using a NMPC control law. The upright unstable equilibria are given by the set . To develop a cost functional we make use of the geometry of the dynamic of the system. To stabilize an arbitrary point of this set, we consider the cost functional

where the stage costs are given by

and the terminal cost is defined via

Within the implementation, you will find these functions in the methods InvertedPendulum::objectiveFunction, InvertedPendulum::pointcostFunction and InvertedPendulum::objectiveWeight.

Moreover, we impose constraints on the state and the control vectors by defining

which can be found in the constructor method InvertedPendulum::InvertedPendulum.

Note that every point in the set is treated equally by this cost functional. Hence, the outcome of the receding horizon control problem is depending on the initial value of the system, but also on the optimization horizon . While the first dependency is due to the periodicity of the cost functional, the latter one follows from possible changes of the optimum if different horizon lengths are considered.