Showcasing cutting-edge robotics projects, interactive demos, and innovative solutions
Building the future of robotics
Automated toilet cleaning robot with computer vision for stain detection and precision cleaning
# Smart Robotic Toilet Cleaner
import cv2
import numpy as np
from gpiozero import Servo, Motor
import time
class RoboticToiletCleaner:
def __init__(self):
# Hardware setup
self.cleaning_arm = Servo(17)
self.brush_motor = Motor(forward=22, backward=23)
self.water_pump = Motor(forward=24, backward=25)
# Computer vision
self.camera = cv2.VideoCapture(0)
# Cleaning patterns
self.patterns = {
'light': [(0, 0), (45, 0), (45, 45), (0, 45)],
'heavy': [(0, 0), (30, 0), (30, 30), (0, 30), (15, 15)]
}
def detect_stains(self):
"""Use CV to detect and classify stains"""
ret, frame = self.camera.read()
if not ret:
return []
hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)
# Detect brown/yellow stains
lower = np.array([10, 100, 20])
upper = np.array([20, 255, 200])
mask = cv2.inRange(hsv, lower, upper)
contours, _ = cv2.findContours(mask, cv2.RETR_EXTERNAL,
cv2.CHAIN_APPROX_SIMPLE)
stains = []
for contour in contours:
area = cv2.contourArea(contour)
if area > 100:
M = cv2.moments(contour)
if M["m00"] != 0:
cx = int(M["m10"] / M["m00"])
cy = int(M["m01"] / M["m00"])
intensity = 'heavy' if area > 500 else 'light'
stains.append({'pos': (cx, cy), 'type': intensity})
return stains
def clean_area(self, pattern='light'):
"""Execute cleaning pattern"""
self.brush_motor.forward(speed=0.8)
self.water_pump.forward(speed=0.6)
for angle_x, angle_y in self.patterns[pattern]:
self.cleaning_arm.value = (angle_x + 90) / 180
time.sleep(0.5)
# Scrub motion
for _ in range(3):
self.brush_motor.forward(speed=1.0)
time.sleep(0.3)
self.brush_motor.stop()
self.water_pump.stop()
def clean_cycle(self):
"""Main cleaning cycle"""
stains = self.detect_stains()
if stains:
for stain in stains:
self.clean_area(stain['type'])
else:
self.clean_area('light')
# Final rinse
self.water_pump.forward(speed=0.8)
time.sleep(3)
self.water_pump.stop()