
Inn BEC panelized
T3nk4I/Minisumo
Code and Files for all the minisumo and sumo related projects I make, this repository includes codes, schematics, drawings, 3D files and more to make your own minisumo robot

An experimental two-camera pan/tilt tracking platform that detects a handheld DGI drone, follows it with a differential stepper mechanism, and controls a low-power green laser through a deliberately fail-closed software…
Turret is an open-source printed circuit board by ryankimharrison, from the ryankimharrison/Laser_Drone_Detector repository on GitHub. It is a 2-layer board of 85.5 × 57 mm with 34 parts on 55 nets, routed with 257 tracks and 63 vias.
It is built around the XL1509-5.0. Its parts include 13 connectors, 6 resistors, 4 capacitors, 3 transistors and 1 IC. It belongs with the RP2040 boards of this library.
An experimental two-camera pan/tilt tracking platform that detects a handheld DGI drone, follows it with a differential stepper mechanism, and controls a low-power green laser through a deliberately fail-closed software interlock.
The narrow C270 has been replaced with an OV9281-class camera (exact USB module still to be commissioned). See CAMERA_UPGRADE.md for camera profiles, required recalibration, the 5–10 m indoor flight dataset workflow, and timing configuration. The replacement profile is tracking-only. Historical measurements below describe the original rig unless explicitly stated otherwise.
This README explains both the big picture and the implementation. In plain language: a Windows computer watches two cameras, identifies the drone, estimates where it is moving, and asks a Raspberry Pi Pico to turn two motors. The laser is a separate output. Tracking the drone does not automatically permit the laser to turn on; a set of additional checks must all pass on every control cycle.
| Area | Purpose |
|---|---|
turret_host/ | Windows/Python application: cameras, object and face detection, tracking, motion control, GUI, calibration, logging, and serial communication |
firmware/current/ | Current MicroPython firmware for the Raspberry Pi Pico |
turret-2026-03-27_134819/ | KiCad schematic and PCB layout for controller board revision 3/27/2026 prod v1 |
tools/ | Calibration, deployment, diagnostics, replay, registration, and analysis utilities |
tests/ | Host-side regression tests, principally for telemetry and microstepping |
dataset/, models/, weights/ | Local training data and detector artifacts; most generated content is intentionally ignored by Git |
firmware/backups/ | Historical, timestamped firmware snapshots; useful for archaeology, not the current implementation |
staged/ | Proposed patches and experiments that may not be active |
The authoritative implementation paths are turret_host/, firmware/current/, and the KiCad project. Documents such as AGENT_HANDOFF.md, DETECTION_BRIEF.md, session notes, and staged patches preserve valuable history, but some statements in them have since been superseded by measurements or code changes.
The physical head carries a narrow camera, a wide camera, a laser, and an inertial measurement unit (IMU). Two stepper motors drive a differential wrist. The computer performs the expensive vision and tracking work; the Pico generates accurate step pulses, applies motion limits, operates switched outputs, and stops motion if host commands disappear.
flowchart LR
W[Wide camera<br/>find and reacquire] --> DW[Wide detector]
N[Narrow camera<br/>precision tracking] --> DN[Drone detector]
N --> F[YuNet face detector]
DW --> X[Wide-to-narrow mapping]
DN --> T[Pixel tracker]
X --> T
T --> C[Controller]
F --> I[Laser interlock]
C --> I
I --> L[Serial link]
L --> P[Raspberry Pi Pico]
P --> M[Two stepper drivers]
P --> Q[Laser MOSFET]
IMU[Payload IMU] --> P
P --> LThe design separates responsibilities:
vel <motor-a> <motor-b> commands over USB serial.Instead of queues, threads exchange data through a Slot: a one-item, newest-wins mailbox. This is important for real-time behavior. If vision falls behind, processing an old queue of frames would make the turret chase where the target was. A slot lets a slow consumer skip frames and act on the freshest available observation.
The wide camera provides situational awareness and reacquisition. It is an SVPRO USBFHD01M/OV2710 module with an approximately 108° horizontal field of view. It normally runs at 1920×1080 at 30 fps, with an optional 1280×720 at 60 fps mode.
The narrow camera provides the precision image coordinate system. Its replacement profile is provisionally 1280×800 at 30 fps, monochrome and global shutter; USB identity, lens, mode, exposure and mounting must be commissioned. The previous C270 ran at 1280×720 at 30 fps, mounted 90° clockwise with its IR-cut filter removed, and remains available as an explicit comparison profile. Camera-dependent calibration is checked against the selected camera, lens, size and mount.
The wide-to-narrow transformation can steer the turret toward a target seen only by the wide camera. It includes camera rotation, focal-length scaling, and optional fitted registration. However, parallax and calibration error mean a wide-origin box is never considered precise enough to authorize the laser. The design rule is:
Track on either camera; fire only from current narrow-camera evidence.
turret_host/detector.py wraps an Ultralytics YOLO detector. The active default is the project-specific drone_y11n_v4_1280.pt, run at 1280-pixel input size with FP16 enabled where supported. Only the drone class is selected.
The detector proposes boxes; it does not by itself decide which box to follow or whether the laser may operate. Training and capture utilities support collecting in-domain images, pre-labeling them, reviewing labels, and training a small model. This matters because the real scene—a close drone held in a hand, indoors, with partial occlusion and altered camera color response—is unlike the small outdoor drones found in most public datasets.
turret_host/tracker.py implements a pixel-space Kalman tracker with state:
[horizontal position, vertical position, horizontal velocity, vertical velocity]It uses confidence, spatial gating, box geometry, and continuity to associate detections. Adaptive process noise lets it remain smooth during steady motion while responding more quickly when the target changes direction. Its state machine is:
SEARCH: no reliable target.ACQUIRE: a candidate is being confirmed.TRACK: the detector and filter agree on a target.COAST: detections were briefly lost, so the filter is predicting without fresh pixel evidence.Coasting is useful for smooth pointing but is not sufficient permission to fire. The interlock requires a fresh narrow-camera drone box, not just a plausible prediction.
Range is estimated from apparent drone size when possible and may be supplemented by camera geometry. The assumed physical drone width is part of the configuration, so this is an estimate rather than a depth sensor measurement.
The controller combines two ideas:
The core control law is conceptually:
motor rate = - inverse(image Jacobian) × (position correction + target image velocity)The image Jacobian is measured during calibration by moving the mechanism and observing how a stationary scene shifts in the camera. Its sign and scale are machine-specific. Rates are clamped, derated near travel limits, and converted through the differential mechanism. Optical flow and IMU-derived platform motion can improve the velocity estimate; their quality gates and fallbacks are logged so recorded runs can be analyzed rather than tuned by impression.
The active face detector is OpenCV YuNet. It runs in a dedicated thread on the narrow camera because CPU inference can take longer than one camera frame period. YuNet expects upright faces, so the narrow image is rotated to compensate for the camera's 90° physical mounting. Detected boxes are then mapped back to the raw narrow-camera coordinate system used by tracking and control.
The interlock measures the distance between every detected face box and the intended beam path. The path is treated as a segment between the calibrated laser goal and current target location rather than as a single point. If a face is within the configured 120-pixel exclusion margin, the laser is inhibited.
Just as importantly, a missing or old face report is treated as unknown, not “no face.” A stalled detector, dead camera thread, clock error, or face result older than 200 ms therefore turns the laser off.
LaserInterlock grants permission only when all of the following are true:
| Check | Meaning |
|---|---|
| Armed | Both configuration and the operator's deliberate arm action allow laser use |
| Tracking | The tracker is in confirmed TRACK, not searching, acquiring, or coasting |
| Goal calibrated | The image location where the beam lands has been physically measured |
| Fresh drone lock | A recent narrow-camera drone box exists and contains the entire beam path |
| Plausible shape | The box aspect ratio is consistent with the measured drone, rejecting a known hand-like false positive |
| Fresh face report | The face detector has reported recently enough to be trusted |
| Face clear | Every face is farther than the inhibit margin from the beam path |
| Settled | The platform angular rate is below the firing threshold |
| Aim error small | The tracked target is close enough to the calibrated beam point |
| Velocity stream fresh | A motion command was successfully sent within the last 100 ms |
| Duty limit | Continuous on-time has not exceeded the configured cap; a cooldown follows a trip |
The logic is permission-based: a current drone detection under the beam is positive evidence. Merely failing to see a face is never enough. On any failed check, the desired laser state changes to off before normal motion work continues.
Additional protections include:
laser on is not retried forever.The software currently detects visible faces, not all human heads. YuNet can miss profiles, the back of a head, heavy occlusion, poor lighting, motion blur, or a strongly tilted face. The repository records a known loss around 35° of in-plane head tilt in one test configuration. The 200 ms allowable report age also permits real-world motion within the safety margin.
Only narrow-camera faces participate in the firing veto. Wide-camera face boxes are drawn for awareness but are not geometrically calibrated into the beam coordinate system and do not gate the laser.
No software command can switch off a laser after power or serial control has failed in a state that leaves the output energized. A physical, normally-off power interlock, keyed enable, emergency stop that removes laser power, enclosure/beam stop, and appropriate protective eyewear are outside this repository and remain necessary. Cheap 532 nm DPSS modules may also emit invisible infrared unless properly filtered.
The firmware runs on a Raspberry Pi Pico/RP2040 under MicroPython.
| Module | Responsibility |
|---|---|
main.py | Safe boot, pin parking, and console startup |
cli.py | USB serial command protocol and operational workflows |
stepper.py | PIO step generation, position moves, velocity loop, acceleration, watchdog, and optional microstep profiles |
kinematics.py | Differential transform between motor motion and payload pitch/yaw |
guard.py | IMU-backed crash/travel protection |
imu.py | GY-85 gyro, accelerometer, and magnetometer drivers |
datum.py | Gravity/yaw datum handling |
endstop.py | Endstop debouncing, homing, and repeatability tests |
peripherals.py | Laser, IR light, fan, ultrasonic, analog, and I²C devices with safety checks |
pinmap.py | Copper-verified board wiring; the hardware source of truth |
config.py | Driver type, mechanics, limits, interlocks, and timing |
diagnostics.py | Electrical and motion self-tests |
The differential wrist is not a conventional independent pan motor plus tilt motor. Both motors moving in the same direction produce pitch; moving oppositely produces yaw. Each motor by itself produces a mixture. kinematics.py performs this transform using the 26-tooth motor and 60-tooth miter pulley ratio.
Position moves and continuous velocity mode use RP2040 PIO state machines for deterministic pulses. A 5 ms firmware velocity tick ramps rates and enforces limits. Dynamic microstepping exists but is disabled by default because measured switching disturbances outweighed its benefit on this drivetrain.
The KiCad design is a single controller/carrier board centered on:
The Pico is USB-powered; the PCB's 5 V rail does not feed Pico VSYS. Grounds are common. This means the controller does not operate as a standalone board without USB power.
| Function | GPIO |
|---|---|
| Tilt motor DIR / STEP | 0 / 1 |
| Tilt microstep M2/M1/M0 / enable | 2 / 3 / 4 / 5 |
| Tilt driver pad 2 | 6 |
| Pan motor DIR / STEP | 7 / 8 |
| Pan microstep M2/M1/M0 / enable | 9 / 10 / 11 / 12 |
| Pan driver pad 2 | 13 |
| IR / fan / endstop 1 / laser | 14 / 15 / 16 / 17 |
| Endstop 2 | 19 |
| J5 I²C0 SDA/SCL | 20 / 21 |
| J11 I²C1 SDA/SCL | 26 / 27 |
| Analog input | 28 / ADC2 |
These are facts encoded in firmware/current/pinmap.py and config.py, not generic warnings:
FAULT on a DRV8825 but logic VDD on an A4988. The current configuration drives it from a Pico GPIO as an acknowledged, marginal workaround; the documented preferred rework is a proper 3.3 V connection.For any new revision, these should be corrected in copper instead of perpetuated as assembly workarounds.
The turret has multiple coordinate systems: wide pixels, raw narrow pixels, upright display pixels, motor microsteps, payload pitch/yaw, and the real laser spot. Calibration is what connects them.
At startup, the normal application establishes a repeatable datum by checking the link, calibrating gyro bias, leveling from gravity, finding a yaw reference, applying a consistent backlash preload, and setting home. Pitch is observable from gravity. Yaw is not; the project uses the repeatable magnetic field of the nearby motors as a local datum rather than trusting it as a compass.
Required calibration artifacts include:
Mechanical backlash was measured around 0.57°, so homing approaches the final datum from a consistent direction.
The recorded development environment is Windows with Python 3.12, OpenCV, NumPy, Pillow, pyserial, PyTorch with CUDA, and Ultralytics. A .venv directory exists in this checkout, but virtual environments are machine-specific and its Python launcher may point to an interpreter that is no longer installed. The repository currently has no reproducible lock file; treat the environment description as informative rather than a clean-install guarantee, and rebuild the environment locally when necessary.
Start safely with simulation and no GUI:
.\.venv\Scripts\python.exe -m turret_host.app --no-hardware --no-gui --run-seconds 5Run simulation with the spectator GUI:
.\.venv\Scripts\python.exe -m turret_host.app --no-hardwareRun with real cameras and motion but force tracking-only behavior:
.\.venv\Scripts\python.exe -m turret_host.app --tracking-onlyThe real-hardware default performs homing and may move the mechanism. Keep the laser power physically disconnected during commissioning. Useful options include --port, --cpu, --wide-fast, --fast-home, --skip-level, --record DIR, and --run-seconds N; use --help for the current list.
Tests that do not require attached hardware:
.\.venv\Scripts\python.exe -m compileall -q turret_host
.\.venv\Scripts\python.exe -m unittest discover -s tests
.\.venv\Scripts\python.exe -m turret_host.control
.\.venv\Scripts\python.exe -m turret_host.trackerMany utilities in tools/ intentionally talk to real hardware or cameras. Read their arguments and source before running them. In particular, deployment, homing, calibration, step, lash, and structured-light tools can cause motion or light emission.
The application can record synchronized telemetry for after-action analysis. The supporting scripts study latency, clock alignment, step integrity, image registration, optical-flow velocity, aim residuals, and mechanical skew. This measurement-first approach is central to the project: motor counts alone cannot reveal a skipped belt or stalled mechanism, and a visually smooth demo does not prove that the safety gates worked.
True in both turret_host/config.py and firmware/current/config.py. The GUI still requires deliberate arming and the interlock still applies, but configuration is not a physical safety barrier.turret_host/BUILD_SPEC.md — host design contract and hard-won implementation constraints.turret_host/STATUS.md — an older formal safety review; useful history, but some configuration values are now outdated.AGENT_HANDOFF.md — detailed hardware measurements, firmware protocol, and project history.DETECTION_BRIEF.md — rationale for the custom drone dataset and detector training approach.PLAN_NEXT_STAGE.md and session notes — experimental results and next-stage control analysis.firmware/current/pinmap.py — the copper-verified wiring source of truth.This project combines automated aiming, moving machinery, exposed electronics, and laser emission. Operate it only in a controlled indoor test area with a beam stop, exclusion zone, direct supervision, and a physical means to remove laser power. Begin with the laser disconnected and substitute a harmless indicator during software development. Compliance with local laser, electrical, workplace, and aviation rules is the operator's responsibility.
| Qty | Value | Footprint | References |
|---|---|---|---|
| 4 | Conn_01x02_Socket | Connector_JST:JST_XH_B2B-XH-A_1x02_P2.50mm_Vertical | J7, J9, J10, J11 |
| 3 | 100 | Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal | R1, R2, R7 |
| 3 | 100k | Resistor_THT:R_Axial_DIN0207_L6.3mm_D2.5mm_P10.16mm_Horizontal | R3, R4, R8 |
| 3 | Conn_01x03_Socket | Connector_JST:JST_XH_B3B-XH-A_1x03_P2.50mm_Vertical | J6, J13, J14 |
| 3 | Conn_01x04_Socket | Connector_JST:JST_XH_B4B-XH-A_1x04_P2.50mm_Vertical | J2, J3, J5 |
| 3 | NMOS | Package_TO_SOT_THT:TO-220-3_Vertical | Q1, Q2, Q4 |
| 2 | Conn_01x02_Pin | Connector_PinSocket_2.54mm:PinSocket_1x02_P2.54mm_Vertical | J1, J4 |
| 2 | Pololu_Breakout_DRV8825 | Module:Pololu_Breakout-16_15.2x20.3mm | A2, A3 |
| 2 | TestPoint | TestPoint:TestPoint_Pad_D3.0mm | TP14, TP17 |
| 1 | 105uF | Capacitor_THT:C_Radial_D8.0mm_H11.5mm_P3.50mm | C3 |
| 1 | 180uF | Capacitor_THT:C_Radial_D8.0mm_H11.5mm_P3.50mm | C1 |
| 1 | 1N5820 | Diode_THT:D_DO-201AD_P15.24mm_Horizontal | D1 |
| 1 | 470uF | Capacitor_THT:C_Radial_D8.0mm_H11.5mm_P3.50mm | C2 |
| 1 | 47uH | Inductor_SMD:L_10.4x10.4_H4.8 | L1 |
| 1 | Alot of uF | Capacitor_THT:C_Radial_D16.0mm_H25.0mm_P7.50mm | C4 |
| 1 | RaspberryPi_Pico | Module:RaspberryPi_Pico_Common_Unspecified | A1 |
| 1 | Screw_Terminal_01x02 | TerminalBlock_Phoenix:TerminalBlock_Phoenix_MKDS-3-2-5.08_1x02_P5.08mm_Horizontal | J12 |
| 1 | XL1509-5.0 | Package_SO:SOIC-8_3.9x4.9mm_P1.27mm | U1 |

