Making a Robot Vacuum Cleaner Follow the S-path Algorithm, Also Called Zig-Zag, Snake Algorithm.

by Wiley19 in Circuits > Arduino

225 Views, 3 Favorites, 0 Comments

Making a Robot Vacuum Cleaner Follow the S-path Algorithm, Also Called Zig-Zag, Snake Algorithm.

image0.jpeg

This project aims to develop a robot vacuum that employs the S-path algorithm for navigation, distinguishing between animate and inanimate obstacles using touch sensor/limit switches and PIR sensors. The S-path algorithm directs the robot to move straight until it encounters an obstacle. It then executes a 90-degree turn, advances briefly, and executes another 90-degree turn before resuming forward motion. Depending on its previous turn, the robot may turn left or right upon encountering an obstacle. While I won't delve into much of the construction process, I'll provide the circuit diagram, GitHub code repository, and videos showcasing the final project.

Supplies

2902-L293D-DC-Motor-Driver-Shield-3.jpg
images (8).jpeg
images (9).jpeg
images (10).jpeg
images-1.jpg
pir sensor.jpg

Bumper sensors/limit switches (any bumper sensor will do).

TT-gear DC motors (for the tires).

Arduino UNO

L293D motor driver arduino shield

LED

DC motor (for the Vacuum machnism)

MPU5060 sensor

PIR sensor

Li-ion battery

Circuit Diagram

Schematic_vacuum-cleaner-circuit_2023-01-05.png

The circuit diagram shows how the components mentioned above are connected. A liitle bit of explanation below;

  • The L293D motor driver is mounted on the Arduino UNO.
  • the left wheel TT-gear motor is connected to M1 and the right wheel TT-gear motor is connected to M2 of the L293D motor driver.
  • The vacuum cleaner sweepers are connected to M3 and the vacuum motor is connected to M4 of the L293D motor driver.
  • The limit switches are connected to the digital pin 2 of the Arduino.
  • Connect the MPU5060 pins to the Arduino pin as follows (VCC to 5V pin of Arduino, GND to GND pin of Arduino pin, SCL to A5 pin of Arduino, SDA to A4 pin of Arduino).
  • Connect other pins as shown in the circuit diagram

Understanding the Algorithm

Complete-coverage-path-planning-in-an-unstructured-environment.png
flow diagram.png

The operational pattern is structured as follows: Initially, the robot moves forward until it encounters an obstacle. In case of an animate obstacle, it executes a left 90-degree turn, proceeds a short distance, then executes another left 90-degree turn before moving forward again, upon colliding with an inanimate obstacle again, the robot turns right 90 degrees, advances briefly, executes another right 90-degree turn, and resumes forward motion in a straight path. If the PIR sensor detects an animate obstacle, the robot stops until the obstacle clears. This pattern is constantly repeated.

Code

The github code is given on the link below, please note that to use the code you need to install some Arduino libraries;

  • Wire.h
  • AFMotor.h

The github link is given below. you can modify it and contribute to it.

https://github.com/willie191998/robot-vacuum-cleaner-distinction-of-animate-and-inanimate.git

Steps

arduino mounted to motor driver.jpg
circuit initial.jpg
  1. Create a connection according to the circuit diagram above, you should mount the Arduino on the compatible motor driver L629D to reduce the space and complexity of wiring, and connect your touch sensor, and PIR sensor to the circuit board.
  2. Connect the battery source to the L629D motor driver, two 3.7V Li-on batteries could do it but your robot would quickly go low so I recommend four 3.7V Li-on batteries.
  3. Connect your vacuum motor and side spinning brush to the motor driver has shown in the circuit above, note that I did not create the vacuum mechanism, I collected one from a toy vacuum cleaner I bought.
  4. Mount the circuit board, batteries, and sensors, properly on the platform or base structure, mine was the base structure of the toy robot vacuum I bought online
  5. Upload your code to Arduino through the USB cord, do not remove the code yet
  6. Test your robot vacuum to ensure it's working accordingly, and modify the code for what isn't working.

Final Project

almost through.jpg

From the video you can see that the robot's motion is not perfectly a straight line and a 90 degrees turn, these are due to the fact the turns in the tires (motor) are not predictable so sometimes the motors might move faster or slower at the same power supply, sometimes the two motors don't move at the same speed. This greatly affects the robot's motion like you see in the video so I have used another sensor called an MPU5060 to improve the motion, the MPU5060 sensor measures the Z-axis acceleration of the robot and tries to reduce the speed of the tires to counter this acceleration. Although the algorithm is not working well currently, you will notice from the video that the robot tries to move in the opposite direction to counter this effect.

If you want the more advanced algorithm for the MPU5060, it's not given on the GitHub page, contact me by email: anoruewilson@gmail.com.

References

I got useful information from the following articles and research work, you should check it out to get extra information to modify the code. note that the code is not very accurate right now, see the problems with the code on the GitHub page.


https://www.instructables.com/How-to-Make-a-Robot-Car-Drive-Straight-and-Turn-Ex/


https://howtomechatronics.com/tutorials/arduino/arduino-and-mpu6050-accelerometer-and-gyroscope-tutorial/


https://digitalspeed.online


Edwards, T., & Sorme, J. (2018). A Comparison Of Path Planning Algorithm For Robotic Vacuum Cleaners. Stockholm, Sweden: KTH Royal Institute of Technology.