Skip to main content
Version: ACS CC

Focalizare Unificata cu Tintire Auto Inteligenta

A turret that tracks and targets people using computer vision and a laser.

info

Author: Andrei-Valerian Andreescu
GitHub Project Link: Github

Description

This project is about building a simple automated turret that can detect and follow people with a camera and aim a laser at them in real-time. The user will be able to set a target (for example a red circle or a yellow t-shirt), and the turret will lock onto it and track it.

Motivation

I got the idea from the game Rust, where you can build autoturrets that shoot at players who get too close to your base. I thought it would be cool to try and make something similar in real life, but just using a laser for now.

Architecture

The system has two main parts:

  • Vision + Targeting (Python): A Python script runs object detection (YOLO) on a laptop and identifies the target based on color or shape. It sends coordinates to the turret controller.
  • Control (Rust): A Raspberry Pi 2W runs a Rust program that controls two servo motors — one for horizontal rotation, one for vertical — and points the camera and laser to track the target.
  • The camera and laser are mounted on the same platform, so they move together.

Simple schematic

An almost final photo of the project

Project_picture

Software Diagram

Software_diagram

Log

Week 5 - 11 May

Researched similar turret systems for inspiration and finalized the design plan. Ordered all necessary hardware components based on system requirements and constraints.

Week 12 - 18 May

Received the components and assembled the mechanical structure, including the servo mounts, camera bracket, and laser holder. Verified that all parts fit together and are functional.

Week 19 - 25 May

Implemented the full software system. The Rust side uses Embassy for async servo control and joystick input, while Python handles vision using OpenCV and MediaPipe. Communication between the two is done over USB serial for real-time turret tracking.

Hardware

A list of the main hardware components used in the project:

  • Raspberry Pi Pico 2W – Acts as the main controller for servo movement and USB communication.
  • 2x SG90 Servo Motors – Control the pan and tilt movement of the turret.
  • HC-SR04 Ultrasonic Sensor – Measures the distance to nearby obstacles for HUD and behavior decisions.
  • Analog Joystick Module – Used for manual control of turret direction
  • USB Camera – Captures video feed for real-time object detection.
  • Laser Pointer – Visually highlights the target being tracked.
  • Breadboard + Jumper Wires – For quick and modular connections.
  • 5V Power Supply – Powers the servo motors reliably.

Schematics

Schematic

Bill of Materials

DeviceUsagePrice
2 × Raspberry Pi Pico 2 WMicrocontrollers with Wi-Fi and Bluetooth for sensor processing and motor control40 RON each
2 × SG90 Micro Servo MotorOX and OY camera movement39 RON each
1 x 5V 3A SourceProvides DC for every component23 RON
Jumper WiresThis is used for wiring connections between modules and breadboard circuits23 RON
BreadboardRapid prototyping without soldering15 RON
ResistorsUsed in voltage dividers12 RON

Software

Software

LibraryDescriptionUsage
OpenCVComputer vision libraryUsed for red circle detection and video stream processing
MediaPipeML solution from GoogleUsed for hand landmark detection
NumPyNumerical operationsUsed for vectorized math like clipping and error computation
PySerialSerial communicationCommunicates with Rust firmware over USB
KeyboardKeypress handlingMode switching and reset from keyboard
ThreadingPython threadsRuns serial reading in a background thread
EmbassyAsync embedded frameworkRust-based async control over servos and peripherals
Embassy-RPHAL for Raspberry Pi PicoControls PWM, GPIO, ADC for joystick and servos
Embassy-USBUSB CDC for RustSends position commands and status updates over USB
FixedFixed-point mathControls PWM signal precision
Static-CellMemory allocationUsed for USB buffer initialization and CDC state
Panic-ProbeError handler for embeddedAllows USB debugging with probe-run
HeaplessLightweight containersUsed for generating serial strings from float measurements