目录

追猎 - UAV Interceptor System

基于阿木实验室 P600 无人机的飞行物实时检测、跟踪、预测与拦截系统。

系统架构

相机 → YOLO检测 → ByteTrack跟踪 → 轨迹记录/预测 → 意图分析 → 拦截规划
                                        ↓                       ↓
                                   安全保护(监控)           飞行控制 → PX4
                                        ↓
                         FastAPI Gateway → React + Cesium (地面站)
                         FastAPI Gateway → QGroundControl (MAVLink共享)

技术栈

组件 技术
飞控 PX4 Autopilot
仿真 Prometheus + Gazebo + PX4 SITL
后端 Python + ROS2 Humble
检测 YOLOv8 + TensorRT
跟踪 ByteTrack
预测 EKF + LSTM
前端 React 18 + CesiumJS
通信 MAVLink + WebSocket

项目结构

D:\UAV-Interceptor\
├── src/
│   ├── ros2/uav_interceptor/     # 7个ROS2节点
│   │   ├── detection_node.py     # YOLO飞行物检测
│   │   ├── tracking_node.py      # ByteTrack多目标跟踪
│   │   ├── trajectory_node.py    # 3D轨迹记录+EKF预测
│   │   ├── intent_node.py        # 飞行意图语义分析
│   │   ├── intercept_node.py     # RRT*+APF拦截规划
│   │   ├── control_node.py       # 飞行状态机控制
│   │   ├── safety_node.py        # 多重安全保护
│   │   └── adapters/             # Prometheus/MAVSDK适配器
│   ├── gateway/                  # FastAPI网关
│   └── frontend/                 # React+Cesium地面站
├── config/                       # 配置文件
├── simulation/                   # 仿真环境配置
├── tests/                        # 单元测试(7个)
└── scripts/                      # 启动/部署脚本

快速开始

1. 仿真模式(Windows/Ubuntu)

# 安装依赖
pip install -r requirements.txt

# 启动网关(仿真模式,无需PX4)
python scripts/start_gateway.py --simulate

# 另一个终端启动前端
cd src/frontend
npm install
npm run dev

访问 http://localhost:3000 打开地面站。

2. Prometheus仿真(Ubuntu + ROS2)

# 搭建仿真环境
cd simulation
chmod +x setup_simulation.sh
./setup_simulation.sh

# 启动PX4 SITL + Gazebo + MAVROS
./start_sim.sh

# 另一个终端启动拦截系统
source /opt/ros/humble/setup.bash
ros2 launch uav_interceptor interceptor.launch.py

# 启动地面站网关
python scripts/start_gateway.py --mavlink "udp://:14540"

QGroundControl 连接 UDP 端口 14550 即可同时查看飞控数据。

3. 真机部署(P600)

# 部署到机载电脑
./scripts/deploy_to_drone.sh 192.168.1.100 "serial:///dev/ttyUSB0:921600"

4. 运行测试

python tests/test_detection.py    # 检测模块
python tests/test_tracking.py     # 跟踪模块
python tests/test_trajectory.py   # 轨迹模块
python tests/test_intent.py       # 意图分析
python tests/test_intercept.py    # 拦截规划
python tests/test_safety.py       # 安全保护
python tests/test_control.py      # 飞行控制

QGroundControl集成

系统通过 MAVLink UDP 多播实现 QGC 集成:

PX4 (UDP:14540)
  ├─► QGroundControl (UDP:14550) — 独立运行
  └─► FastAPI Gateway (UDP:14540 + WebSocket)
       └─► React前端 — 地图+视频+控制
  • QGC 和前端同时接收飞控数据
  • QGC 保持完整地面站功能(参数调整、日志下载等)
  • 前端专注态势显示和任务控制

功能模块

功能 描述 节点
飞行物实时检测 YOLOv8目标检测,20-30FPS detection_node
多目标跟踪 ByteTrack,持久ID,3D定位 tracking_node
三维轨迹记录 环形缓冲区,SQLite持久化 trajectory_node
轨迹预测 EKF短期+LSTM中期 trajectory_node
意图分析 规则引擎分类6种意图 intent_node
拦截规划 RRT*全局+APF局部避障 intercept_node
自主控制 状态机管理飞行阶段 control_node
安全保护 地理围栏/电量/碰撞/超时 safety_node

开源参考

邀请码