Skip to content

Yuxiang-Fan/NUEDC-2025-Laser-Tracker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenMV-Based Auto-Aiming Gimbal System (2025 NUEDC)

📝 Project Overview

This repository provides a vision-based control implementation for Task 2 of the 2025 National Undergraduate Electronics Design Contest (NUEDC), Question E. The system utilizes an OpenMV4 module as the primary vision processor to coordinate a 2D Pan-Tilt gimbal. The design objective is to identify target centers on A4 UV-sensitive paper and direct a 405nm laser pointer to the target within a 2-second interval.

🛠️ Hardware Configuration

  • Vision Processor: OpenMV4 (STM32H7-based), utilized for image acquisition and real-time feature processing.
  • Actuators: A 2D Pan-Tilt gimbal driven by two PWM-controlled servos. Servo movements are constrained to ±5° increments per control cycle.
  • Laser Module: 405nm blue-violet laser (optical power ≤ 10mW). A red laser was employed for calibration during the development phase.

🧠 Control Logic & Algorithms

The system implements a closed-loop control architecture integrating feature recognition, signal filtering, and positional adjustment.

1. Target Recognition (NCC Algorithm)

The implementation employs the Normalized Cross-Correlation (NCC) algorithm within the LAB color space to identify rectangular frames. The matching degree is defined by the following mathematical model:

$$NCC = \frac{\sum_{x,y}(I_1(x,y)-\bar{I}_1)(I_2(x+d,y)-\bar{I}_2)}{\sqrt{\sum_{x,y}(I_1(x,y)-\bar{I}_1)^2 \sum_{x,y}(I_2(x+d,y)-\bar{I}_2)^2}}$$

(Where $I_1$ represents the source image pixel values and $I_2$ represents the target template values after coordinate offset $d$.)

2. Error Filtering

To mitigate high-frequency jitter resulting from mechanical backlash or rapid transitions, a 5-frame moving average filter is applied to the calculated pixel errors ($e_x, e_y$) prior to the control stage.

3. Positional PID Control

Decoupled proportional control is applied to the horizontal and vertical axes:

  • Pan (Horizontal): $K_p = 0.07$
  • Tilt (Vertical): $K_p = 0.08$
  • Output Scaling: A damping factor of $0.9$ is applied to the final output to reduce potential overshoot and oscillation during convergence.

📊 Experimental Results

The following table summarizes the measured performance across different test scenarios.

Scenario Initial Condition Target Status Max Deviation ($D$) Observation
Test 1 Fixed position Stationary 1.6 cm Successful tracking
Test 2 Fixed position Stationary 1.8 cm Successful tracking
Test 3 Arbitrary offset Stationary 3.8 cm Target locked
Test 4 Arbitrary offset Stationary 5.3 cm Target locked

Summary: Experimental data indicates that the steady-state error is maintained within 1.8 cm at fixed positions. The system demonstrates reliable convergence from arbitrary starting coordinates, meeting the requirement of ≤ 2.0 cm deviation within the specified 2-second timeframe.

🚀 Deployment

  1. Clone the repository to the local environment.
  2. Transfer main.py and pid.py from the src/ directory to the root directory of the OpenMV module.
  3. Adjust the LAB_THRESHOLD parameters in main.py to account for specific ambient lighting conditions.
  4. Upon power-up, the system undergoes a centering routine before entering the active tracking state.

基于 OpenMV 的自动对准云台系统 (2025 年电赛)

📝 项目概览

本项目为 2025 年全国大学生电子设计竞赛(NUEDC)E 题任务 2 提供了基于视觉的控制实现。系统利用 OpenMV4 模块作为核心视觉处理器,协调二维云台运动。设计目标是识别 A4 紫外感光纸上的目标中心,并在 2 秒内驱动 405nm 激光笔指向目标。

🛠️ 硬件配置

  • 视觉处理器:OpenMV4 (基于 STM32H7),用于图像采集和实时特征处理。
  • 执行器:由两个 PWM 控制的舵机驱动的二维云台。舵机运动被限制在每个控制周期 ±5° 以内。
  • 激光模块:405nm 蓝紫色激光器(光功率 ≤ 10mW)。开发阶段使用红色激光器进行校准。

🧠 控制逻辑与算法

系统实现了一个集成了特征识别、信号滤波和位置调整的闭环控制架构。

1. 目标识别 (NCC 算法)

在 LAB 颜色空间中采用归一化相关系数 (NCC) 算法来识别矩形框。匹配程度由以下数学模型定义:

$$NCC = \frac{\sum_{x,y}(I_1(x,y)-\bar{I}_1)(I_2(x+d,y)-\bar{I}_2)}{\sqrt{\sum_{x,y}(I_1(x,y)-\bar{I}_1)^2 \sum_{x,y}(I_2(x+d,y)-\bar{I}_2)^2}}$$

(其中 $I_1$ 代表源图像像素值,$I_2$ 代表坐标偏移 $d$ 后的目标模板值。)

2. 误差滤波

为了减轻由于机械回程或快速切换导致的离散抖动,在控制阶段前对计算出的像素误差 ($e_x, e_y$) 应用了 5 帧移动平均滤波器。

3. 位置式 PID 控制

对水平和垂直轴应用解耦比例控制:

  • Pan (水平):$K_p = 0.07$
  • Tilt (垂直):$K_p = 0.08$
  • 输出缩放:对最终输出应用 0.9 的阻尼因子,以减少收敛过程中的潜在超调和震荡。

📊 实验结果

下表总结了不同测试场景下的实测性能。

场景 初始条件 目标状态 最大偏差 ($D$) 观察结果
测试 1 固定位置 静止 1.6 cm 成功追踪
测试 2 固定位置 静止 1.8 cm 成功追踪
测试 3 任意偏移 静止 3.8 cm 目标锁定
测试 4 任意偏移 静止 5.3 cm 目标锁定

总结:实验数据表明,固定位置的稳态误差保持在 1.8 cm 以内。系统展示了从任意起始坐标可靠收敛的能力,满足了在指定的 2 秒时限内偏差 ≤ 2.0 cm 的要求。

🚀 部署

  1. 克隆仓库至本地环境。
  2. src/ 目录下的 main.pypid.py 传输至 OpenMV 模块的根目录。
  3. 根据具体的环境光照条件调整 main.py 中的 LAB_THRESHOLD 参数。
  4. 上电后,系统将执行归中程序,随后进入活跃追踪状态。

About

An OpenMV-based auto-aiming system using NCC template matching and PID control for the 2025 NUEDC (Question E). Features dual-axis gimbal tracking with ±2cm precision.基于OpenMV的自动瞄准系统,采用NCC模板匹配与PID控制,针对2025年NUEDC竞赛E题设计。具备双轴云台追踪功能,精度达±2cm。

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages