GreetingBot is a project combining a person detection and greeting system with an obstacle avoidance robot using Python and GPIO on a Raspberry Pi.
- Person Detection: The system detects a person using a camera and stops the robot if a person is detected.
- Greeting: The robot can greet a person by playing a sound.
- Obstacle Avoidance: The robot moves forward and avoids obstacles using ultrasonic sensors.
The project is divided into three main files:
-
raspberrypi/camera.py
- Captures frames from the camera.
- Sends frames to the server for person detection.
- Communicates with
raspberrypi/motor.py
to stop the robot if a person is detected.
-
raspberrypi/motor.py
- Controls the motors of the robot.
- Receives messages from
raspberrypi/camera.py
to either stop or move the robot. - Handles obstacle avoidance using ultrasonic sensors.
-
server/main.py
- Runs a Flask server to handle frame uploads.
- Uses YOLO (You Only Look Once) for real-time object detection.
- Sends responses back to
raspberrypi/camera.py
indicating whether a person is detected and if a greeting should be made.
- Raspberry Pi
- Camera module
- Ultrasonic sensors
- Motor driver
- Python 3
- 3d Modeling
- Required Python libraries:
requests
,opencv-python
,pygame
,RPi.GPIO
,socket
,flask
,yolov5
,pytourch
-
Clone the repository:
git clone https://github.com/Hemantcoder2005/GreetingBot.git cd GreetingBot
-
Install the required Python libraries:
pip install requests opencv-python pygame RPi.GPIO flask yolov5
-
Set up the hardware: Connect the camera, ultrasonic sensors, and motor driver to the Raspberry Pi.
-
Run the server:
python3 server/main.py
-
Run the camera script:
python3 raspberrypi/camera.py
-
Run the motor script:
python3 raspberrypi/motor.py
- Initializes the camera and captures frames.
- Sends the frames to the
server/main.py
for person detection using YOLO. - If a person is detected, sends a message to
raspberrypi/motor.py
to stop the robot. - If the server indicates a greeting, plays a random sound.
- Controls the motor pins using the GPIO library.
- Measures distances using ultrasonic sensors.
- Moves the robot forward and avoids obstacles.
- Receives messages from
raspberrypi/camera.py
to stop or move the robot.
- Runs a Flask server that listens for incoming frame uploads from
raspberrypi/camera.py
. - Uses the YOLO model to detect persons in the frames.
- Sends a JSON response back to
raspberrypi/camera.py
indicating whether a person is detected and if a greeting should be made.
-
Camera not found:
- Ensure the camera is properly connected.
- Verify that the camera module is enabled in the Raspberry Pi configuration.
-
Motors not working:
- Check the motor driver connections.
- Verify the GPIO pin setup.
-
Ultrasonic sensor giving incorrect readings:
- Ensure the sensors are properly connected.
- Check the trigger and echo pin configurations.
-
Server not responding:
- Ensure that
server/main.py
is running. - Check the network connection between the Raspberry Pi and the server.
- Ensure that
Contributions are welcome! Please fork the repository and create a pull request with your changes.
- This project was inspired by the need for a responsive and interactive robot capable of detecting and greeting people while avoiding obstacles.