Programing a located vacuum cleaner by myself.
Published on September 22, 2023 by vbarcena2020(abito2)
Práctica 1 - Located Vacuum Cleaner post Robótica de Servicios Unibotics Python Docker
2 min READ
This post will show you how I progress in my task of subject “Robótica de Servicios” to program a located vacuum cleaner:
This task presents us with the situation the situation of a vacuum cleaner which must clean the house by locating it using the map.
The method that I have decided to implement is get the path using opencv and with the path move along the house to clean it.
I get the path using BSA in python but not in unibotics because I wanted to watch the where is the path drawing it in the image.
In this practice I will perform two subtasks, get the path, follow the path.
Fistly, I get the image with opencv and I resized it to 512 x 512 pixels and I erode the walls to avoid being to close to crash with those.
After knowing the size of the image I divide it in cells of 16 x 16 pixels.
To draw the path I get the origin point of the robot and draw the cell where it is in blue. The cells that have already been visited are drawn in blue and the cells of neighbors that have not yet been visited are drawn in green.
To move along the house I establish the priority of the following order west, north, east and south. When the robot is surrounded by previously visited places or walls I look for the closest and most accessible neighbor to go to and continue cleaning the house.
To follow the path I use a reduced one in which all the consecutive repeated movements are put together, obtaining a path with fewer steps.
To move I convert the pixels to coordinates in the real world and with this coordinates I can go to then and orientate to the next position and follow all the path.
The code libraries that I have used are numpy, math and queue:
Finally, I have to mention that depending on the values of the velocities the robot can lost the point and crash to the walls.
Also you can modify sizes of the cells or not erode the walls but you risk getting too close to the walls and crashing, even if you get a better sweep of the house, in addition to adding many more steps to the path.
Finally, you can also modify the order of priority you give to the robot’s cardinal points, obtaining a different path which can be better or worse, depending on where you start.
There is a gift which shows the path creating.
Gif:
Simulation Video
This video shows the simulation of create the path and the localized vacuum cleaner in unibotics.