29
DEMO Pendulum Fuzzy + Classical Control

Pendulum demo fuzzy classic

Embed Size (px)

Citation preview

DEMO

PendulumFuzzy + Classical Control

Exercises

DEMO:Java-Based PD Control of a Two-Link Arm at:http://www.ai.sri.com/~connolly/robotics/control-demo.html

Tutorials

http://www.ee.usyd.edu.au/tutorials_online/matlab/index.html

Fuzzy Control (Mamdani)

de\e NL NS ZE PS PLNL PL PL PS ZE NSNS PL PS PS ZE NSZE PL PS ZE NS NLPS PS ZE NS NS NLPL ZE NS NS NL NL

0ZENL NS PS PL

Example of membership functions

Disturbance

y(t)r(t) e(t)Fuzzy

controllerDynamic systemu(t)

Command OutputError

-

Control

d(t)

Example: Inverted pendulumThe problem is to balance a pole on a mobile platform that can move in only two directions, to the left or to the right. • define (subjectively) the speed variable of the platform by specifying the membership functions for the fuzzy_sets negative high (cyan) negative low (green) zero (red) positive low (blue)

positive high (magenta) The same is done for the angle between the platform and the pendulum and the angular velocity of this angle:

Example: Inverted pendulumwe assume that in the beginning the pole is in a nearly upright position so that an angle greater than, say, 45 degrees in any direction can - by definition - never occur.

we will set up some rules that we wish to apply in certain situations. Consider for example that the pole is in the upright position (angle is zero) and it does not move (angular velocity is zero). Obviously this is the desired situation, and therefore we don't have to do anything (speed is zero). Let's consider another case: the pole is in upright position as before but is in motion at low velocity in positive direction. Naturally we would have to compensate the pole's movement by moving the platform in the same direction at low speed.

Rule 1: If angle is zero and angular velocity is zero then speed shall be zero. Rule 2: If angle is zero and angular velocity is pos. low then speed shall be pos. low.

We can summarize all applicable rules in a table:

| angle | speed | NH NL Z PL PH ----------+------------------------------ v NH | NH e NL | NL Z l Z | NH NL Z PL PH o PL | Z PL c PH | PH

where NH is a (usual) abbreviation for negative high, NL for negative low etc.

Example: Inverted pendulumMamdani controller

Let's apply the ruleif angle is zero and angular velocity is zero then speed is zero to the values that we've selected.

Example: Inverted pendulum

For an actual angle

Example: Inverted pendulumRule 1: If angle is zero and angular velocity is zero then speed shall be zero.

Example: Inverted pendulumOnly four rules they fire and we overlap them into one single result.

The result of • Rule 1: if angle is zero and angular velocity is zero

then speed is zero

• Rule 4: if angle is positive low and angular velocity is negative low then speed is zero

• Rule 3: if angle is positive low and angular velocity is zero then speed is positive low

• Rule 2: if angle is zero and angular velocity is negative low then speed is negative low

is:

is:

is:

is:

Example: Inverted pendulum

These four results overlapped yield the overall result:

The result of the fuzzy controller so far is a fuzzy set (of speed), so we have to choose one representative value as the final output. There are several heuristic methods (defuzzification methods), one of them is e.g. to take the center of gravity of the fuzzy set:

The whole procedure is called Mamdani controller

Fuzzy Logic Control

• A Fuzzy Logic Controller - - usually consists of:

• (i) A fuzzification unit which maps measured inputs of crisp value into fuzzy linguistic values to be used by a fuzzy reasoning mechanism.

• (ii) A knowledge base (KB) which is the collection of expert control knowledge required to achieve the control objective.

• (iii) A fuzzy reasoning mechanism that performs various fuzzy logic operations to infer the control action for the given fuzzy inputs.

• (iv) A defuzzification unit which converts the inferred fuzzy control action into the required crisp control values to be entered into the system process.

Demo

Fuzzy control of a pendulum problem

http://www.erudit.de/erudit/demos/cartball/index.htm

Try an on-line demonstration of the FuzzyCLIPS system, acting as a fuzzy shower control at http://ai.iit.nrc.ca/fuzzy/shower/title.html

Analysis of a Pendulum Problem

after Jan Jantzen

http://www.erudit.de/erudit/demos/cartball/index.htm

Inverted pendulum

• Balancing an inverted pendulum is a good demonstration problem, because it is difficult, swift, and spectacular.

• It is a standard problem used in many classrooms and commercial software packages.

• This version is not the usual pole balancer, but rather a steel ball rolling on a pair of arched tracks.

• The objective of the demo is to present the basic concepts of fuzzy control, in an easily accessible manner.

• The ball can be balanced using conventional techniques for comparison.

• Fuzzy control is different in the sense that the control strategy is a set of rules rather than mathematical equations.

• The cart moves on a pair of tracks horizontally mounted on a heavy support.

• The control objective is to balance the ball on the top of the arc and at the same time place the cart in a desired position.

• We will analyze the ball and cart separately and apply the basic physical equations related to the vertical reaction force Y and the horizontal reaction force K.

• Friction forces are neglected.

The problem

They are nonlinear due to the trigonometric functions, and they are coupled such that occurs on the left side of (A-6) and on the right side of (A-7); the situation is the reverse in the case of .

y

The model can be linearized around the origin. In order to avoid errors we will linearize (A-6)-(A-7) rather than the nonlinear state-space equations. Introduce the following approximations to the trigonometric functions

With the data in Table 1 the actual values of the constants are:

a = -1.34

b = 0.301

c = 14.3

D = -0.386

State feedback control

Notice that the control signal is now the voltage U rather than the force F, for convenience.

The block diagram shows how the four states are fed back into the controller, which combines them linearly.

• This is a state-space form as well, but of the closed-loop system.

• Stability is guaranteed if none of the eigenvalues of the closed-loop system matrix A+BK are in the right half of the complex plane (all k’s must be positive).

• Jorgensen found (in 1974) by trial and error the following values satisfactory: K= [5,5,120,8]

• Using optimization techniques (Linear Quadratic Regulator – Matlab Toolbox, will give a fast and stable controller with little overshoot from

K= [24,24,162,44]

Cascade Control

• It is quite intuitive to divide the system into two subsystems, one for the ball, another for the cart; – it makes it more manageable.

• The ball seems to require faster control reaction than the positioning of the cart, – and it is standard practice to have a fast inner loop,

• in this case a PD controller reacting on the ball angle makes it reach its reference ,

– which takes commands from a slower outer loop, • in this case a PD controller reacting on the cart position

r

System Block Diagram

Fuzzy control of a pendulum problem

Fuzzy control Demo

The default membership functions are triangular.

Examples of membership functions are

• MVL (moves left),

• SST (stands still), and

• MVR (moves right).

Graph

Show Charts

When enabled the following Plots show up after starting a new simulation:

- cart position y and cart control signal U1 against time

- cart phase plot, g1*y  against g2*dy

- ball angle and ball control signal U2 against time.

- ball phase plot, g3* against g4*

- ball control signal U1, cart control signal U2, and U1+U2 against time

d