Mobile Robot couldn't pass smoothly and stack at any obstacle

 

Hi all 

 

this is my first post .

I am in the process of designing an obstacle avoidance mobile robot controlled by fuzzy logic , the idea of this work is that the robot should moves straight in an desired angle given by the user and if it faces an obstacle in his way , it should avoid that obstacle and then re-correct its heading angle to the desired angle . 

My mobile robot is Rover 5 with two DC motors and Encoders and three ultrasonic sensors , one of sensors is in front side and two others on two sides of robot with 45 & -45 degree .

But I face a problem and I will explain it in the figures below because I couldn't to snapshot my real robot .

In figure below the initial heading angle of robot is zero with X-axis and desired angle (for example) is 45 degree .

 

so the fuzzy control will increase right motor and decease left to point or steer robot with angle 45 , and when the heading angle of robot is equaled to desired angle "45" , the robot moves straight and until now everything is OK .

 

but the problem started when the robot faces an obstacle in his way .

 

 

so to avoid that obstacle , fuzzy control will increase right  motor and decrease left to make robot change its heading to avoid it , as shown in figure below 

 

 

In the state above , instead that the robot move a little forward , It suddenly change its heading angle by increasing left motor and decrease right one and that happens because one of fuzzy rule is triggered which is telling robot to re-correct its heading to desired angle when no sensor sense an obstacles . So the robot will return to old state as in picture below 

 

now robot again tries to avoid obstacle and change its direction and then re-correct its heading to desired angle

and it stacked in these two states , switching between them and don't move  , so any help / idea about how to solve this problem

 

 

Hint : Actually my fuzzy controller is with four inputs (Front sensor reading , Right sensor reading , Left sensor reading , Desired angle ) and two outputs (Right Wheel Speed , Left Wheel Speed ) and simply the rules base scheme as follow :

If  Front Sensor  triggered  Turn Left
If  Left Sensor  triggered  Turn Right
If  Right Sensor  triggered  Turn Left
If  No Sensor  triggered  Re-correct Heading Angle to Desired angle and move Forward .

 

 

Update :

 

thanks for all your posts 

Now , I realized that I should force a slight move forwards after the turn before returning to the heading . but the problem how could I make this force or modifier , should it be located inside rule base ? I tried to add or modify a rule in my rules base to perform this force but I failed to find right place to this force .

these are my rules and membership functions by Matlab , actually I converted MATLAB Fuzzy Inference System to Arduino C Converter by http://www.makeproto.com/

A couple suggestions

Add a modifier to the avoid rule that checks for obstacles right and left. Always turning left could drive you in to a wall. Second, going along with 6677’s comment, write a block of code that executes instead of a single instruction.

More interesting will be seeing you overcome the object and get back on your original post before driving around the object. :slight_smile:

To avoid loops

Remember last position or increase the threesold necessary to choose to do the reverse move. Or sweep left and right by a random degree.

Or keep a model which maps the points where the robot has been. A map generated by this robot would have octagonal tiles and each cell has a  “unexplored”, “explored”, and “wall” status and the bot looks for three tiles at once. At each move the bot choose at random one of the unexplored tiles.

 

Obstacle Avoidance

You might be able to do by having 2 goal angles.

  • 1.  Long Term goal angle
  • 2.  Short Term goal angle

When you encounter an obstacle, modify the short term goal angle to an appropriate avoidance angle.

If the robot is moving and does not detect obstacles, alter the short term goal angle to move in the direction (by adding or subtracting degrees) of the long term goal angle, by a percentage of the difference.  You’ld have to tune the percentage for how sharp/broad you would like the turns to be.  I’d try something like 20% for starters, it all depends on how many times a second this course correction is going to happen though, and how quickly you want it to correct.

This means that in the absence of obstacles, the robot will steer sharper if its deflection from the long-term goal is higher, and more gradually if the deflection from the long term goal is lower.  With some tuning, this should lead to graceful turns, and the bot should drive around obstacles and resume to its long term goal smoothly.  

You might consider using a force field algorithm to make the robot appropriately sensitive to encountering multiple obstacles at different distances.  The FFA would steer a more intelligent course through the mess.  It would be better if you had a couple more sonars for that though.

A simpler alternative, but not as good in my opinion, would be to have the bot have a short term memory of the last evasive action (a deflection angle from goal), and not allow deflections that are direct opposites to be executed, or degrade them by a percentage.  Whenever the bot is moving, you can gradually expire/degrade the memory by a percentage.

I don’t know how to fit this into fuzzy logic, but that’s not my problem.  :-)

With two more sensors you

With two more sensors you could pass the object by keeping it on a specified distance on the left or right side. Count the steps of the motor encoder until the object is circled to find back to your pre-set path.

BTW, you would also need to modify your headline of this post. “Help” is not allowed by the rules. Why? A headline which describes the problem more clear will get you more answers since people click more. I almost did not click because i did not know what it is about and time is precious. Clicking on a post only to know that you can’t help after you clicked is not very efficient. Note: I am clicking on the links from China, so everything needs even onger to load :-) 

Another edit: Welcome to LMR :slight_smile: Show us more about your robot, pictures and most desired a video…we do have a saying here: No video, that’s not a robot! ^-° 

 

thanks a lot but sorry your

thanks a lot but sorry your answer is not clear to me , Do you mean to add extra sensor on each left and right side ? I tried that before but that’s didn’t solve the problem .

He is saying

you have a sensor on each side. When you are in avoid mode keep track of encoder counts while there is an object sensed on the opposite side opposite the direction you turned.

Sorry , my mind is a little
Sorry , my mind is a little messy and dizzy , I don’t understand what is the role of encoder counts in this state ?

Please give more details .

thanks

There are two common typos of system.

Open loop and closed loop. Open loop robotic movement means you tell the robot to move the wheels forward for a short time before doing something else. You will have no way to know how far the robot moved out if it moved in a straight line. Adding sensors to the wheels that measure revolutions and parts of a revolution. Adding sensors to motors or wheels will give you a closed loop system. With those sensors you will know if the robot has moved in a straight line and hopefully how far it has traveled. One of the only times you will have problems with encoders is when the wheels slip. If the wheels slip, your encoders won’t be able to tell you how far you have moved.

Well, just imagine a wall

Well, just imagine a wall follower which keeps a wall in a specified distance on any side.

If your robot detects the obstacle then he (yes I will address robots like that :slight_smile: ) will avoid it by turning left or right. Doing a right turn will enable the left side sensor to detect the object which was before in front of the robot and so for that sensor invisible. Now you run the robot with that sensor around the object by counting the encoder steps. With a rectangle shaped object you will turn right, go forward until the left sensor lost the object and then you need to turn left-forward until the left sensor detects it again. When the end of the object is reached you will only have to go back to the original by reversing the first right turn and the left-forward turn.

It’s like you are drunken but you still remember your door is the fifth door after the second corner. You will following that wall by touching it (even around corners) and count how many doors you already passed. If you are reaching the fifth one you are at home :slight_smile: