Person Following AI Robot (No Code)
by KimY21 in Circuits > Raspberry Pi
34 Views, 0 Favorites, 0 Comments
Person Following AI Robot (No Code)
Introduction
This tutorial shows how to build a person-following robot using Grablo's visual programming blocks. The system uses AI vision for real-time person detection and PI control to adjust wheel speeds for smooth tracking. A distance sensor prevents collisions by stopping the robot when obstacles are too close.
What You'll Build
A person-following robot with:
- Real-time person detection using AI camera
- PI (Proportional-Integral) control for smooth movement
- Collision prevention with distance sensor
- Differential drive steering
- Live dashboard for monitoring
Supplies
Required Components
- Raspberry Pi 4 or above
- Raspberry Pi Camera Module or USB webcam
- HC-SR04P ultrasonic distance sensor (3.3V compatible)
- L298N motor driver
- 2x DC motors with wheels
- Robot chassis
- Power bank for Raspberry Pi (5V/2A minimum)
- 2x 18650 batteries (in series) for motors
- Jumper wires
Wiring:
Refer to attached wiring diagram
⚠️ Critical Notes:
- HC-SR04P must use 3.3V (NOT 5V) to protect GPIO pins
- Keep Raspberry Pi and motor power supplies separate
- Connect common ground between Raspberry Pi and L298N
Quick Start
- Download and install Grablo software on your Raspberry Pi
- Wire components according to circuit diagram
- Get this project
- Connect your controller (enter Raspberry Pi IP address)
- Run the project
To build it yourself, continue to Step 2.
Create Logic
Create Project & Logic
- Go to https://app.grablo.co
- Click "Create Project"
- Name your project
- Create a new logic
Control 1 - Camera and Person Detection
Set up the camera to continuously detect people.
- Condition (Once): Run once at startup
- Action (AI Camera): Start camera
- AI Analysis 1: Detect if person is present
- AI Analysis 2: Get person's center X-coordinate
This runs continuously, updating detection status and position in real-time.
Control 2 - Distance Measurement
Measure distance continuously for collision prevention.
- Condition (Always): Run continuously
- Action (I/O Device Control): Read distance sensor
Control 3 - Motor PI Control
Calculate wheel speeds and move the robot.
- Condition 1 (Compare): Check If Person Detected
- Condition 2 (Compare): Check If Distance greater than 30 (cm)
- Action 1 (Set Variable): Calculate PI control using Block Editor
- Action 2 (I/O Device Control): Set Left Motor Speed based on PI Control
- Action 3 (I/O Device Control): Set Right Motor Speed based on PI Control
Control 4 - Stop Motors
Stop motors when conditions aren't met.
- Condition (Watch Condition): Watch Control 3, set to "Invert"
- Action 1 (I/O Device Control): Stop left motor (Coast Stop)
- Action 2 (I/O Device Control): Stop right motor (Coast Stop)
- Action 3 (Set Variable): Reset accumulated error to 0
Create Dashboard (Optional)
Add widgets for monitoring:
- Camera Widget: Live feed with detection overlay
- LED Widget: Person Detection Status
- Label Widget: Distance
- Label Widget: Error
- Label Widget: Speed Correction
Launch Your Project
That's it - you're done!
Launch Your Project
- Download and install Grablo software on your Raspberry Pi
- Wire components according to circuit diagram
- Connect your controller (enter Raspberry Pi IP address)
- Run the project
Expected Results
When you run your project:
- Camera starts and AI person detection activates
- Person detected: Robot moves forward to follow
- Move left/right: Robot turns by adjusting wheel speeds
- Multiple people: System tracks the largest person
- Distance < 30cm: Robot stops automatically
- No person: Robot stops and resets
- Dashboard updates: Real-time display of camera and distance sensor
Video Tutorial
Video TutorialWatch the complete build process in action!
Expand Your Project
Add more functionality:
- Voice control with STT (Speech-to-Text)
- Voice output with TTS (Text-to-Speech)
- Music playback and sound effects
- LED effects and status indicators
- Adjustable base speed
Troubleshooting
No person detection:
- Check camera connection and lighting
- Adjust camera angle (aim at person's height)
- Optimal distance: 0.5-5 meters
Robot not moving:
- Verify GPIO connections and battery charge
- Test motor directions
Aggressive turning or oscillation:
- Reduce gains from 0.06 to 0.04
- For oscillation, reduce I gain to 0.03
Distance sensor issues:
- Must use 3.3V (NOT 5V)
- Verify common ground connection
Resources
- Official Website: https://grablo.co
- Web Application: https://app.grablo.co
- Documentation: https://doc.grablo.co
- Support: support@grablo.co