lunduniversity.lu.se

# Furuta Pendulum Project

## Project: Swingup and Control of a Simulated Furuta Pendulum

In this project you will develop a Java-based control system for a rotating pendulum, also known as a Furuta pendulum. A Java simulation model and 3D animation of the physical process is provided to you. Your task is to develop a feedback controller that can operate in two different modes: control in the lower position and control in the upper (inverted) position. In either mode, it should be possible to specify a reference value for the arm angle. The control system should also be able to perform a swingup from the lower to the upper position using an algorithm that is provided to you. Relevant controller parameters and plots of the measurement and control signals should be accessible through a GUI developed by you. This project is similar in spirit to the computer exercises where you also used Java to control a simulated process.

## Detailed Description of the Project

#### The Simulated Furuta Pendulum

The Furuta pendulum process [1,2,3] consists of a pendulum hanging freely at the end of a rotating arm, which in turn can be accelerated by a motor. Its dynamics is highly nonlinear; using first-principles modeling it can be described as a fourth-order nonlinear differential equation [2]. The four state variables are the pendulum angle (θ = theta) and its derivative, and the arm angle (φ = phi) and its derivative, see the figure to the right. The angles (θφ) = (0, 0) correspond to the pendulum being in the upper position and the arm being directed towards you in the 3D animation. Based on the nonlinear equations of motion, a simulation model has been constructed in Java. It internally operates with a sampling period of 1 ms and integrates the nonlinear equations using forward differences. Note that the simulated angles do not have any upper or lower bounds – if the pendulum or the arm rotates multiple times in one direction, its angle can reach ±2π, ±4π, etc. The control signal is unitless and limited to the interval [–1, 1].

The Furuta pendulum simulation and animation can be created and accessed through the class SimFuturaPendulum, with the following Java interface:

` // Class for simulating and animating the Furuta pendulum (available in furuta.jar) public class SimFurutaPendulum {    // Creates and starts a new process simulation, with initial    // pendulum angle theta0 and arm angle phi0 (in radians)    public SimFurutaPendulum(double theta0, double phi0);    // Returns the pendulum angle (in radians)    public double getThetaAngle();    // Returns the arm angle (in radians)    public double getPhiAngle();    // Sets the control signal (unitless, between -1.0 and +1.0)    public void setControlSignal(double u);} `

#### Control Principles

The continuous-time process dynamics can be linearized in a stationary point to yield a fourth-order linear state-space model. The upper position linear model is unstable, while the lower position model is marginally stable. Both models contain an integrator that correspond to the arm angle dynamics. You should design a sampled-data state feedback controller law u(k) = –L x(k) for each of the two cases. The sampling interval h will be an important design parameter. The Matlab file `furuta_model.m` below sets up a linear model dx/dt = Ax + Bu for each of the cases. Depending on your control theory background, you have two choices for the sampled control design:

1. Pole placement.  In continuous time, two of the poles should be chosen to be well-dampled and have about the same speed as the open-loop pendulum poles (≈ 6 rad/s). Of the remaining two poles, one could be made quite fast (> 20 rad/s) and one quite slow (< 2 rad/s). Sample the A and B matrices into discrete time using Matlab's `c2d` and translate the desired pole location into discrete time as well. Then use `place `to calculate the state feedback vector L.
2. Linear-quadratic regulator.  Use the Matlab command `lqrd` to directly calculate an "optimal" sampled state feedback vector based on the continuous-time system. Put a large penalty on the pendulum angle and a smaller one on the arm angle. You may also need to add some penalty on the angle derivaties to reduce oscillations. Tune the Q and R design matrices to give closed-loop poles that are of similar magnitudes as hinted to above.

The time derivatives of θ and φ need to be somehow obtained from the sampled measurements. The simplest option is to use backward differences to approximate the derivaties. A much more advanced option (in terms of implementation complexity) is to design two state observers: one for the lower position and one for the upper position. You can try this option if time permits.

The swingup algorithm you will use is based on the article [3], but modified to include a damping term involving the arm angle velocity:

u = k1sgn [ (cos(θ) + (dθ/dt)2 / 2ω02 –  1) dθ/dtcos(θ) ] – k2 dφ/dt

Here, ω= 6.7 rad/s, k1 determines the magnitude of the control signal to be used, and k2  is a damping factor to prevent the arm from rotating too fast. Both of these parameters need to be tuned and should be selected somewhere in the range [0, 1]. Start with, e.g., k1  = 1 and k2  = 0 and experiment from there.

#### Program Specification

1. The program should have a graphical user interface (GUI), where it is possible to switch the controller between three different modes: OFF (the starting mode), LOWER (control with the pendulum in the lower position) and UPPER (control with the pendulum in the upper position). There should also be a QUIT button for ending the program.
2. In the LOWER and UPPER modes, it should be possible to specify a reference value for the arm angle φ.
3. The GUI should contain plots of the measurement signals and the arm angle reference as well as the control signal.
4. When switching from OFF or LOWER to the UPPER mode, a swingup should be performed using the algorithm provided above. When the pendulum is close enough to the top, the upper regulator should be activated.
5. When switching from UPPER to LOWER mode, the control signal should be turned off, letting the pendulum fall down by itself. When the pendulum is close enough to the bottom and also dθ/dt is small enough, the lower regulator should be activated.
6. The regulators should function even if the arm or pendulum have rotated multiple times. The current arm reference angle should be interpreted as "zero" by the state feedback law, and the actual arm angle can then deviate ±π  from this value. In the lower mode, the downright pendulum position should be interpreted as "zero" by the state feedback and the actual pendulum angle can then deviate ±π  from this value. The same holds for the upper mode, where the upright pendulum position should be interpreted as "zero".
7. In the GUI it should be possible to specify values for the swingup parameters k1 and k2 and threshold values for the angles and angular velocities that determine the mode switches. (This will make it easier for you to fine-tune the mode switching and swingup schemes.)

## Java and Matlab Code

• furuta.jar, Test.java – Java archive for pendulum simulator and 3D animation, with minimal test program
• furuta_model.m – Matlab code for defining linear state-space models (based on [2])
• regler.jar – Java archive for plotters, etc. (same as used in the exercises)

## Project Report

You should write a final report according to the original project instructions. (No suggested solution is needed.)

## References

[1]  Gäfvert, M. (1998): "Modelling the Furuta Pendulum." Technical Report TFRT-7574, Department of Automatic Control, Lund University, Sweden.

[2] Åkesson, J. (1999): "Safe Reference Following on the Inverted Pendulum." Master's Thesis TFRT-7587, Department of Automatic Control, Lund University, Sweden.

[3]  Åström, K. J., & Furuta, K. (2000). "Swinging up a Pendulum by Energy Control." Automatica, 36(2), 278-285.

Page Manager: