Avatar The Society of Robotics and Automation is a society for VJTI students. As the name suggests, we deal with Robotics, Machine Vision and Automation

Rotary Inverted Pendulum

Implement MPC using LQR on rotary inverted pendulum in simulation and hardware



Control systems form the basis for ensuring that every automatic system performs its ordained task accurately, efficiently and quickly (optimally) despite being subjected to varying environmental conditions. In this project, we will implement MPC(Model Predictive control) on Rotary Inverted Pendulum system using LQR(Linear Quadratic Regulator) as an optimizer. The mechanical structure of inverted pendulum is based on two factors, the actuation method and degree of freedom (DOF) of the system. The actuation methods are linear and rotary. The simplest controllable structure of inverted pendulum system has two DOF, one for the base position and other for the pendulum angle. Rotary inverted pendulum system is essentially a combination of three elements: a motor, an arm and a pendulum. In this system one end of the arm is connected to the shaft of the motor and pendulum is attached to other end of the arm by a pin joint that is allowed to rotate freely in the vertical plane.


An inverted pendulum is a pendulum that has its Centre of mass above its pivot point. It is unstable and without additional help will fall over. It can be suspended stably in this inverted position by using a control system to monitor the angle of the pole and move the pivot point horizontally back under the Centre of mass when it starts to fall over, keeping it balanced. The inverted pendulum is a classic problem in dynamics and control theory and is used as a benchmark for testing control strategies. It is often implemented with the pivot point mounted on a cart that can move horizontally under control of an electronic servo system as shown in the photo; this is called a cart and pole apparatus. The Pendulum is made stable by supplying minimum constant current at high frequency which just makes it oscillate at its position.

How to stabilize the inverted pendulum?

An ordinary pendulum has negative feedback when displaced, so it is stable. An inverted pendulum has positive feedback, so it is unstable. The only way to maintain its balance is by moving the pivot point. How much to move the pivot point to maintain stability is the classical problem in control theory. Simply moving it in the direction of imbalance does not work. The correct solution depends not only on the direction and magnitude of imbalance; it also depends on the pendulum’s velocity that has been generated by the imbalance and it also depends on the velocity with which the pivot can be moved.

Model Predictive Control (MPC)

Model predictive control (MPC) is an advanced method of process control that is used to control a process while satisfying a set of constraints. The models used in MPC are generally intended to represent the behavior of complex and simple dynamical systems. The additional complexity of the MPC control algorithm is not generally needed to provide adequate control of simple systems, which are often controlled well by generic PID controllers. Model predictive control is a multi-variable control algorithm that uses:

  • an internal dynamic model of the process
  • a cost function over the receding horizon
  • an optimization algorithm minimizing the cost function


    To validate the mathematical model, numerical simulation of nonlinear model of the system is performed via MATLAB Simulink. As the structure consists of the pendulum with mass, the motor ,the rotor along with the base. We simulate these individual components to obtain the output graph associated with the components shows their behavior .The horizontal and vertical plane are used geometrically to visualize the position of pendulum and the arms. These are then coupled to form the device whose planar output is then observed to be as same as the rotary inverted pendulum. This helps us in understanding the lag associated along with the correct dimensions of the components.

Git Repository

Rotary Inverted Pendulum