Person Following AI Robot (No Code)

by KimY21 in Circuits > Raspberry Pi

34 Views, 0 Favorites, 0 Comments

Person Following AI Robot (No Code)

Person Following AI Robot - Demo

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:

  1. Real-time person detection using AI camera
  2. PI (Proportional-Integral) control for smooth movement
  3. Collision prevention with distance sensor
  4. Differential drive steering
  5. Live dashboard for monitoring


Supplies

결선도.png

Required Components

  1. Raspberry Pi 4 or above
  2. Raspberry Pi Camera Module or USB webcam
  3. HC-SR04P ultrasonic distance sensor (3.3V compatible)
  4. L298N motor driver
  5. 2x DC motors with wheels
  6. Robot chassis
  7. Power bank for Raspberry Pi (5V/2A minimum)
  8. 2x 18650 batteries (in series) for motors
  9. Jumper wires


Wiring:

Refer to attached wiring diagram


⚠️ Critical Notes:

  1. HC-SR04P must use 3.3V (NOT 5V) to protect GPIO pins
  2. Keep Raspberry Pi and motor power supplies separate
  3. Connect common ground between Raspberry Pi and L298N

Quick Start

  1. Download and install Grablo software on your Raspberry Pi
  2. Wire components according to circuit diagram
  3. Get this project
  4. Connect your controller (enter Raspberry Pi IP address)
  5. Run the project

To build it yourself, continue to Step 2.

Create Logic

2025-11-23_12-59-19.png

Create Project & Logic

  1. Go to https://app.grablo.co
  2. Click "Create Project"
  3. Name your project
  4. Create a new logic


Control 1 - Camera and Person Detection

Set up the camera to continuously detect people.

  1. Condition (Once): Run once at startup
  2. Action (AI Camera): Start camera
  3. AI Analysis 1: Detect if person is present
  4. 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.

  1. Condition (Always): Run continuously
  2. Action (I/O Device Control): Read distance sensor


Control 3 - Motor PI Control

Calculate wheel speeds and move the robot.

  1. Condition 1 (Compare): Check If Person Detected
  2. Condition 2 (Compare): Check If Distance greater than 30 (cm)
  3. Action 1 (Set Variable): Calculate PI control using Block Editor
  4. Action 2 (I/O Device Control): Set Left Motor Speed based on PI Control
  5. 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.

  1. Condition (Watch Condition): Watch Control 3, set to "Invert"
  2. Action 1 (I/O Device Control): Stop left motor (Coast Stop)
  3. Action 2 (I/O Device Control): Stop right motor (Coast Stop)
  4. Action 3 (Set Variable): Reset accumulated error to 0


Create Dashboard (Optional)

2025-11-23_10-44-05.png

Add widgets for monitoring:

  1. Camera Widget: Live feed with detection overlay
  2. LED Widget: Person Detection Status
  3. Label Widget: Distance
  4. Label Widget: Error
  5. Label Widget: Speed Correction


Launch Your Project

That's it - you're done!


Launch Your Project

  1. Download and install Grablo software on your Raspberry Pi
  2. Wire components according to circuit diagram
  3. Connect your controller (enter Raspberry Pi IP address)
  4. Run the project


Expected Results

When you run your project:

  1. Camera starts and AI person detection activates
  2. Person detected: Robot moves forward to follow
  3. Move left/right: Robot turns by adjusting wheel speeds
  4. Multiple people: System tracks the largest person
  5. Distance < 30cm: Robot stops automatically
  6. No person: Robot stops and resets
  7. Dashboard updates: Real-time display of camera and distance sensor

Video Tutorial

Person Following AI Robot

Video TutorialWatch the complete build process in action!

Expand Your Project

Add more functionality:

  1. Voice control with STT (Speech-to-Text)
  2. Voice output with TTS (Text-to-Speech)
  3. Music playback and sound effects
  4. LED effects and status indicators
  5. Adjustable base speed


Troubleshooting

No person detection:

  1. Check camera connection and lighting
  2. Adjust camera angle (aim at person's height)
  3. Optimal distance: 0.5-5 meters

Robot not moving:

  1. Verify GPIO connections and battery charge
  2. Test motor directions

Aggressive turning or oscillation:

  1. Reduce gains from 0.06 to 0.04
  2. For oscillation, reduce I gain to 0.03

Distance sensor issues:

  1. Must use 3.3V (NOT 5V)
  2. Verify common ground connection


Resources

  1. Official Website: https://grablo.co
  2. Web Application: https://app.grablo.co
  3. Documentation: https://doc.grablo.co
  4. Support: support@grablo.co