Fuzzy Logic Control
Classical control algorithms require an exact specification of reference values, however, it is difficult to give exact definitions of properties such as the warmth of a heater, the color of a piece of fabric or the speed of a car. Fuzzy logic uses rules on linguistic variables such as “fast” and “slow” to implement control algorithms. Values from the sensors are fuzzified into linguistic variables, then the rules are applied, and finally the consequents of the rules are defuzzified to obtain numerical values that can be applied to the actuators.
If the car in front is far away or the car in back is near, set the speed to fast.
If the car in front is near, set the speed to slow.
The logic is “fuzzy” because the rules are expressed in terms of linguistic variables like speed whose values do not have precise mathematical definitions, but only imprecise linguistic specifications like fast and slow.
The values of the sensors are converted into values of the linguistic variables, such as far, closing, near, called premises. Each premise specifies a certainty which is the probability of our belief that the variable is true.
- Apply rules
A set of rules expresses the control algorithm. Given a set of premises, a consequent is inferred. Consequents are also linguistic variables such as very fast, fast, cruise, slow, stop.
The consequents are combined in order to produce a crisp output, which is a numerical value that controls some aspect of the robot such as the power applied to the motors.
The following sections present the three phases of fuzzy control for the task of a robot approaching an object and stopping when it is very close to the object.
The labeled points on the x-axis refer to thresholds: (a) far_low, (b) closing_low, (c) far_high, (d) near_low, (e) closing_high, (f) near_high. If the value of the sensor is below far_low, then we are completely certain that the object is far away and the certainty is 1. If the value is between closing_low and far_high then we are somewhat certain that the object is far away, but also somewhat certain that it is closing. The fuzziness results from the overlapping ranges: when the value is between point (b) and point (c), we can’t say with complete certainty if the object is far away or closing. For the sensor value v of about 33 the certainty of far is about 0.15 and the certainty of closing is about 0.25.
11.2 Apply Rules
If far then very fast
If far and closing then fast
If closing then cruise
If closing and near then slow
If near then stop
The certainties of the consequents resulting from rules 1, 3, 5 are the same as the certainties of the corresponding premises. When there are two premises, as in rules 2 and 4, the certainties of the consequents are computed from the minimum of the certainties of the premises. Since both of the premises must apply, we can’t be more certain of the consequent than we are of the smaller of the premises. For the value v in Fig. 11.1, rule 2 applies and the certainty of the consequent is \(\min (0.15,0.25)=0.15\).
Implement the fuzzy logic controller for a robot approaching an object.
Define appropriate thresholds for the proximity sensor and appropriate values for defuzzifying to obtain a crisp motor speed.
Compare the results with the proportional control algorithm you implemented in Activity 6.3.
Fuzzy logic control is an alternative to the classical mathematical control algorithms described in Chap. 6. The advantage of fuzzy logic control is that it does not demand precise mathematical specifications of the robot’s behavior which may be difficult to define. We gave an example of fuzzy definitions of speed; other examples would be color (when does a shade of red become orange?) and temperature (when does a warm room become hot?). The disadvantage is that the behavior of fuzzy logic control is not as transparent as that of classical control algorithms.
11.5 Further Reading
The derivation of the formula is given in Appendix B.6.
This chapter is distributed under the terms of the Creative Commons Attribution 4.0 International License (http://creativecommons.org/licenses/by/4.0/), which permits use, duplication, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if changes were made. The images or other third party material in this chapter are included in the work’s Creative Commons license, unless indicated otherwise in the credit line; if such material is not included in the work’s Creative Commons license and the respective action is not permitted by statutory regulation, users will need to obtain permission from the license holder to duplicate, adapt or reproduce the material.