2025-12-10 00:01:32 +08:00

153 lines
4.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# WorkpieceProject 配置说明
## 概述
WorkpieceProjectConfig 是 WorkpieceProject 系列应用的共享配置库,提供了统一的 XML 配置文件加载和保存功能。
## 配置结构
配置文件使用 XML 格式,包含以下四个主要部分:
### 1. BinocularMark TCP 客户端配置
用于配置 BinocularMarkReceiver 模块连接到 BinocularMarkApp 服务器的参数。
```xml
<BinocularMark
serverIP="127.0.0.1" <!-- BinocularMarkApp 服务器IP地址 -->
serverPort="5901" <!-- BinocularMarkApp 服务器端口 -->
reconnectInterval="5000" <!-- 重连间隔(毫秒) -->
heartbeatInterval="30000"/> <!-- 心跳间隔(毫秒) -->
```
**对应数据结构**: `BinocularMarkClientConfig`
### 2. EpicEye 3D 相机配置
仅 WorkpiecePositionApp 需要,用于配置 EpicEye 3D 相机设备列表。
```xml
<EpicEyeDevices>
<Device name="EpicEye_1" ip="192.168.1.100" index="1"/>
<!-- 可配置多个设备 -->
</EpicEyeDevices>
```
**对应数据结构**: `std::vector<DeviceInfo>`
### 3. 调试配置
控制调试模式、日志输出和数据保存行为。
```xml
<Debug
enableDebug="true" <!-- 是否开启调试模式 -->
saveDebugImage="false" <!-- 是否保存调试图像 -->
savePointCloud="false" <!-- 是否保存点云数据 -->
printDetailLog="true" <!-- 是否打印详细日志 -->
debugOutputPath="./debug"/> <!-- 调试输出路径 -->
```
**对应数据结构**: `VrDebugParam`(定义在 AppCommon/Inc/VrCommonConfig.h
### 4. 串口配置
用于机械臂通信的串口参数(可选)。
```xml
<Serial
portName="COM6" <!-- 串口名称Linux下如 /dev/ttyS3 -->
baudRate="115200" <!-- 波特率 -->
dataBits="8" <!-- 数据位 -->
stopBits="1" <!-- 停止位 -->
parity="0" <!-- 校验位: 0-无校验, 1-奇校验, 2-偶校验 -->
flowControl="0" <!-- 流控制: 0-无, 1-硬件, 2-软件 -->
enabled="true"/> <!-- 是否启用串口通信 -->
```
**对应数据结构**: `SerialConfig`(定义在 AppCommon/Inc/VrCommonConfig.h
## 配置加载示例
```cpp
#include "IVrConfig.h"
// 创建配置管理器
IVrConfig* pConfig = nullptr;
IVrConfig::CreateInstance(&pConfig);
// 加载配置
ConfigResult configResult;
int ret = pConfig->LoadConfig("./config/config.xml", configResult);
if (ret == LOAD_CONFIG_SUCCESS) {
// 访问 BinocularMark 配置
std::string serverIP = configResult.binocularMarkConfig.serverIP;
int serverPort = configResult.binocularMarkConfig.serverPort;
// 访问 EpicEye 设备列表WorkpiecePositionApp
if (configResult.epicEyeDeviceList.size() > 0) {
std::string epicEyeIP = configResult.epicEyeDeviceList[0].ip;
}
// 访问调试参数
bool enableDebug = configResult.debugParam.enableDebug;
}
```
## 应用使用情况
### WorkpiecePositionApp
使用配置项:
- ✅ BinocularMark TCP 客户端配置
- ✅ EpicEye 设备列表
- ✅ 调试配置
- ⚪ 串口配置(可选)
工作流程:
1. 通过 BinocularMarkReceiver 连接到 BinocularMarkApp使用 binocularMarkConfig
2. 连接到 EpicEye 3D 相机(使用 epicEyeDeviceList[0]
3. 接收 Mark 坐标 + 点云数据
4. 计算工件抓取位置
### WorkpieceSpliceApp
使用配置项:
- ✅ BinocularMark TCP 客户端配置
- ❌ EpicEye 设备列表(不需要)
- ✅ 调试配置
- ⚪ 串口配置(可选)
工作流程:
1. 通过 BinocularMarkReceiver 连接到 BinocularMarkApp使用 binocularMarkConfig
2. 接收 Mark 坐标数据
3. 通过串口控制机械臂调整工件位置
## 简化历史
### 移除的参数
以下参数在简化过程中被移除(这些是算法内部计算的参数,不应由配置文件提供):
-`VrOutlierFilterParam` - 离群点过滤参数
-`VrCornerParam` - 角点检测参数
-`VrTreeGrowParam` - 区域生长参数
-`VrWorkpieceParam` - 工件参数
### 原因
binocularMark 算法接口需要的是预先标定好的相机校准矩阵,而不是这些算法调优参数。标定矩阵应该通过专门的标定工具生成,并在 BinocularMarkApp 的配置中设置。
WorkpieceProject 系列应用只需要:
1. **连接参数**如何连接到数据源BinocularMarkApp、EpicEyeDevice
2. **调试参数**:是否保存调试数据
3. **通信参数**:如何控制机械臂(串口)
## 参考文件
- 配置模板:`config_example.xml`
- 接口定义:`Inc/IVrConfig.h`
- 实现代码:`Src/VrConfig.cpp`
- 公共数据结构:`AppUtils/AppCommon/Inc/VrCommonConfig.h`