The Problem
Indoor autonomous drones need continuous, low‑latency pose estimates without expensive motion‑capture rigs. Existing commercial systems are cost‑for‑each‑camera, hard to deploy, and lack an open‑source stack that can be adapted to custom hardware.
What This Does
Low-Cost-Mocap supplies a lightweight, external‑camera framework that captures multiple drones in a room‑scale volume.
- Computer side (
computer_code/) runs a Vite + React UI that visualises the tracked agents and sends control set‑points via WebSocket. - Python API (
computer_code/api/) receives camera frames, runs a structure‑from‑motion pipeline, and publishes 3‑D poses. - Hardware side (
receiver_esp32/,sender_esp32/) implements the wireless link between each drone and the computer using ESP‑32 microcontrollers.
Key modules:
KalmanFilter.py– state‑space integration of pose estimates.LowPassFilter.py– smoothing of noisy image‑based depth.Singleton.py– ensures a single global instance of the pose manager.helpers.py– utility functions for camera calibration and data conversion.
How It Is Wired
Execution starts at the Python entry point computer_code/api/index.py.
index.pycreates a FastAPI (implicit) or plain HTTP server and registers a/socketendpoint.- Incoming WebSocket frames are routed to
helpers.process_frame(). process_frame()parses the image, runs OpenCV SFM, and feeds the raw pose intoKalmanFilter.update().- Updated state propagates to the WebSocket client via
Singleton.get_instance().broadcast(). - On the frontend,
computer_code/src/shared/styles/scripts/socket.tsopens a WebSocket to the backend, receives pose data, and renders it inCameraWireframe.tsxandTrajectoryPlanningSetpoints.tsx.
The hub is Singleton, which owns the shared pose buffer; changing it would require touching the entire client‑server contract. The cycle is minimal: the backend never calls client code directly, only via the socket, keeping the modules loosely coupled.
Outside‑world interactions:
- Network – WebSocket over TCP (
ws://localhost:8000/socket). - File system – reads calibration JSON (
camera_params.json) on startup. - Hardware – ESP‑32 modules communicate over Wi‑Fi; the code for them lives in
sender_esp32/andreceiver_esp32/.
How To Use It
Setup
git clone https://github.com/moses-y/Low-Cost-Mocap
cd Low-Cost-Mocap/computer_code
yarn install # install JS deps
python3 api/index.py # start Python server
yarn run dev # launch React UI
Configuration
- Place camera calibration data in
computer_code/api/camera_params.json. - Ensure OpenCV‑SFM is built (see README for hints).
- No environment variables are required; the code hard‑codes
localhost:8000.
Running
- Open the UI at the URL printed by
yarn run dev. - Power the ESP‑32 sender/receiver pair; the drones will begin streaming to the server.
Real‑World Use
A typical deployment handles 4 drones in a 5 m × 5 m room. The UI shows real‑time trajectories; the backend publishes pose updates every 50 ms. A downstream controller can subscribe to the WebSocket and issue velocity commands, enabling closed‑loop flight without an external motion‑capture system.
Code Health & Issues
| Severity | Issue | Location |
|---|---|---|
| Medium | Missing CI/CD pipeline | .github/ folder – no workflow files |
| Low | Incomplete documentation | README.md, docs/ – minimal guidance |
| Low | Single test file (api/test.py) | Test coverage is minimal |
No static analysis was run; the repository contains no linting rules beyond .eslintrc.cjs. Dependencies are declared in computer_code/package.json and computer_code/yarn.lock.
The Bottom Line
The stack is functional and demonstrates a viable low‑cost alternative to commercial mocap rigs. It is best suited for teams willing to tweak the Python pipeline and calibrate their own cameras. The lack of CI, limited tests, and sparse documentation constrain rapid adoption, but the clear module boundaries make incremental improvement straightforward.