feat:转子钢芯配置手眼标定用公共模块

This commit is contained in:
YangSn 2026-09-19 09:47:22 +08:00
parent ef5b9e3156
commit db3fda39f7
6 changed files with 50 additions and 16 deletions

View File

@ -7,7 +7,7 @@
<COM Name="COM1" Remarks="" Baund="9600" Parity="0" StopBit="0" DataBit="0" FlowCtrl="0" TransMode="0" CharType="0" BreakTime="10" />
<COM Name="COM14" Remarks="" Baund="9600" Parity="0" StopBit="0" DataBit="0" FlowCtrl="0" TransMode="0" CharType="0" BreakTime="10" />
<COM Name="COM13" Remarks="" Baund="9600" Parity="0" StopBit="0" DataBit="0" FlowCtrl="0" TransMode="0" CharType="0" BreakTime="10" />
<NET Name="VISION_NET" Remarks="" DesIP="127.0.0.1" LocalPortID="0" DesPortID="502" LinkMode="0" LinkResetTime="3000" LinkHoldTime="6000" TransMode="2" CharType="0" MaxAsynNum="15" />
<NET Name="VISION_NET" Remarks="" DesIP="192.168.10.20" LocalPortID="0" DesPortID="502" LinkMode="0" LinkResetTime="3000" LinkHoldTime="6000" TransMode="2" CharType="0" MaxAsynNum="15" />
</PORT_LIST>
<DEVICE_LIST>
<DEVICE Name="[M]VISION_NET-001" PortName="VISION_NET" DeviceType="1" Addr="1" ForwardZero="0" AddrUIMode="0" CRCByteOder="1" AddrOffset="0" PackWay="1" BitGap="0" RegGap="5" OneReg10="0" OneCoil0F="0" BCast1="0" BCast2="0" IsBCDevice="0" BathReadMode="0" BathWriteMode="0">

View File

@ -36,7 +36,8 @@
| 写入值 | 命令 |
|---:|---|
| `1` | 工件检测 |
| `2` | 料框检测 |
工件检测算法会在定位过程中同步计算所需的料框信息,不需要单独触发料框检测。
## 5. 状态寄存器
@ -50,8 +51,6 @@
工件检测完成且 `Status=1` 后,客户读取工件检测结果寄存器。
料框检测只通过 `Status` 返回完成或失败,不提供料框几何结果寄存器。
## 6. 工件检测结果
当前 Modbus TCP 返回第一个工件结果。
@ -69,6 +68,21 @@
| `12-13` | 2 | float | `B` | 姿态第 2 项,单位 deg |
| `14-15` | 2 | float | `C` | 姿态第 3 项,单位 deg |
`workpieceType` 取值含义如下:
| `workpieceType` | 含义 |
|---:|---|
| `0` | 中央 |
| `1` | 上边 |
| `2` | 下边 |
| `3` | 左边 |
| `4` | 右边 |
| `5` | 左上角 |
| `6` | 右上角 |
| `7` | 左下角 |
| `8` | 右下角 |
| `9` | 隔板 |
## 7. 姿态字段顺序
默认姿态字段含义:

View File

@ -1,4 +1,4 @@
# WorkpieceTapered / WorkpieceRotor TCP 协议
# 锥形工件定位 / 转子钢芯定位 TCP 协议
## 1. 概述
@ -11,13 +11,6 @@
- 当前模式:眼在手外
- 请求和响应均不使用 JSON
适用项目:
- `WorkpieceTapered`:锥形工件定位
- `WorkpieceRotor`:转子钢芯定位
两个项目共用同一套 TCP/IP 协议格式。
## 2. 请求报文
格式:
@ -30,7 +23,6 @@
```text
S1\r\n
T1\r\n
```
字段说明:
@ -38,10 +30,10 @@ T1\r\n
| 字段 | 说明 |
|---|---|
| `S1` | `S`=工件检测,后跟相机索引 |
| `T1` | `T`=料框检测,后跟相机索引 |
本项目为眼在手外,检测请求不需要传入机械臂当前 `X/Y/Z/A/B/C`。
料框检测用于后续工件定位,不通过 TCP/IP 返回料框几何数据。
工件检测算法会在定位过程中同步计算所需的料框信息,不需要发送单独的料框检测请求,
也不通过 TCP/IP 返回料框几何数据。
## 3. 工件检测返回报文
@ -74,6 +66,21 @@ PointNum_Type_X_Y_Z_A_B_C[_Type_X_Y_Z_A_B_C...]\r\n
| `X/Y/Z` | 工件位置,单位 mm,保留 3 位小数 |
| `A/B/C` | 工件姿态,单位 deg,保留 3 位小数 |
`Type`(`workpieceType`)取值含义如下:
| `workpieceType` | 含义 |
|---:|---|
| `0` | 中央 |
| `1` | 上边 |
| `2` | 下边 |
| `3` | 左边 |
| `4` | 右边 |
| `5` | 左上角 |
| `6` | 右上角 |
| `7` | 左下角 |
| `8` | 右下角 |
| `9` | 隔板 |
本项目不输出接近点坐标,只输出工件定位结果。
## 4. 错误响应

