Ildaron/Laser_control: A Python Mosquito Laser Turret Built From Raspberry Pi, Jetson Nano and a Galvanometer
Laser for control mosquito, weed, and pest
At a glance
- What is it?
- The repository documents a stereovision pipeline that locates a mosquito in X, Y and Z, then steers two galvanometer mirrors through an MCP4922 DAC. The README's own warning is that no version of this device can be made safe, and the author recommends a 1 mW pointer.
- Who is it for?
- Build this only if you are doing supervised bench work with a 1 mW pointer and you have read the README's warning about scattered reflections. Do not deploy it in a home, a garden, or anywhere a person can walk into the beam path.
- Can I use it commercially?
- Not without permission. GitHub finds no licence file in the repository, and without a licence all rights are reserved by default: you may read the code but not reuse it. Check the README, or ask the authors, before using it.
- Is it still maintained?
- Yes. The repository last received commits 169 days ago.
- What is it written in?
- Mainly Python, according to GitHub's language statistics.
Answers come from the project's GitHub data, last synced on September 15, 2026, and from our analysis. They are not legal advice.
DEEP OPEN-SOURCE ANALYSIS
What problem Laser_control actually addresses
The repository is a build log for a device that finds a flying insect, computes where it is in three dimensions, and points a laser at that position. The stated targets are mosquitoes, the Asian hornet, weeds and pests, and the topics list names kill-mosquito, weedcontrol, triangulation and galvanometer. The intended reader is someone assembling hardware, not someone looking for a library: the README is organised around a warning, a wiring description, mirror calibration values, and a coordinate derivation. There is no package on a registry and no release tag retrieved, so adoption means cloning the repository and reading the schematic. The author is direct about the audience limit. The opening line says not to repeat the build and that only a 1 mW laser pointer is acceptable.
Camera to mirror: the data path described in the README
Detection starts with a camera frame. The README states that Haar cascades were used first on a Raspberry Pi, then replaced with yolov4-tiny on a Jetson Nano. That gives the object position in the image plane, X and Y. Depth, the Z coordinate, comes from stereo vision: the README says a depth map is compiled and the average of the pixels inside the detected region of interest is taken with np.average from NumPy, which yields the distance. With X, Y and Z known, the code computes the angles needed for the mirrors. Those angles leave the single board computer as an SPI command to an MCP4922 digital-to-analog converter. The converter produces a 0 to 5 V signal, an operational amplifier board converts it to a bipolar range, and the README states the galvanometer driver boards end up with -12 V and +12 V for mirror positioning. The laser is switched on after the mirrors settle. The README points to the electrical schematic under 2.Jetson_code/2.1_mirror_control. One detail worth pausing on: the README says the mirror angle can be derived through the tangent, and the text is cut off mid-sentence in the supplied material, so the full formula is not verifiable here.
Calibrating the galvanometer before anything else
The mirror range is not assumed. The README notes that the maximum deflection angle is set at the factory, but that it must be checked before use, and gives a concrete case: the galvanometer documentation specified a step width of 30, while the unit in hand had only 20. The documented endpoints are 350 (lower) and 550 (upper) for the x mirror, and 00 (lower) and 250 (upper) for the y mirror. Those four numbers are the kind of thing that silently breaks a build if you trust the datasheet instead of measuring. Anyone porting this code to a different galvanometer will need to re-derive them, because the angle calculation in the README depends on the geometry of the specific scanner.
Depth accuracy is the weakest link in the chain
The X and Y estimate comes from a detector, so its error is bounded by the model. The Z estimate comes from averaging a disparity region, and the README itself links to a separate project, OpenCV-stereovision-tuner-for-windows, plus a preprint titled Low-Cost Stereovision System (Disparity Map) For Few Dollars. The phrase low-cost is the honest part. A single averaged disparity value over a small ROI is a coarse distance estimate, and for a target the size of a mosquito the depth error translates directly into a miss along the beam axis. The README also has a section titled We need more FPS, which is an acknowledgement that the frame rate of the detection stage constrains how fast the mirror can be commanded to a moving target. Neither the FPS target nor a measured depth error appears in the supplied material, so treat both as unquantified.
The safety section is the real specification
The README's warning is unusually specific and should be read as a design constraint rather than a disclaimer. It describes laser injury to the retina: the beam can enter a blood vessel and block it, or reach the blind spot where the optic nerve leaves the eye, and a burned line of pixels can precede retinal flaking. It notes there are no pain receptors in the retina, so damage can go unnoticed while the brain fills in the missing area, and the loss becomes apparent only once the damaged region is large enough. It then addresses mitigation directly: human detection and audio sensors can be added, but the README states the installation cannot be made 100 percent safe, because a reflection can injure someone outside the device's field of view and at a distance. The conclusion drawn there is that the technology should not be used at home. That is the author's own boundary, and it is the most important line in the repository.
What you need to get it running
There is no install command in the supplied material, no requirements file contents, and no release artefacts retrieved, so setup is a manual assembly job. The hardware named in the README is a Raspberry Pi or a Jetson Nano, two Pi cameras for the stereo pair, a galvanometer with driver boards, an MCP4922 DAC, an operational amplifier board for the bipolar conversion, and a power supply. The software path is a Python detection stage (Haar cascades or yolov4-tiny, under the darknet-yolo topic) feeding OpenCV stereo processing, then SPI output to the DAC. The schematic lives under 2.Jetson_code/2.1_mirror_control. The calibration constants you will edit are the mirror endpoints quoted in the README: 350 and 550 on x, 00 and 250 on y. The licence is the open question. The README's badge links to license.txt and displays the word FREE, but the repository metadata returned no licence identifier, so the actual terms are not confirmed by the material available. Read license.txt before redistributing anything.
Alternatives and where this approach does not fit
If the goal is insect population reduction rather than a tracking turret, the standard alternative is a trap: a CO2 or attractant-baited unit that kills or captures without any aiming step. The difference in approach is fundamental. A trap does not need depth estimation, a galvanometer, or a DAC, because it never has to compute a target's position in three dimensions. It trades selectivity for simplicity, and it cannot miss because of a disparity error. Conversely, if the goal is a general-purpose laser pointing or marking system, a commercial galvo controller with a documented SDK avoids the reverse-engineered mirror endpoints and the MCP4922 wiring entirely. Laser_control sits in a narrow middle: it is more ambitious than a trap and less supported than an industrial scanner, and its own README says the safe version can only track with a pointer, which removes the neutralisation function that motivates the build in the first place.
Maintenance cost and the licence gap
Maintenance here is hardware maintenance. The mirrors, driver boards and op-amp stage are the parts that drift, and the README's own calibration anecdote shows that factory figures cannot be trusted between units. The Python side depends on OpenCV, NumPy and a darknet-yolo detector, and the last push recorded is 2026-03-30, so the repository is active, but with no releases retrieved there is no versioned upgrade path: you pull master and diff it yourself. On licensing, the README badge points to license.txt and says FREE, while the repository metadata carries no licence identifier. That mismatch is the thing to resolve first, because it determines whether you can ship a derivative or only build one for yourself. Nothing here is legal advice; the file itself is the source of truth.
Editorial conclusion
Build this only if you are doing supervised bench work with a 1 mW pointer and you have read the README's warning about scattered reflections. Do not deploy it in a home, a garden, or anywhere a person can walk into the beam path. Before buying a galvanometer, verify the actual mirror deflection range on your unit, because the README records a case where the datasheet step width of 30 turned out to be 20 in practice, and the documented endpoints for the x mirror are 350 and 550 against 00 and 250 for y.
Community notes