Autonomous person-following system for the Boston Dynamics Spot robot using visual servoing and YOLOv8.
This system enables Spot to autonomously follow a person using:
- ZED 2i stereo camera for image capture
- YOLOv8 for real-time person detection
- Proportional control for smooth tracking
- Body pitch control for tracking on stairs
- Real-time person detection and tracking
- Visual servoing with three control signals (lateral, distance, pitch)
- Automatic search behavior when person is lost
- Live web stream for monitoring (Flask server on port 5000)
- Docker support with GPU acceleration
- Boston Dynamics Spot robot
- NVIDIA GPU with CUDA support
- Docker with NVIDIA Container Toolkit
- ZED 2i camera (optional, falls back to Spot's cameras)
- Clone and setup:
git clone https://github.com/vivekmattam02/spot.git
cd spot
cp config/config.yaml.example config/config.yaml
# Edit config/config.yaml with your Spot credentials- Build Docker image:
./docker_run.sh build- Run:
./docker_run.sh run- View live feed at
http://<your-ip>:5000
Copy config/config.yaml.example to config/config.yaml and set:
spot.hostname: Your Spot's IP addressspot.username: Your Spot usernamespot.password: Your Spot password
Key tuning parameters:
control.kp_linear: Forward/backward responsiveness (default: 0.5)control.kp_angular: Turning responsiveness (default: 0.5)control.kp_pitch: Body tilt responsiveness (default: 0.2)target.target_bbox_area: Following distance (larger = closer)
spot/
├── config/
│ └── config.yaml.example # Configuration template
├── src/
│ ├── main.py # Entry point, control loop, web server
│ ├── spot_controller.py # Spot SDK interface
│ ├── perception.py # ZED camera + YOLO detection
│ ├── visual_servoing.py # Control law implementation
│ └── state_machine.py # Behavior state management
├── tests/ # Test scripts
├── utils/ # Visualization utilities
├── Dockerfile
├── docker-compose.yml
└── requirements.txt
- Camera captures frame (1280x720 @ 30fps)
- YOLOv8 detects person, returns bounding box
- Visual servoing computes three errors:
- Lateral error: horizontal offset from image center
- Distance error: difference from target bounding box area
- Pitch error: vertical offset from image center
- Proportional control converts errors to velocity commands
- Commands sent to Spot at 10Hz
- Hardware E-Stop always available
- Software E-Stop with keepalive
- Velocity limits enforced
- Smooth acceleration ramping
- Automatic stop on detection loss
./docker_run.sh test-detection # Test YOLO with webcam
./docker_run.sh test-camera # Test Spot camera
./docker_run.sh test-mobility # Test robot movement (robot will move!)MIT License