I am going to build an Auto Guided Robot using Fuzzy Logic, UWP App (C#), Windows 10 IoT Core, and Raspberry Pi 3, and I will divide this tutorial into a couple of blogs to make it easier, shorter and quicker to learn and implement.
This is the robot, you will see at the end of this blog series: (hopefully working as intended 🙂 )
In this blog post, I will show you how to use Fuzzy Logic in your UWP (Windows 10) Applications to make it much smarter and usable, but before we get started, Do you even know what is Fuzzy Logic? Don’t Worry! I will tell you in a nutshell what is fuzzy logic?
It’s an approach to computing based on “degrees of truth” rather than the usual “true or false” (1 or 0) Boolean logic on which the modern computer is based on.
Fuzzy logic seems closer to the way our brains work. We aggregate data and form a number of partial truths which we aggregate further into higher truths which in turn, when certain thresholds are exceeded, cause certain further results such as motor reaction.
A similar kind of process is used in neural networks, expert systems and other artificial intelligence applications.
Fuzzy logic is essential to the development of human-like capabilities for AI, sometimes referred to as artificial general intelligence: the representation of generalized human cognitive abilities in software so that, faced with an unfamiliar task, the AI system could find a solution.
How is it different than classical logic?
• Statements are no longer black or white, true or false, on or off.
• In traditional logic an object takes on a value of either zero or one.
• In fuzzy logic, a statement can assume any real value between 0 and 1, representing the degree to which an element belongs to a given set.
Fuzzy Logic Algorithm:
- Define the linguistic variables and terms
- Construct the membership functions
- Construct the rule base
- Convert crisp input data into fuzzy values using the membership functions
- Evaluate the rules in the rule base
- Combine the results of each rule
- Convert the output data to non-fuzzy values
Here’s an example that we are going to implement through this set of blogs.
- Linguistic Variables are:
Input: Distance IS (Far or Near)
Output: Speed (High or SLOW)
- Trapezoidal is our member function
- Our Rule base for example:
IF Distance IS Far THEN Speed IS Fast
IF Distance IS Near THEN Speed IS SLOW
- Use Trapezoidal Function to convert crisp inputs to fuzzy values
- Evaluate the rules in our rule base (Step 3.)
- Combine the results of each rule
- Convert the output into non-fuzzy values
In a real scenario, the input data should be like this Distances (Front, Right and Left) for better performance, but I only used one distance, because I only have one sensor at the moment, and the out should depend on the Angle of the robot, also I don’t have servo motors to control the angle precisely, so I depend on normal DC Motors and rotating them be switching one of them on/off depend on which direction.(This tutorial just to show you how to use the fuzzy logic in your UWP Application and your IoT Solutions, I am just showing you a very quick and simple demo, you can apply the same concept into a lot of applications and real scenarios)
In the next blog, I will show you how to use Fuzzy Logic in UWP Application using C#/.NET and after that I will deploy that on Raspberry Pi 3 running Windows 10 IoT Core controlling my robot.
I do appreciate your feedback and comments, see you next blog.