Building Auto Guided Robot – Part 1: Intro to Fuzzy Logic

fuzzylogic_system.jpg

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 🙂 )

18342827_1391725417556053_2588661008783146475_n.jpg

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?

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:

  1. Define the linguistic variables and terms
  2. Construct the membership functions
  3. Construct the rule base
  4. Convert crisp input data into fuzzy values using the membership functions
  5. Evaluate the rules in the rule base
  6. Combine the results of each rule
  7. Convert the output data to non-fuzzy values

Example:

Here’s an example that we are going to implement through this set of blogs.

Steps:

  1. Linguistic Variables are:
    Input: Distance IS (Far or Near)
    Output: Speed (High or SLOW)
  2. Trapezoidal is our member function
  3. Our Rule base for example:
    IF Distance IS Far THEN Speed IS Fast
    IF Distance IS Near THEN Speed IS SLOW
  4. Use Trapezoidal Function to convert crisp inputs to fuzzy values
  5. Evaluate the rules in our rule base (Step 3.)
  6. Combine the results of each rule
  7. Convert the output into non-fuzzy values

Important NOTE:
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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s