1 / 79

Fuzzy Logic: Practical Examples and Applications

Learn how to combine conflicting pieces of advice using fuzzy logic. Explore linguistic examples of operations on the same variable and discover practical applications in robotics.

Download Presentation

Fuzzy Logic: Practical Examples and Applications

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. A great man who created a completenew mathematics with many practical applications.

  2. Fuzzy Logic practical easy examples

  3. How to combine various, even conflicting pieces of advise? Linguistic

  4. Examples of Operations on the same variable A B A  B A  B A

  5. Example 1:Using Fuzzy Logic for a Line Following Robot

  6. Mechanical Design of a very inexpensive Line-Following Robot In our example below: Line white, background black

  7. Basic Motions of a Differential Drive robot Reminder = Braitenberg Vehicles

  8. Calculations for input rules

  9. Structure of this type of the system: Two Levels, various membership functions in each, shared MIN MIN Defuzzifier of the “sum” MIN Fuzzified inputs MIN MIN Fuzzy values of combined first level groups One input Defuzzifier MAX MIN MIN Level of input membership functions Level of output membership functions Reminder = general simple scheme for Fuzzy Logic

  10. Input Membership Functions Characteristics of two identical sensors We have three membership functions: Black, Gray and White

  11. Sample Fuzzy Rule Base – for input rules • Here is an example how you can create your own rules for a robot of your choice. • This table decides what to do for every combination of data from both input sensors SR X = don’t know = undetermined The system will “learn” values for these don’knows. • Descriptions such as this table: • Generalize Truth Table • Generalize Karnaugh Map

  12. Output Membership Function • Output of the controller can be negative or positive

  13. This slide explains how to apply rules for left sensor We calculate for given measurement for the left sensor For black membership function white black gray For white membership function black Reading the data from left sensor

  14. How to apply input rules?

  15. How to calculate output? • Here are some examples of rule calculations This calculated 0.7 for SL This calculated 0.2 for F Right sensor Left sensor

  16. Calculations for output rules

  17. How to calculate Output Membership Function Calculated in previous slide 0.7 for SL Calculated similarly for SR 0.2 for F Note: this is some kind of weighted sum This is one example of defuzzification that calculates the speed of the motor

  18. Structure of this type of the system: Two Levels, various membership functions in each, shared Sensor L This is fuzzy “strength” of the fuzzy output value SL white SL 0.7 Defuzzifier 0.7 MIN Note: this is some kind of weighted sum gray This is fuzzy “strength” of the fuzzy output value F SL 0.8 F -20 black MIN F other white 0 HL MIN ……. gray Fuzzy values of combined first level groups black Sensor R Level of input membership functions Level of output membership functions speed of the motor

  19. To remember • The previous slide was only a special case of defuzzification in a sum gate • Many other methods and shapes are possible. • Remember the general structure of the circuit. There are many variants of this circuit. With many defuzzification methods.

  20. Example 2:Using Fuzzy Logic for an Obstacle Avoiding Robot

  21. In this example the principles are the same as before, but the way of calculating is somewhat different. • We have no table, just we directly write rules. • This is just for didactic reasons.

  22. Very Basic Control Theory Read carefully @ Your speed towards a goal or away from an object should be proportional to the distance from it. @ If you want to get to a goal in an optimal amount of time you want to move quickly. @ However, you need to decelerate as you grow near the target so you can have more control. @Speed is proportional to distance-to-target Speed is proportional to the distance to target

  23. Very Basic Control Theory Read carefully @ In systems with momentum (i.e. the real world) we have to worry about more complex acceleration and deceleration. @ We can overshoot our target or stop short! @You increase your rate of deceleration based on how close you are to a goal or obstacle. @You can also integrate over the distance to a goal to create a steady state. @ This is the basic idea behind a PID controller. @Proportional Integral Derivative @The physical derivation of PID can be tricky, we will avoid it for now. @However this is a part of an extremely interesting topic!

  24. IDEA! Heuristic experimental rules • Lets just hack a fuzzy controller together and avoid some math. • The formal mathematicians will hate us, but if it works, that may be all that matters! • Derive rule of thumb ideas for speed and direction • If I am 6 meters from the obstacle, am I far from it?

  25. If near, turn more

  26. Experimental heuristics in robot design Try some fuzzy rules… • Let us look at adjusting trajectory first then we will look at speed… • If an obstacle is near and center, turn sharp right or left. • If an obstacle is far and center, turn soft left or right. • If an obstacle is near, turn slightly right or left, just in case. 􀁹 Etc… You have to experiment with these rules

  27. Degrees of angle Degrees of angle meters

  28. Implication of the rules

  29. Defuzzification

  30. Get closer, turn more Many rules of thumb like this

  31. Advise on creating rules These are just examples. You decide for your robot and your sensors The robot works in continuous time • The fuzzy rules should change slightly at each time step. • We don’t want the robot to jerk to a new trajectory too quickly. • Smooth movements tend to be better. • How often we need to update the controller is dependant on how fast we are moving. • For instance: If we update the controller 30 times a second and we are moving < 1 kph then movement will be smooth. • Ideally, the commands issued from the fuzzy controller should create an equilibrium with the observations.

  32. Advise on creating rules • Our robot has momentum • We have somewhat implicitly integrated the notion of momentum. • This is why we would slow down as we get closer to an obstacle • What about more refined control of speed and direction? • Use the derivative of speed and trajectory to increase or decrease the rate of change. • Thus, if it seems like we are not turning fast enough, then turn faster and visa versa.

  33. Remember the general structure MIN MIN Defuzzifier of the “sum” MIN Fuzzified inputs MIN MIN Fuzzy values of combined first level groups One input Defuzzifier MAX MIN MIN Level of input membership functions Level of output membership functions Reminder = general simple scheme for Fuzzy Logic

  34. EXAMPLE 3:Fan control

  35. Controller Structure • Fuzzification • Scales and maps input variables to fuzzy sets • Linear or not • Single input single output • Inference Mechanism • Approximate reasoning • Deduces the control action • Various shapes of membership functions • Various operators, not only MIN, MAX and NOT. • Defuzzification • Convert fuzzy output values to control signals • Defuzzification can be a single output linear or nonlinear function with fuzzy input and crisp output • Defuzzification can be built-into the “output sum” which can be other function than MAX or SUM or TRUNCATED SUM.

  36. Rule Base for Fan Control • Fan Speed • Set stop {0, 0, 0} • Set slow {50, 30, 10} • Set medium {60, 50, 40} • Set fast {90, 70, 50} • Set blast {, 100, 80} Air Temperature • Set cold {50, 0, 0} • Set cool {65, 55, 45} • Set just right {70, 65, 60} • Set warm {85, 75, 65} • Set hot {, 90, 80}

  37. Structure of this type of the system: Two Levels, various membership functions in each, shared MIN MIN Defuzzifier of the “sum” MIN Fuzzified inputs MIN MIN Fuzzy values of combined first level groups One input Defuzzifier MAX MIN MIN Level of input membership functions Level of output membership functions

  38. Membership function is a curve of the degree of truth of a given input value default: The truth of any statement is a matter of degree Rules Air Conditioning Controller Example: • IF Cold then Stop • If Cool then Slow • If OK then Medium • If Warm then Fast • IF Hot then Blast

  39. outputs Fuzzy Air Conditioner This is another useful visualization in two-dimensional space. inputs

  40. Mapping Inputs to Outputs

  41. EXAMPLE 4:Using Fuzzy Logic for a SWERVING ROBOT This is a more detailed analysis of a simple version of Example 1

  42. Motivating Example: Swerving Robot

More Related