Step 1: Designing the Robot
We first designed a compact robot that could travel inside pipelines. The chassis was built to hold all the electronics while keeping the robot stable and lightweight.
Components Used
- Raspberry Pi 5
- OV5693 USB Camera
- L298N Motor Driver
- 12V DC Geared Motors
- 3S2P 21700 Li-Ion Battery Pack
- DHT11 Sensor
- Wheel Encoder
- Ethernet Cable
- Servo Motor (Camera Rotation)
- LED Light
Step 2: Hardware Assembly
The hardware components were mounted on the chassis.
- Raspberry Pi acts as the brain.
- Camera is mounted at the front.
- LED provides illumination inside dark pipelines.
- Motors are connected through the L298N driver.
- DHT11 measures environmental conditions.
- Encoder measures distance travelled.
- Servo rotates the camera for a wider inspection angle.
- Ethernet cable provides communication with the laptop.
Step 3: Raspberry Pi Programming
The complete robot is programmed in Python.
Major libraries used include:
socket
threading
OpenCV (cv2)
pickle
json
RPi.GPIO
adafruit_dht
These libraries are responsible for
- Motor control
- Video streaming
- Crack detection
- Sensor reading
- GUI communication
- Networking
Step 4: Motor Control
Using the L298N Motor Driver, GPIO pins control the robot movement.
Commands include:
- Forward
- Backward
- Left
- Right
- Stop
The Raspberry Pi sends PWM signals to control motor speed.
COMMANDS = {
'FORWARD',
'BACKWARD',
'LEFT',
'RIGHT',
'STOP'
}
Step 5: Camera Installation
The OV5693 USB Camera continuously captures live video.
cap = cv2.VideoCapture(CAMERA_INDEX)
Camera Settings
- Resolution: 640 × 480
- FPS: 30
- JPEG Compression for fast transmission
Every frame is encoded before being sent to the laptop.
cv2.imencode('.jpg', frame)
Step 6: Crack Detection using YOLO
The captured frames are processed using the YOLO object detection model.
Processing Flow
Camera →
Image Preprocessing →
YOLO Model →
Crack Detection →
Display Result
YOLO detects cracks in real time and draws bounding boxes around detected defects.
Step 7: Environmental Monitoring
The robot measures pipeline conditions using the DHT11 Sensor.
The program continuously reads
- Temperature
- Humidity
Example from the code
temperature = dht_device.temperature
humidity = dht_device.humidity
The readings are transmitted to the laptop every second.
Step 8: Encoder-Based Distance Measurement
A wheel encoder measures
- Distance travelled
- Robot speed
Your code calculates
Distance = Encoder Count × CM_PER_PULSE
This allows the operator to estimate the location of detected cracks.
Step 9: Servo Camera Scanning
The servo rotates the camera automatically to increase the inspection area.
Features implemented
- Manual Left
- Manual Right
- Auto Sweep
- 180° Sweep
- Continuous Sweep
Implemented in your code using
set_servo()
start_sweep()
stop_sweep()
Step 10: Ethernet Communication
Instead of Wi-Fi, the robot communicates with the laptop using Ethernet.
Three TCP sockets are created:
CMD_PORT = 9999
VID_PORT = 9998
ENV_PORT = 9997
These ports separately handle
- Robot movement commands
- Live video
- Environmental sensor data
This provides reliable and low-latency communication.
Step 11: Live Video Streaming
Each captured frame is
- JPEG encoded
- Serialized using Pickle
- Sent over Ethernet
payload = pickle.dumps(encoded)
This allows the laptop to receive live video with minimal delay.
Step 12: Graphical User Interface (GUI)
The GUI displays
- Live camera feed
- Crack detection results
- Temperature
- Humidity
- Robot speed
- Distance travelled
- System status
The operator controls the robot directly from the GUI.
Step 13: Real-Time Operation
Once all three connections are established
Robot Starts
↓
Camera captures live video
↓
YOLO detects cracks
↓
DHT11 reads temperature & humidity
↓
Encoder measures distance
↓
Servo scans surroundings
↓
Video + Sensor Data sent via Ethernet
↓
GUI displays all information
↓
Operator controls robot
↓
Robot continues inspection
Overall Working Flow
Power ON
│
▼
Initialize Raspberry Pi
│
▼
Capture Live Video
│
▼
YOLO Crack Detection
│
├──────────────► Crack Found
│ │
│ ▼
Read DHT11 Sensor Display Detection
│ │
▼ ▼
Read Encoder Send Video + Data
│ │
└──────────────► Ethernet
│
▼
GUI on Laptop
│
▼
Operator Controls Robot
│
▼
Continue Pipeline Inspectionf
