go_away

### Author Topic: Any one of u got idea about fuzzy logic?  (Read 11860 times)

0 Members and 1 Guest are viewing this topic.

#### bonomonod

• Jr. Member
• Posts: 9
• Helpful? 0
##### Any one of u got idea about fuzzy logic?
« on: November 10, 2006, 02:26:23 PM »
Any one of u got idea about fuzzy logic? would u guys mind to share ur idea? fuzzy logic for robot,  how to implement it?

#### JesseWelling

• Expert Roboticist
• Supreme Robot
• Posts: 707
• Helpful? 0
• Only You Can Build A Robot!
##### Re: Any one of u got idea about fuzzy logic?
« Reply #1 on: November 10, 2006, 06:36:28 PM »
My first robot was ussed fuzzy logic (even though I didn't realize it at the time).

Here is what I did.
I had 2 Sharp IR range Finders and my goal was to get a differential dirve
robot to wonder around with out hitting any thing. Sharp IR's read from
low voltage at long distance to high voltage at short distance. So what
I did was mount two of them on my robot looking across the nose so the
crossed infront much like this picture:

So I fed the inverted value (which was now big for a long distance
and small for a short distance) to the motor speed for that side
(left IR looks right and gives motor value to left motor) and shazam you
have a robot that steers away from objects. I added a little bit of offset so
that if an object was closer than x distance the motor would turn in reverse
and it ran away from objects even better.

It was a simple bot that I programed in assembly on a pic controller.
Personaly I don't recomend Pics any more because the arn't that powerfull
as far as micro controllers go and development can only be done cheeply in assembly.

« Last Edit: November 10, 2006, 06:38:37 PM by JesseWelling »

#### JesseWelling

• Expert Roboticist
• Supreme Robot
• Posts: 707
• Helpful? 0
• Only You Can Build A Robot!
##### Re: Any one of u got idea about fuzzy logic?
« Reply #2 on: November 10, 2006, 06:48:35 PM »
Also have you read this?
http://www.societyofrobots.com/programming_fuzzy_logic.shtml

and while I havn't gotten a chance to look at it here is a C++ library for fuzy logic:
http://ffll.sourceforge.net/

#### bonomonod

• Jr. Member
• Posts: 9
• Helpful? 0
##### Re: Any one of u got idea about fuzzy logic?
« Reply #3 on: November 10, 2006, 10:46:33 PM »
hmm, ur bot is interesting, by positioning in different angle and invert the signal into normalize condition which easy to be understand by all, well, i got what u mean, but basically how do u apply to fuzzy logic? how u obtain the signal changes in terms of resolution but not digital 1 or 0? is it with the aid of ADC? thx for sharing~

#### JesseWelling

• Expert Roboticist
• Supreme Robot
• Posts: 707
• Helpful? 0
• Only You Can Build A Robot!
##### Re: Any one of u got idea about fuzzy logic?
« Reply #4 on: November 11, 2006, 02:45:35 AM »
yea generally you would use ADC or some other kind of quantitative measuring process.
Say you only have on and off for some kind of sensor. Well if you wanted to use fuzzy controll based on that,
what you could do is to take a sample at a certain rate and average it out.

That's purely hypothetical situation but you get the idea.

#### bonomonod

• Jr. Member
• Posts: 9
• Helpful? 0
##### Re: Any one of u got idea about fuzzy logic?
« Reply #5 on: November 11, 2006, 03:47:09 AM »
hmm.. well, it is hard for us to get the certain rate isn't it? speaking of that, actually what kind of method approach u applied into ur bot? quite interesting..

#### JesseWelling

• Expert Roboticist
• Supreme Robot
• Posts: 707
• Helpful? 0
• Only You Can Build A Robot!
##### Re: Any one of u got idea about fuzzy logic?
« Reply #6 on: November 11, 2006, 01:12:28 PM »
I wouldn't say it's hard at all to get any rate you want...all proccessors run at a given clock speed.
there is such a thing as hard time constraints and soft time constraints but for our level generaly
soft time constraints work fine. especialy if the resolution of your time constrainat is fairly small.
Mine was purley reflexive robot with a small layer of subsumption so it wouldn't get caught in a corner.
I left out the fact that I had a sensor looking forward for brevity but it determined if it was in a corner or not.
So what the bassic code looked like was this:

do
{
take adc measurement of left right and front
convert measurments

left motor= (left reading/2) + (front reading/2)
right motor= (right reading/2) + (front reading/2)

if left reading and right reading are smaller than some value x and if front reading is over x but under y
turn away from the smaller value between left reading and right reading untill over x

}

like I said pretty simple but it got the job done. that may not seem like a lot but in pic assembly it
ended up being about 4k.

#### Admin

• Administrator
• Supreme Robot
• Posts: 11,702
• Helpful? 173
##### Re: Any one of u got idea about fuzzy logic?
« Reply #7 on: November 11, 2006, 01:36:32 PM »
jesse your code looks like your robot uses 3 IR, and you took averages between a given side sensor and the front sensor, no?

bonomonod be careful of using averages, because the average between no wall, and a wall next to your robot, is still half way through the wall . . .

but what i think jesse did was use the average to find the wall location, and not distance, between the sensors, correct?

#### JesseWelling

• Expert Roboticist
• Supreme Robot
• Posts: 707
• Helpful? 0
• Only You Can Build A Robot!
##### Re: Any one of u got idea about fuzzy logic?
« Reply #8 on: November 11, 2006, 01:55:03 PM »
Not exactly.  I averaged out the converted readings which were effectively motor comands.
So we just added the front sensor to both right and left sides....meaning if the way was clear both wheels went forward.
But if there was a wall on the right, then the left sensor always slowed down the left wheel forcing a turn.

I said reading but what I meant was "modified value for the motor"

#### bonomonod

• Jr. Member
• Posts: 9
• Helpful? 0
##### Re: Any one of u got idea about fuzzy logic?
« Reply #9 on: November 13, 2006, 03:34:53 AM »
oic, so u did actually fuzzy using the value of IR to determine the rotational direction of ur motor? Is that possible for us to use random motion to apply in robot? which simply means we use the random function and create the random number, with some condition, it will behave randomly and fuzzy.?

#### JesseWelling

• Expert Roboticist
• Supreme Robot
• Posts: 707
• Helpful? 0
• Only You Can Build A Robot!
##### Re: Any one of u got idea about fuzzy logic?
« Reply #10 on: November 13, 2006, 03:38:39 AM »
yes?
I'm not sure I understand what you mean.

#### bonomonod

• Jr. Member
• Posts: 9
• Helpful? 0
##### Re: Any one of u got idea about fuzzy logic?
« Reply #11 on: November 13, 2006, 10:07:44 AM »
oh, i mean that we can create the random number using some formula, for that number, we apply by setting serveral condition as the random motion for the robot.

for example,

random x

then x will contain a value, for example 1980

the we set

if x<2000 and x>1000 then nap

then random x

second time the x value will be differ, let say 20089

if x < 30000 and x > 20000 then run

is this consider as fuzzy logic?

#### JesseWelling

• Expert Roboticist
• Supreme Robot
• Posts: 707
• Helpful? 0
• Only You Can Build A Robot!
##### Re: Any one of u got idea about fuzzy logic?
« Reply #12 on: November 13, 2006, 11:36:03 AM »
Stictly speaking, kinda sorta? Admin what are your thoughts on this?
my thought on this is you can have a random reaction built in but, part of
what fuzzy logic is is taking in continous values and using those values as a
kid of truth. for my robot i used the metric "is there a wall close by?" well
it's realative isn't it? so I made a function that gave a fuzzy answer to that question
(through the use of an analog range finder and the adc) and used that to mold my motor schema.
Have you read this by the way? http://www.societyofrobots.com/programming_fuzzy_logic.shtml

What you could do is come up with a fuzzy controller and put a "mood" modifier on it.
So you take my robot and have 2 other fuzy components that affect it's performance, Decisivness, Spazziness.
These could be randomly controlled variables but depending on Decisivness I could move up and down my
value that switches the direction, eg high decisivness = turn motor backwards further as opposed to shorter, so it gives
the apearance of makeing the decission to turn away form a wall quicker. Spazziness could be the scaling of how fast
the motor goes from 0 to 255. the spazzier it gets the closser to full on and full off the robot gets. the further from spazziness the slower it accelerates.

So then I just randomly generate it's Decisivness and Spazziness. But that doesn't seem very interesting so lets make it's
decisiveness depend on how many corners it it falls into because the more decisive it is the less corners it will get into.

I guess my explination is hard to understand if you don't understand my robots motor schema in the first place but....well....i've got class in 10min.

#### Admin

• Administrator
• Supreme Robot
• Posts: 11,702
• Helpful? 173
##### Re: Any one of u got idea about fuzzy logic?
« Reply #13 on: November 13, 2006, 06:35:50 PM »
<Jesse invokes the admin card>

So bonomonod, your example is not fuzzy logic - it is binary. Its either true, or false. It is either between 1000 and 2000, or it isnt. There is no 'close to but not actually inbetween' rule.

Fuzzy logic however is not binary. Its kinda like me shining light in your eyes. The brighter the light, the more you cover your eyes. A little light and you do nothing. Extreme light and you cover your eyes with your hands. But in between, you squint. The amount you cover your eyes is equal to the amount of light in your eyes. Its that fuzzy 'brightness level' that makes it fuzzy logic.

In Jesse's example, he used motor speed instead of squinting. Fuzzy logic for robots is a sort of proportional controller. Basically set the sensor value to the motor speed (modified by some constant).

Fuzzy logic is also great for combining multiple sensors, as Jesse did. Instead of devising some weird binary true/false table, what fuzzy logic does it just lets you add sensor values together (each modified by different tweakable constants).

#### JesseWelling

• Expert Roboticist
• Supreme Robot
• Posts: 707
• Helpful? 0
• Only You Can Build A Robot!
##### Re: Any one of u got idea about fuzzy logic?
« Reply #14 on: November 13, 2006, 06:45:46 PM »
Good Old Fashioned Artificial Intelligence is not fun....there's too much work involved and not enough of the clever.
Ofcouse it has it's place....If you are working on having your robot not drive into a wall you can put a software safty check in the lower levels of your firmware, and make it so the AI can disable that feature for very controlled movement untill it's clear of the danger.

#### Admin

• Administrator
• Supreme Robot
• Posts: 11,702
• Helpful? 173
##### Re: Any one of u got idea about fuzzy logic?
« Reply #15 on: November 13, 2006, 09:49:51 PM »
Quote
software safety check in the lower levels of your firmware
Agreed. I always have an emergency backup function in my code, saying if 'wall is too close, forget everything and back away.'

But fuzzy logic can give higher priority to certain sensors than others . . . or even exponential gain priority. The closer the wall is, the more dominating that sensor becomes in the equation . . . to the point the others are insignificant in decision making . . .

#### JesseWelling

• Expert Roboticist
• Supreme Robot
• Posts: 707
• Helpful? 0
• Only You Can Build A Robot!
##### Re: Any one of u got idea about fuzzy logic?
« Reply #16 on: November 13, 2006, 10:27:29 PM »
good thought.....to be honest I'm still not sure exactly what kind of paradigm i'm going to implement on my rover...just getting the firmware and interface ready for the ai to take hold.

#### bonomonod

• Jr. Member
• Posts: 9
• Helpful? 0
##### Re: Any one of u got idea about fuzzy logic?
« Reply #17 on: November 14, 2006, 06:05:57 AM »
oic, i got wat u mean already, for mine example, its like behavior, whether it is behave like that or not which false under binary 0 or 1. as for fuzzy logic, we are talking about the value in between 0 and 1. erm, now i ask, for light detection, we can actually measure the rc constant as constructed rc network to determine the rc constant value. as the cds resistance differs, the t=rc will be changing, with the changing of the t, is that possible for us to apply fuzzy logic for that though?

#### Admin

• Administrator
• Supreme Robot
• Posts: 11,702
• Helpful? 173
##### Re: Any one of u got idea about fuzzy logic?
« Reply #18 on: November 14, 2006, 08:24:25 AM »
what you want to do is use an ADC port on your microcontroller to read the analog value from your light sensor. this will give you a value 'between 0 and 1.'

it isnt an rc constant that you are measuring, but instead a voltage propotional to light sensed.

#### bonomonod

• Jr. Member
• Posts: 9
• Helpful? 0
##### Re: Any one of u got idea about fuzzy logic?
« Reply #19 on: November 15, 2006, 06:07:34 AM »
okay, got that, thx for guiding me ya, else, will be confused.. thx ya~

#### bonomonod

• Jr. Member
• Posts: 9
• Helpful? 0
##### Re: Any one of u got idea about fuzzy logic?
« Reply #20 on: November 16, 2006, 04:24:56 AM »
may i ask? wat is the recommended ADC to be use for fuzzy logic? internally microcontroller itself? or external device.?

#### Admin

• Administrator
• Supreme Robot
• Posts: 11,702
• Helpful? 173
##### Re: Any one of u got idea about fuzzy logic?
« Reply #21 on: November 16, 2006, 10:06:02 AM »
depends on what kind of robot you have.

if your going to build a small cheap robot, then use a microcontroller (almost all of them have ADC built in internally)

#### bonomonod

• Jr. Member
• Posts: 9
• Helpful? 0
##### Re: Any one of u got idea about fuzzy logic?
« Reply #22 on: November 16, 2006, 11:48:49 PM »
do u hav any idea towards adc0831? i mean how it works with microcontroller?

#### Admin

• Administrator
• Supreme Robot
• Posts: 11,702
• Helpful? 173
##### Re: Any one of u got idea about fuzzy logic?
« Reply #23 on: November 17, 2006, 12:18:42 AM »
what do you need it for? i mean, many microcontrollers have 8 ADC already built in . . .

Get Your Ad Here

data_list