
Velocitya->addFuzzySet(average) // Adicionando o FuzzySet average em velocityįuzzySet* fast = new FuzzySet(180, 240, 240, 240) // Velocidade alta Velocitya->addFuzzySet(slow) // Adicionando o FuzzySet slow em velocityįuzzySet* average = new FuzzySet(72, 150, 150, 210) // Velocidade normal Criando os FuzzySet que compoem o FuzzyOutput velocidadeįuzzySet* slow = new FuzzySet(0, 60, 60, 96) // Velocidade lenta create array loop to iterate over every item in the arrayįor (int thisReading = 0 thisReading addFuzzySet(small) // Adicionando o FuzzySet small em distanceįuzzySet* safe = new FuzzySet(112, 187, 187, 262) // Distancia seguraĭistance->addFuzzySet(safe) // Adicionando o FuzzySet safe em distanceįuzzySet* big = new FuzzySet(225, 300, 300, 300) // Distancia grandeĭistance->addFuzzySet(big) // Adicionando o FuzzySet big em distanceįuzzy->addFuzzyInput(distance) // Adicionando o FuzzyInput no objeto FuzzyįuzzyOutput* velocitya = new FuzzyOutput(1) Int IN3=4 //connected to Arduino’s port 4ĭigitalWrite(IN2,HIGH) //setting motorA’s directon Int IN2=3 //connected to Arduino’s port 3 Int IN1=2 //connected to Arduino’s port 2 variable for storing the distance (cm) arrayIndex of the current item in the array stores the distance readings in an array number of readings to take/ items in the array to remove the jitter/noise from the DYP-ME007 sonar readings variables to take x number of readings and then average them
SOURCE CODE FUZZY LOGIC ARDUINO SERIAL
my problem is when i test my code, i have good result in my serial board and when i connect my two motors, the us sensor don’t send good diwtance like before. Like my first article this one was also one of my assignments for AI at university and I thought I'd try this one out in WPF using C# as well.Good morning i want to write a program to make collision avoidance with fuzzy logic. "Fuzzy logic is a mathematical approach to problem solving. It excels in producing exact results from imprecise data, and is especially useful in computers and electronic applications.įuzzy logic differs from classical logic in that 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. The human brain can reason with uncertainties, vagueness, and judgments. Fuzzy logic is an attempt to combine the two techniques." - Paul Wang, Professor of Electrical Engineering Computers can only manipulate precise valuations. So fuzzy logic is just logic that takes imprecise inputs and ouptus a precise output - a precise problem solving methodology. So lets go about creating a fuzzy logic system for an obstacle avoidance system.

Inputs to a fuzzy system could say the temperature in a room or the color of a particular pixel on screen. The fuzzy logic system works by applying certain rules to the input values to find out the degree that the particular input matches a set of values defined by a rule.īy looking at the input fuzzy sets above, a person who is 165cm according to the boolean representation, the person would by short. But the fuzzy logic would output that the person is partly short and partly average. The input value 165 is a member of both the short and average domain. So a Fuzzy Logic recognizes not only clear-cut, black-and-white alternatives but also the infinite gradations in between.

So in Fuzzy terms the person would classified within a range of as small to a degree of 0.4, and average to a degree of 0.6. Specify the shape of the membership functionsįor our input variables - angle could be described as.Decide on what the fuzzy rules are going to be (can be described linguistically).Specify the fuzzy sets to be associated with each variable.Now for the actual parameters of the fuzzy system in 3 simple steps: Adjustment Angle of the heading of the car to avoid possible collisions with obstacles.Distance to between the obstance and my car.Angle of the obstacle relative to the direction my car is travelling in.So lets go about designing a fuzzy system for obstacle avoidance of the car in my assignment.įirst we need to define the input and output variables of the fuzzy system.
