> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mrdvs.com/llms.txt
> Use this file to discover all available pages before exploring further.

# JSON 通信协议

> 相机与机器人或 PLC 之间的 TCP Socket JSON 通信格式与字段说明。

## 概述

相机作为 TCP Socket 服务端，默认监听端口为 `5501`。报文为文本格式，支持 ASCII 字符；建议使用 JSON 编码。

> [!NOTE]
>
> 本协议用于机器人或 PLC 触发 3D 检测，并接收相机返回的检测结果。

## 请求报文

向相机发送以下报文以触发 3D 视觉任务：

```json theme={null}
{"action":"3D"}
```

## 响应报文

相机完成检测后返回 JSON 对象。

**result** `integer` *required*

检测状态。值为 `0` 表示定位失败、无结果；其他整数表示识别成功，数值为返回结果数量。

**pos** `number[]` *required*

被测物位姿数组。每组结果依次为 `X`、`Y`、`Z`、`RX`、`RY`、`RZ`，采用机械臂坐标系。位置单位为 mm，角度单位为 °，且 `−180° ≤ RZ ≤ 180°`。检测失败时，各数值均为 `0`。

### 响应示例

**检测成功**

```json theme={null}
{"result":2,"pos":[100,107.3,1530,179,89,89,112,432.1,1500,179,89,75]}
```

**检测失败**

```json theme={null}
{"result":0,"pos":[0,0,0,0,0,0]}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.