Wednesday, 19 October 2022

TASK 1: VACUUM CLEANER


INTRODUCTION:

The objective of this task is to clean the house using a finite state machine to prove the reactive behaviour of the vacuum cleaner. Besides, it is main goal is to cover the largest area of a house using the programmed algorithm.

In my case I decided to implement the following finite state machine: 

 FINITE STATE MACHINE DESIGN:     

                    

 

In this GIF you can see that there are 5 states but I use mainly 4 since spiral it is only used at the beginning. 

SPIRAL:

I believe all states are clear but it can be quite confusing the initial state called spiral.

This initial state's purpose is to start with a static angular (to the right side since the vacuum start really close to a cupboard and it would detect it and would not cover much of the goal at the beginning) and a random linear speed to have a random spiral. If not, the spiral would always be the same and the vacuum would detect the same obstacle every time. Its interval is between 0 to 3

When it reaches to its first obstacle, then it starts the infinitive loop that will not longer take into account of the spiral state. 

I decided to do that since there are many furnitures and after many tries, I did not find any advantages keeping the spiral into the infinite loop.

REACTIVENESS OF THE SYSTEM:

We have learnt that using sleeps (in our case rospy.sleep) break the reactiveness of the system. So, to avoid that I have included a boolean variable for back and turn state when the vacuum gets to one of these states, iterations start running and when it achieves certain amount of iterations, goes to the next state. 

Of course if it is for example turning and detects an obstacle it goes backward to demonstrate a reactive behaviour. The system will not be stuck on a state as if we used a sleeps and in that case it would not detect an obstacle until sleep finishes.

SENSORS:

In this task, I decided to use both sensors: Laser and Bumper so the vacuum would detect more obstacles like legs of chairs and tables. Besides, including the laser sensor, the vacuum will not force movements against obstacles.
  
- LASER:
 
To have a correct data of the laser I have included in my program the function provided in the statement called: "parse_laser_data(laser_data)" which I found really useful.  
After obtaining that array, I separate the measures and angles in three parts:
 
    * From 0 to 60 degrees I assume that is Vacuum's Left side.
    * From 60 to 120 degrees I assume that is Vacuum's Front side.
    * From 120 to 180 degrees I assume that is Vacuum's Right side.
 
Here you can see a diagram if my explanation has not been clear:


After storing in three different arrays the measures of the three ranges told above, I calculate the mean of each one to have a consistent algorithm and avoid if just one light fails and it's distance given is not the real one. However, I had to add the minimum value of each array since many obstacles are thin and knowing the mean values was not enough.
 
- BUMPER:
 
This sensor is used as a complement with the laser. I found it really useful for chair's legs and obstacles like these ones.
If the bumper is pushed then, it goes forward.  (it is backward the laser)
  
MOVEMENTS:
 
 - Forward: linear speed positive.
 - Backward: linear speed negative.
 - Left : angular speed positive.
 - Right: angular speed negative. 
 
I have stated that if an obstacle is detected by its left, turns to its right. 
If an obstacle is detected by its front or right, turns to its left. 
 
Another thing to outline is that I decided to use a random angle instead of turning to a random time. My angle is between 30 to 90 degrees. I have stated that range due to after many tries it tent to turn more than 90 degrees and came back to its obstacle.
 



CONCLUSION:

To conclude I would like to outline that in an average of tries, it cleans about 80 percent of the house in about 30 mins. 

Here you can see a picture of the evaluator.

Down below, you can find videos.

VIDEOS: 


I was not been able to upload the video here, so I leave you links were you can find them.  Besides, unfortunately I have struggled with some screen recorders so, the only solution I found is recording the screen with my phone.
 
I hope you like them!

- Random Start: random start.
- Running: vacuum running.



TASK 4: GRADIENT PATH PLANNING

 INTRODUCTION:  The objective of this task is to implement the logic of the Gradient Path Planning algorithm.  The GPP consists of selecting...