View File

@ -80,6 +80,8 @@ struct VrRotorCoreParam
{
double radius = 45.0;
double height = 20.0;
double spacerLength = 720.0; // 隔板标称长度
double spacerWidth = 520.0; // 隔板标称宽度
double layerRatio = 0.5; // 分层系数
double distToSideRatio = 1.1; // 边距系数
double groundRemoveOffset = 200.0; // 地面去除Z偏置

View File

@ -169,6 +169,14 @@ int CVrConfig::LoadConfig(const std::string& filePath, ConfigResult& configResul
rotorParam.radius = rotorCoreParamElement->DoubleAttribute("radius");
if (rotorCoreParamElement->Attribute("height"))
rotorParam.height = rotorCoreParamElement->DoubleAttribute("height");
if (rotorCoreParamElement->Attribute("spacerLength"))
{
rotorParam.spacerLength = rotorCoreParamElement->DoubleAttribute("spacerLength");
}
if (rotorCoreParamElement->Attribute("spacerWidth"))
{
rotorParam.spacerWidth = rotorCoreParamElement->DoubleAttribute("spacerWidth");
}
if (rotorCoreParamElement->Attribute("layerRatio"))
rotorParam.layerRatio = rotorCoreParamElement->DoubleAttribute("layerRatio");
if (rotorCoreParamElement->Attribute("distToSideRatio"))
@ -437,6 +445,8 @@ bool CVrConfig::SaveConfig(const std::string& filePath, ConfigResult& configResu
XMLElement* rotorCoreParamElement = doc.NewElement("RotorCoreParam");
rotorCoreParamElement->SetAttribute("radius", configResult.algorithmParams.rotorCoreParam.radius);
rotorCoreParamElement->SetAttribute("height", configResult.algorithmParams.rotorCoreParam.height);
rotorCoreParamElement->SetAttribute("spacerLength", configResult.algorithmParams.rotorCoreParam.spacerLength);
rotorCoreParamElement->SetAttribute("spacerWidth", configResult.algorithmParams.rotorCoreParam.spacerWidth);
rotorCoreParamElement->SetAttribute("layerRatio", configResult.algorithmParams.rotorCoreParam.layerRatio);
rotorCoreParamElement->SetAttribute("distToSideRatio", configResult.algorithmParams.rotorCoreParam.distToSideRatio);
rotorCoreParamElement->SetAttribute("groundRemoveOffset", configResult.algorithmParams.rotorCoreParam.groundRemoveOffset);

View File

@ -28,7 +28,8 @@
minRectVertex1_0="5000.0" minRectVertex1_1="-5000.0" minRectVertex1_2="0.0"
minRectVertex2_0="5000.0" minRectVertex2_1="5000.0" minRectVertex2_2="0.0"
minRectVertex3_0="-5000.0" minRectVertex3_1="5000.0" minRectVertex3_2="0.0"/>
<RotorCoreParam radius="45.0" height="20.0" layerRatio="0.5" distToSideRatio="1.1" groundRemoveOffset="200.0"/>
<RotorCoreParam radius="45.0" height="20.0" spacerLength="720.0" spacerWidth="520.0"
layerRatio="0.5" distToSideRatio="1.1" groundRemoveOffset="200.0"/>
<PlaneCalibParams>
<CameraCalibParam cameraIndex="1" cameraName="Camera1" isCalibrated="false" planeHeight="-1.0"
planeCalib_00="1.0" planeCalib_01="0.0" planeCalib_02="0.0"