T3nk4I/Minisumo
Code and Files for all the minisumo and sumo related projects I make, this repository includes codes, schematics, drawings, 3D files and more to make your own minisumo robot

alextrical/ESP32-Sentinel-Kinetic-Wireless-Dongle
ESP8266 based Re-implementation of the Vent-Axia Sentinel Kinetic Wired Remote Controller without a Display

slippery-carrot/ESPrinkler-Retic-Controller
8-Zone reticulation controller based on ESPHome for Home Assistant



CK20000/STM32-Digital-Twin-Project-Status-Architecture
Tired of paywalled PCB simulators? Open-source, physics-accurate digital twin for KiCad. Real MCU (Renode), real analog (ngspice), live PyQt6 dashboard. No stubs, no fake numbers. Fork and grow it.

ben-jacobson/RemoraNucleoHatPCB
Cost-effective, customisable LinuxCNC motion control unit.

It measures 85.5 × 57 mm and has 2 copper layers, 1.6 mm thick.
34 parts, built around the XL1509-5.0. The full list of its parts is on this page, with links to each part's symbol and footprint where PCBKit's library has them.
From the ryankimharrison/Laser_Drone_Detector repository on GitHub, at the commit this page was made from: the board is turret-2026-03-27_134819/turret.kicad_pcb and its schematic turret-2026-03-27_134819/turret.kicad_sch. PCBKit opens the board in the browser, with nothing to install.
Its repository states no licence, so its author keeps all rights: ask ryankimharrison before reusing the design.