组件类型更新
This commit is contained in:
@@ -72,7 +72,7 @@ Spring Boot 不自动读取 `.env`,需要通过 shell 导入。默认 profile
|
||||
|
||||
先选定最符合需求的唯一躯干,再沿接口逐层选件。interfaceType 优先确定目标类型,缺失/无效时从 child 的 LINK_ 后解析现有类别;双方 frames[].child 严格一致才连接,name 不参与匹配。每个数组元素独立占用,同款组件可复用为多个实例;明确 quantity 优先,省略时填满所需类型的可匹配接口,单次最多24个实例。汇总和替代均按实例处理。
|
||||
|
||||
后端只返回实例及接口下标的连接关系,不再计算装配矩阵;原始 urdfInfo 保留,由前端决定摆放。现有类别及默认模板不变,不新增 leg_0 或四足/六足模板。历史结果通过新消息重新生成,无需数据库迁移。
|
||||
后端只返回实例及接口下标的连接关系,不再计算装配矩阵;原始 urdfInfo 保留,由前端决定摆放。组件类型统一使用[完整12类大写编码](cadworld-api/docs/api.md#36-角色映射),足部为 LEG_L/LEG_R;旧小写及 pedal_l/pedal_r 兼容输入。默认模板不变,不新增 leg_0 或四足/六足模板。历史结果通过新消息重新生成,无需数据库迁移。
|
||||
|
||||
## 上传与接口
|
||||
|
||||
|
||||
+60
-54
@@ -57,7 +57,7 @@ X-Request-Id: frontend-match-001
|
||||
|
||||
```json
|
||||
{
|
||||
"requiredParts": ["torso_0", "arm_r"]
|
||||
"requiredParts": ["TORSO_0", "ARM_R"]
|
||||
}
|
||||
```
|
||||
|
||||
@@ -68,8 +68,8 @@ X-Request-Id: frontend-match-001
|
||||
"userInput": "我要一个双足跑步机器人,整体20自由度,质量不超过10kg,躯干用铝合金,右臂扭矩至少20N·m",
|
||||
"requirements": ["双足", "机器人", "跑步"],
|
||||
"requiredParts": [
|
||||
"torso_0", "head_0", "waist_0", "arm_l", "arm_r", "hand_l", "hand_r",
|
||||
"pedal_l", "pedal_r", "foot_l", "foot_r"
|
||||
"TORSO_0", "HEAD_0", "WAIST_0", "ARM_L", "ARM_R", "HAND_L", "HAND_R",
|
||||
"LEG_L", "LEG_R", "FOOT_L", "FOOT_R"
|
||||
],
|
||||
"robotRequirements": {
|
||||
"degreesOfFreedom": 20,
|
||||
@@ -78,8 +78,8 @@ X-Request-Id: frontend-match-001
|
||||
"operators": {"massKg": "lte"}
|
||||
},
|
||||
"partRequirements": [
|
||||
{"category": "torso_0", "material": "铝合金"},
|
||||
{"category": "arm_r", "torqueNm": 20, "operators": {"torqueNm": "gte"}}
|
||||
{"category": "TORSO_0", "material": "铝合金"},
|
||||
{"category": "ARM_R", "torqueNm": 20, "operators": {"torqueNm": "gte"}}
|
||||
]
|
||||
}
|
||||
```
|
||||
@@ -90,7 +90,7 @@ X-Request-Id: frontend-match-001
|
||||
| --- | --- | --- | --- |
|
||||
| `userInput` | string | 否 | 最多 4000 字符,仅作上下文;后端不解析、不存储,也不覆盖结构化条件 |
|
||||
| `requirements` | string[] | 否 | 最多 32 个关键词,每个非空且最多 128 字符;省略/null 表示无关键词要求 |
|
||||
| `requiredParts` | string[] | 是 | 非空,最多 24 项;中英文别名归一化后去重,组件类型去重但支持同类型多个实例;未列出躯干时自动补入唯一 `torso_0` |
|
||||
| `requiredParts` | string[] | 是 | 非空,最多 24 项;中英文别名归一化后去重,组件类型去重但支持同类型多个实例;未列出躯干时自动补入唯一 `TORSO_0` |
|
||||
| `robotRequirements` | object | 否 | 整机条件,字段见下表 |
|
||||
| `partRequirements` | object[] | 否 | 最多 12 项;每项对应一个角色的条件,字段见下表 |
|
||||
|
||||
@@ -144,16 +144,22 @@ X-Request-Id: frontend-match-001
|
||||
|
||||
| 中文类型 | 标准编码 |
|
||||
| --- | --- |
|
||||
| 躯干_0 | torso_0 |
|
||||
| 头_0 | head_0 |
|
||||
| 腰_0 | waist_0 |
|
||||
| 臂_l、臂_r | arm_l、arm_r |
|
||||
| 手_l、手_r | hand_l、hand_r |
|
||||
| 足_l、足_r | pedal_l、pedal_r |
|
||||
| 脚_l、脚_r | foot_l、foot_r |
|
||||
| 尾_0 | tail_0 |
|
||||
| 躯干_0 | TORSO_0 |
|
||||
| 头_0 | HEAD_0 |
|
||||
| 腰_0 | WAIST_0 |
|
||||
| 左臂 | ARM_L |
|
||||
| 右臂 | ARM_R |
|
||||
| 左手 | HAND_L |
|
||||
| 右手 | HAND_R |
|
||||
| 左足(腿部) | LEG_L |
|
||||
| 右足(腿部) | LEG_R |
|
||||
| 左脚 | FOOT_L |
|
||||
| 右脚 | FOOT_R |
|
||||
| 尾_0 | TAIL_0 |
|
||||
|
||||
输入接受中英文别名和英文大小写,响应返回标准编码。左右侧独立;`pedal` 对应足,`foot` 对应脚。
|
||||
以上12类为完整组件类型,公开响应统一使用大写标准编码。输入兼容英文大小写和原有中文别名;旧 `pedal_l/pedal_r` 兼容为 `LEG_L/LEG_R`。左右侧、足与脚独立,不互相替代。
|
||||
|
||||
组件库分类及 URDF `interfaceType` 均按上述类型识别,候选查询兼容已有大小写分类和旧足部编码;`interfaceType` 缺失时也可从 `LINK_LEG_L/LINK_LEG_R` 等 child 识别目标类型。原始 `urdfInfo` 保持不变,连接仍要求双方 `frames[].child` 区分大小写完全一致。实例编码同步使用大写类别,例如 `LEG_L:1`。
|
||||
|
||||
### 3.7 匹配结果的业务约定
|
||||
|
||||
@@ -161,7 +167,7 @@ X-Request-Id: frontend-match-001
|
||||
|
||||
先选定需求评分最高的一个躯干:按躯干自身条件的未满足数量、数值差距、功能文本和关键词相关性评价;需求评分相同时优先所需接口覆盖,最后按编码稳定排序。整机自由度、质量总量在选定躯干后的组合中评价,不直接作为躯干单件目标。
|
||||
|
||||
默认方案始终只有一个躯干且以 `torso_0` 为根,未列出躯干时自动补入。后续只沿这个躯干的接口路径匹配其他部件,在固定躯干下优先覆盖所需部件,再评价整机条件。选中的躯干不会因为另一个躯干能接更多部件而自动替换。参数与材质可降级,角色和连接规则始终保持匹配;不自动加入其他未要求的中间连接件。
|
||||
默认方案始终只有一个躯干且以 `TORSO_0` 为根,未列出躯干时自动补入。后续只沿这个躯干的接口路径匹配其他部件,在固定躯干下优先覆盖所需部件,再评价整机条件。选中的躯干不会因为另一个躯干能接更多部件而自动替换。参数与材质可降级,角色和连接规则始终保持匹配;不自动加入其他未要求的中间连接件。
|
||||
|
||||
无法覆盖所有角色时返回躯干及可拼的连通部分;选中的躯干没有所需端口时可只返回躯干。没有可用躯干则返回 `NO_MATCH`,不会用其他角色作为根。躯干替代候选用于替换当前躯干,不追加第二个躯干。
|
||||
|
||||
@@ -178,7 +184,7 @@ X-Request-Id: frontend-match-001
|
||||
| 字段 | 类型 | 内容 |
|
||||
| --- | --- | --- |
|
||||
| `status` | string | 匹配状态,见下表 |
|
||||
| `rootCategory` | string / null | 有结果时固定为 `torso_0`;无结果时为 null |
|
||||
| `rootCategory` | string / null | 有结果时固定为 `TORSO_0`;无结果时为 null |
|
||||
| `parts` | object[] | 默认选中组件,字段见 4.2 |
|
||||
| `connections` | object[] | 默认方案的整套父子连接,字段见 4.4 |
|
||||
| `alternatives` | object[] | 每个已选角色一个分组,每组最多 5 个兼容替代组件,字段见 4.5 |
|
||||
@@ -225,7 +231,7 @@ X-Request-Id: frontend-match-001
|
||||
|
||||
### 4.3 完整成功响应示例
|
||||
|
||||
以下响应对应 3.1 的最小请求 `{"requiredParts":["torso_0","arm_r"]}`,不是包含 11 个角色的整机请求。组件库提供了躯干、默认右臂和一个兼容的替代右臂。
|
||||
以下响应对应 3.1 的最小请求 `{"requiredParts":["TORSO_0","ARM_R"]}`,不是包含 11 个角色的整机请求。组件库提供了躯干、默认右臂和一个兼容的替代右臂。
|
||||
|
||||
```json
|
||||
{
|
||||
@@ -234,12 +240,12 @@ X-Request-Id: frontend-match-001
|
||||
"requestId": "example-request",
|
||||
"data": {
|
||||
"status": "MATCHED",
|
||||
"rootCategory": "torso_0",
|
||||
"rootCategory": "TORSO_0",
|
||||
"parts": [
|
||||
{
|
||||
"componentCode": "CW-00000000000000000000000000000001",
|
||||
"componentName": "铝合金躯干",
|
||||
"category": "torso_0",
|
||||
"category": "TORSO_0",
|
||||
"description": "机器人躯干",
|
||||
"material": "铝合金",
|
||||
"massKg": 2,
|
||||
@@ -267,7 +273,7 @@ X-Request-Id: frontend-match-001
|
||||
"type": "fixed",
|
||||
"parent": "BASE",
|
||||
"child": "LINK_arm_r",
|
||||
"interfaceType": "arm_r",
|
||||
"interfaceType": "ARM_R",
|
||||
"originExplicit": true,
|
||||
"xyz": [
|
||||
-0.1,
|
||||
@@ -291,12 +297,12 @@ X-Request-Id: frontend-match-001
|
||||
"version": 1,
|
||||
"stepUrl": "https://models.example.com/cadworld/components/CW-00000000000000000000000000000001/step/batch/model.STEP",
|
||||
"urdfUrl": "https://models.example.com/cadworld/components/CW-00000000000000000000000000000001/urdf/batch/robot.urdf",
|
||||
"instanceId": "torso_0:1"
|
||||
"instanceId": "TORSO_0:1"
|
||||
},
|
||||
{
|
||||
"componentCode": "CW-00000000000000000000000000000002",
|
||||
"componentName": "右臂",
|
||||
"category": "arm_r",
|
||||
"category": "ARM_R",
|
||||
"description": "机器人右臂",
|
||||
"material": "铝合金",
|
||||
"massKg": 1,
|
||||
@@ -322,7 +328,7 @@ X-Request-Id: frontend-match-001
|
||||
"type": "fixed",
|
||||
"parent": "ARM_BASE",
|
||||
"child": "LINK_arm_r",
|
||||
"interfaceType": "arm_r",
|
||||
"interfaceType": "ARM_R",
|
||||
"xyz": [
|
||||
0,
|
||||
0,
|
||||
@@ -339,20 +345,20 @@ X-Request-Id: frontend-match-001
|
||||
"version": 1,
|
||||
"stepUrl": "https://models.example.com/cadworld/components/CW-00000000000000000000000000000002/step/batch/model.STEP",
|
||||
"urdfUrl": "https://models.example.com/cadworld/components/CW-00000000000000000000000000000002/urdf/batch/robot.urdf",
|
||||
"instanceId": "arm_r:1"
|
||||
"instanceId": "ARM_R:1"
|
||||
}
|
||||
],
|
||||
"connections": [
|
||||
{
|
||||
"parentCategory": "torso_0",
|
||||
"parentCategory": "TORSO_0",
|
||||
"parentComponentCode": "CW-00000000000000000000000000000001",
|
||||
"parentLink": "BASE",
|
||||
"frameName": "J1",
|
||||
"childCategory": "arm_r",
|
||||
"childCategory": "ARM_R",
|
||||
"childComponentCode": "CW-00000000000000000000000000000002",
|
||||
"childRootLink": "ARM_BASE",
|
||||
"parentInstanceId": "torso_0:1",
|
||||
"childInstanceId": "arm_r:1",
|
||||
"parentInstanceId": "TORSO_0:1",
|
||||
"childInstanceId": "ARM_R:1",
|
||||
"interfaceChild": "LINK_arm_r",
|
||||
"parentFrameIndex": 0,
|
||||
"childFrameIndex": 0
|
||||
@@ -360,18 +366,18 @@ X-Request-Id: frontend-match-001
|
||||
],
|
||||
"alternatives": [
|
||||
{
|
||||
"category": "torso_0",
|
||||
"category": "TORSO_0",
|
||||
"items": [],
|
||||
"instanceId": "torso_0:1"
|
||||
"instanceId": "TORSO_0:1"
|
||||
},
|
||||
{
|
||||
"category": "arm_r",
|
||||
"category": "ARM_R",
|
||||
"items": [
|
||||
{
|
||||
"component": {
|
||||
"componentCode": "CW-00000000000000000000000000000003",
|
||||
"componentName": "高扭矩右臂",
|
||||
"category": "arm_r",
|
||||
"category": "ARM_R",
|
||||
"description": "机器人右臂",
|
||||
"material": "铝合金",
|
||||
"massKg": 1.2,
|
||||
@@ -400,7 +406,7 @@ X-Request-Id: frontend-match-001
|
||||
"type": "fixed",
|
||||
"parent": "ARM_V2_BASE",
|
||||
"child": "LINK_arm_r",
|
||||
"interfaceType": "arm_r",
|
||||
"interfaceType": "ARM_R",
|
||||
"xyz": [
|
||||
0,
|
||||
0,
|
||||
@@ -417,19 +423,19 @@ X-Request-Id: frontend-match-001
|
||||
"version": 1,
|
||||
"stepUrl": "https://models.example.com/cadworld/components/CW-00000000000000000000000000000003/step/batch/model.STEP",
|
||||
"urdfUrl": "https://models.example.com/cadworld/components/CW-00000000000000000000000000000003/urdf/batch/robot.urdf",
|
||||
"instanceId": "arm_r:1"
|
||||
"instanceId": "ARM_R:1"
|
||||
},
|
||||
"connections": [
|
||||
{
|
||||
"parentCategory": "torso_0",
|
||||
"parentCategory": "TORSO_0",
|
||||
"parentComponentCode": "CW-00000000000000000000000000000001",
|
||||
"parentLink": "BASE",
|
||||
"frameName": "J1",
|
||||
"childCategory": "arm_r",
|
||||
"childCategory": "ARM_R",
|
||||
"childComponentCode": "CW-00000000000000000000000000000003",
|
||||
"childRootLink": "ARM_V2_BASE",
|
||||
"parentInstanceId": "torso_0:1",
|
||||
"childInstanceId": "arm_r:1",
|
||||
"parentInstanceId": "TORSO_0:1",
|
||||
"childInstanceId": "ARM_R:1",
|
||||
"interfaceChild": "LINK_arm_r",
|
||||
"parentFrameIndex": 0,
|
||||
"childFrameIndex": 0
|
||||
@@ -445,7 +451,7 @@ X-Request-Id: frontend-match-001
|
||||
"unmatchedKeywords": []
|
||||
}
|
||||
],
|
||||
"instanceId": "arm_r:1"
|
||||
"instanceId": "ARM_R:1"
|
||||
}
|
||||
],
|
||||
"totals": {
|
||||
@@ -462,7 +468,7 @@ X-Request-Id: frontend-match-001
|
||||
}
|
||||
```
|
||||
|
||||
同款组件可重复出现在 parts 中,新增的 instanceId 在结果内唯一,例如 arm_r:1、arm_r:2。单次最多24个实例;数量或搜索达到上限时 searchLimited=true,仍返回已有组合。missingParts 增加 expectedQuantity、actualQuantity 和 missingQuantity,明确数量未达到时返回缺少的数量。默认方案及替代项均按实例累计质量和自由度。
|
||||
同款组件可重复出现在 parts 中,新增的 instanceId 在结果内唯一,例如 ARM_R:1、ARM_R:2。单次最多24个实例;数量或搜索达到上限时 searchLimited=true,仍返回已有组合。missingParts 增加 expectedQuantity、actualQuantity 和 missingQuantity,明确数量未达到时返回缺少的数量。默认方案及替代项均按实例累计质量和自由度。
|
||||
|
||||
### 4.4 连接字段 `connections[]`
|
||||
|
||||
@@ -545,14 +551,14 @@ X-Request-Id: frontend-match-001
|
||||
```json
|
||||
{
|
||||
"requirements": ["跑步"],
|
||||
"requiredParts": ["torso_0", "arm_r"],
|
||||
"requiredParts": ["TORSO_0", "ARM_R"],
|
||||
"robotRequirements": {
|
||||
"massKg": 2,
|
||||
"functionDescription": "跑步",
|
||||
"operators": {"massKg": "lte"}
|
||||
},
|
||||
"partRequirements": [
|
||||
{"category": "arm_r", "torqueNm": 30, "operators": {"torqueNm": "gte"}}
|
||||
{"category": "ARM_R", "torqueNm": 30, "operators": {"torqueNm": "gte"}}
|
||||
]
|
||||
}
|
||||
```
|
||||
@@ -562,11 +568,11 @@ X-Request-Id: frontend-match-001
|
||||
```json
|
||||
{
|
||||
"status": "FALLBACK",
|
||||
"rootCategory": "torso_0",
|
||||
"rootCategory": "TORSO_0",
|
||||
"totals": {"degreesOfFreedom": 4, "massKg": 3.2, "knownMassKg": 3.2, "massComplete": true},
|
||||
"unmetRequirements": [
|
||||
{
|
||||
"scope": "PART", "category": "arm_r", "field": "torqueNm", "operator": "gte",
|
||||
"scope": "PART", "category": "ARM_R", "field": "torqueNm", "operator": "gte",
|
||||
"expected": 30, "actual": 25, "reason": "VALUE_MISMATCH"
|
||||
},
|
||||
{
|
||||
@@ -592,7 +598,7 @@ X-Request-Id: frontend-match-001
|
||||
|
||||
```json
|
||||
{
|
||||
"requiredParts": ["torso_0", "head_0", "arm_r"]
|
||||
"requiredParts": ["TORSO_0", "HEAD_0", "ARM_R"]
|
||||
}
|
||||
```
|
||||
|
||||
@@ -601,7 +607,7 @@ X-Request-Id: frontend-match-001
|
||||
```json
|
||||
{
|
||||
"status": "PARTIAL",
|
||||
"rootCategory": "torso_0",
|
||||
"rootCategory": "TORSO_0",
|
||||
"totals": {
|
||||
"degreesOfFreedom": 4,
|
||||
"massKg": 3,
|
||||
@@ -612,7 +618,7 @@ X-Request-Id: frontend-match-001
|
||||
"unmatchedKeywords": [],
|
||||
"missingParts": [
|
||||
{
|
||||
"category": "head_0",
|
||||
"category": "HEAD_0",
|
||||
"reason": "NO_COMPONENT",
|
||||
"expectedQuantity": 1,
|
||||
"actualQuantity": 0,
|
||||
@@ -632,7 +638,7 @@ X-Request-Id: frontend-match-001
|
||||
```json
|
||||
{
|
||||
"requirements": ["跑步"],
|
||||
"requiredParts": ["torso_0", "arm_r"]
|
||||
"requiredParts": ["TORSO_0", "ARM_R"]
|
||||
}
|
||||
```
|
||||
|
||||
@@ -661,14 +667,14 @@ X-Request-Id: frontend-match-001
|
||||
],
|
||||
"missingParts": [
|
||||
{
|
||||
"category": "torso_0",
|
||||
"category": "TORSO_0",
|
||||
"reason": "NO_COMPONENT",
|
||||
"expectedQuantity": 1,
|
||||
"actualQuantity": 0,
|
||||
"missingQuantity": 1
|
||||
},
|
||||
{
|
||||
"category": "arm_r",
|
||||
"category": "ARM_R",
|
||||
"reason": "NO_COMPONENT",
|
||||
"expectedQuantity": 1,
|
||||
"actualQuantity": 0,
|
||||
@@ -707,7 +713,7 @@ HTTP 200,完整响应示例:
|
||||
"data": {
|
||||
"componentCode": "CW-00000000000000000000000000000001",
|
||||
"componentName": "铝合金躯干",
|
||||
"category": "torso_0",
|
||||
"category": "TORSO_0",
|
||||
"description": "机器人躯干",
|
||||
"material": "铝合金",
|
||||
"massKg": 2,
|
||||
@@ -730,7 +736,7 @@ HTTP 200,完整响应示例:
|
||||
"type": "fixed",
|
||||
"parent": "BASE",
|
||||
"child": "LINK_arm_r",
|
||||
"interfaceType": "arm_r",
|
||||
"interfaceType": "ARM_R",
|
||||
"originExplicit": true,
|
||||
"xyz": [-0.1, 0.01, 0],
|
||||
"rpy": [0, -1.5707963267949, 0],
|
||||
@@ -785,7 +791,7 @@ HTTP 200,完整响应示例:
|
||||
|
||||
```json
|
||||
{
|
||||
"requiredParts": ["arm_r"],
|
||||
"requiredParts": ["ARM_R"],
|
||||
"robotRequirements": {"degreesOfFreedom": "20"}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# 需求解析后端接入与部署
|
||||
|
||||
已按 `/Users/edy/Downloads/robot-demand-parser-v1` 的 README、backend-handoff、protocol,以及 `index.mjs` / `mechanical-rules.mjs` 移植 Java 程序校验。自动拼装输出版本为 `multimodal-v1.3-child-instances`,目录版本为 `2026-10-14-auto-assembly`。原始来源作为参考保留,当前提示词与 Java 规则已调整为无追问的自动生成流程。来源文件夹保持不变,运行时不依赖 Node、React 或前端解析脚本。
|
||||
已按 `/Users/edy/Downloads/robot-demand-parser-v1` 的 README、backend-handoff、protocol,以及 `index.mjs` / `mechanical-rules.mjs` 移植 Java 程序校验。自动拼装输出版本为 `multimodal-v1.4-component-types`,目录版本为 `2026-10-16-component-types`。原始来源作为参考保留,当前提示词与 Java 规则已调整为无追问的自动生成流程。来源文件夹保持不变,运行时不依赖 Node、React 或前端解析脚本。
|
||||
|
||||
业务标准化另外落实躯干优先规则:整机必须且只能有一个躯干,解析时可自动补入基础躯干;明确排除躯干时保留排除项并返回无匹配方案,不追问或偷偷补入。匹配先固定最符合需求的躯干,再搜索与其连通的其他组件。
|
||||
|
||||
@@ -81,13 +81,13 @@ java -jar cadworld-api/target/cadworld-api-0.0.1-SNAPSHOT.jar
|
||||
{
|
||||
"name": "incoming",
|
||||
"child": "LINK_arm_r",
|
||||
"interfaceType": "arm_r"
|
||||
"interfaceType": "ARM_R"
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
父接口也有 child=LINK_arm_r、目标类型为 arm_r 时,可以连接这件右臂。多个同 child 的 frames 元素为多个独立接口,原始数组不重排;连接双方以实例标识及 frameIndex 占用接口。先处理固定躯干的接口,再逐层扩展,先覆盖需求类型和明确数量,再在尽量满足硬要求的前提下填充其他兼容接口,避免自动增补破坏本可满足的整机参数。
|
||||
父接口也有 child=LINK_arm_r、目标类型为 ARM_R 时,可以连接这件右臂。多个同 child 的 frames 元素为多个独立接口,原始数组不重排;连接双方以实例标识及 frameIndex 占用接口。先处理固定躯干的接口,再逐层扩展,先覆盖需求类型和明确数量,再在尽量满足硬要求的前提下填充其他兼容接口,避免自动增补破坏本可满足的整机参数。
|
||||
|
||||
结构化结果的实例标识为 category:序号;AI 外层实例标识为 matchId:category:序号,序号从1开始。connection 返回 interfaceChild 和双方 parentFrameIndex/childFrameIndex;不再返回 matrixLayout、装配矩阵或连接摆放用 xyz/rpy。完整 urdfInfo 仍返回原始 JSON,由前端解析各实例模型并定位。资源URL可缓存共享,模型实例必须独立。
|
||||
|
||||
|
||||
@@ -2,6 +2,19 @@
|
||||
|
||||
服务地址默认 `http://127.0.0.1:8991`。本流程接收用户文字、图片,自动理解需求、选件并校验装配,完成响应直接包含机器人方案。无需追问、确认或接受降级后才能显示。所有 JSON 接口和 SSE 事件数据沿用 `{code, message, data, requestId}`。
|
||||
|
||||
本文已按当前后端代码核对(2026-10-16),新生成结果的 `result.analysis.schemaVersion` 为 `multimodal-v1.4-component-types`。新方案的类别和实例编码使用[完整12类大写编码](api.md#36-角色映射),足部使用 `LEG_L/LEG_R`;旧小写及 `pedal_l/pedal_r` 仅作为兼容输入,原始 URDF 数据保持不变。本次对接变化如下:
|
||||
|
||||
| 位置 | 当前约定 |
|
||||
| --- | --- |
|
||||
| 消息请求体 | 仍只有 `messageId`、`text`、`attachmentIds`;数量等需求写在自然语言中 |
|
||||
| `data.result.request.partRequirements[]` | 后端解析出的部位条件,新增可选 `quantity`;它不是消息接口的请求体字段 |
|
||||
| `data.match.components[]` | 保留组件包装结构,外层 `instanceId` 区分同款组件的多个实例 |
|
||||
| `data.match.assembly.connections[]` | 双方实例编码、共同 `interfaceChild` 和双方原始 frames 下标;不再返回摆放矩阵及连接中的 xyz/rpy |
|
||||
| `data.match.alternatives[]` | 按目标 `instanceId` 分组,切换时只替换该实例 |
|
||||
| `data.match.missingParts[]` | 包含期望、实际、缺少数量;缺件时仍可展示已有连通组合 |
|
||||
|
||||
历史快照不会自动升级,联调新协议时请使用新的 `messageId` 生成结果。
|
||||
|
||||
## 1. 前端调用顺序
|
||||
|
||||
1. 创建会话,保存 `conversationId`。
|
||||
@@ -98,6 +111,8 @@ AI 对话拼装仅保留以上 7 个接口。原 `confirm`、`rematch`、按 `ma
|
||||
| `text` | string | 是 | 最多 20000 字符;仅图片时传空字符串 |
|
||||
| `attachmentIds` | string[] | 否 | 最多 4 张,不重复;省略/null 表示无图 |
|
||||
|
||||
部位、数量、材质等要求直接写入 `text`,例如“拼一个躯干和4个右臂”。后端会把明确数量写入返回的 `data.result.request.partRequirements[].quantity`。消息请求体无需增加 `quantity`、`requiredParts` 或 `partRequirements`;直接提交结构化条件请使用 [POST /api/robot-matches](api.md)。
|
||||
|
||||
文字和图片不能同时为空。相同编号但不同内容返回 409。历史由后端保存,不传 `role`、`messages`、客户端解析结果。最多 40 条历史消息(旧会话可能包含历史助手消息,新流程不写入追问);图片原始字节总量最多 30MiB,编码后的模型请求最多 40MiB;超限时新建会话。
|
||||
|
||||
### SSE 事件
|
||||
@@ -184,7 +199,7 @@ async function sendMessage(conversationId, message, onEvent, signal) {
|
||||
"summary": "右臂扭矩至少20N·m",
|
||||
"questions": [],
|
||||
"warnings": [
|
||||
"整机拼装固定一个躯干,已补入torso_0作为基础组件。"
|
||||
"整机拼装固定一个躯干,已补入TORSO_0作为基础组件。"
|
||||
],
|
||||
"result": {
|
||||
"request": {
|
||||
@@ -193,17 +208,18 @@ async function sendMessage(conversationId, message, onEvent, signal) {
|
||||
"右臂"
|
||||
],
|
||||
"requiredParts": [
|
||||
"torso_0",
|
||||
"arm_r"
|
||||
"TORSO_0",
|
||||
"ARM_R"
|
||||
],
|
||||
"robotRequirements": {},
|
||||
"partRequirements": [
|
||||
{
|
||||
"category": "arm_r",
|
||||
"category": "ARM_R",
|
||||
"torqueNm": 20,
|
||||
"operators": {
|
||||
"torqueNm": "gte"
|
||||
}
|
||||
},
|
||||
"quantity": 1
|
||||
}
|
||||
]
|
||||
},
|
||||
@@ -221,7 +237,7 @@ async function sendMessage(conversationId, message, onEvent, signal) {
|
||||
"robotTypes": [],
|
||||
"partCategories": [
|
||||
{
|
||||
"category": "arm_r",
|
||||
"category": "ARM_R",
|
||||
"source": "explicit",
|
||||
"reason": "用户指定部件",
|
||||
"evidence": "我要一个右臂,扭矩至少20N·m"
|
||||
@@ -233,20 +249,31 @@ async function sendMessage(conversationId, message, onEvent, signal) {
|
||||
{
|
||||
"scope": "part",
|
||||
"categories": [
|
||||
"arm_r"
|
||||
"ARM_R"
|
||||
],
|
||||
"field": "torqueNm",
|
||||
"value": "20N·m",
|
||||
"upperValue": "",
|
||||
"operator": "gte",
|
||||
"evidence": "我要一个右臂,扭矩至少20N·m"
|
||||
},
|
||||
{
|
||||
"scope": "part",
|
||||
"field": "quantity",
|
||||
"value": 1,
|
||||
"upperValue": "",
|
||||
"operator": "eq",
|
||||
"evidence": "我要一个右臂,扭矩至少20N·m",
|
||||
"categories": [
|
||||
"ARM_R"
|
||||
]
|
||||
}
|
||||
],
|
||||
"questions": [],
|
||||
"warnings": [
|
||||
"整机拼装固定一个躯干,已补入torso_0作为基础组件。"
|
||||
"整机拼装固定一个躯干,已补入TORSO_0作为基础组件。"
|
||||
],
|
||||
"catalogVersion": "2026-10-14-auto-assembly",
|
||||
"catalogVersion": "2026-10-16-component-types",
|
||||
"observations": [
|
||||
{
|
||||
"id": "e1",
|
||||
@@ -270,6 +297,18 @@ async function sendMessage(conversationId, message, onEvent, signal) {
|
||||
"e1"
|
||||
],
|
||||
"evidence": "我要一个右臂,扭矩至少20N·m"
|
||||
},
|
||||
{
|
||||
"id": "r2",
|
||||
"dimension": "quantity",
|
||||
"subject": "右臂",
|
||||
"requirement": "一个右臂",
|
||||
"priority": "must",
|
||||
"source": "explicit",
|
||||
"evidenceIds": [
|
||||
"e1"
|
||||
],
|
||||
"evidence": "我要一个右臂,扭矩至少20N·m"
|
||||
}
|
||||
],
|
||||
"images": [],
|
||||
@@ -281,7 +320,7 @@ async function sendMessage(conversationId, message, onEvent, signal) {
|
||||
]
|
||||
}
|
||||
],
|
||||
"schemaVersion": "multimodal-v1.3-child-instances",
|
||||
"schemaVersion": "multimodal-v1.4-component-types",
|
||||
"canSubmit": true,
|
||||
"status": "ready",
|
||||
"defaultTemplate": ""
|
||||
@@ -292,7 +331,7 @@ async function sendMessage(conversationId, message, onEvent, signal) {
|
||||
"revision": 1,
|
||||
"matchId": "DM-33333333333333333333333333333333",
|
||||
"status": "complete",
|
||||
"rootCategory": "torso_0",
|
||||
"rootCategory": "TORSO_0",
|
||||
"searchLimited": false,
|
||||
"degradationAcceptanceRequired": false,
|
||||
"degradationAccepted": false,
|
||||
@@ -314,17 +353,26 @@ async function sendMessage(conversationId, message, onEvent, signal) {
|
||||
"expected": 20,
|
||||
"actual": 25,
|
||||
"reason": "所选组件的登记参数满足该条件"
|
||||
},
|
||||
{
|
||||
"intentId": "r2",
|
||||
"priority": "must",
|
||||
"status": "satisfied",
|
||||
"field": "quantity",
|
||||
"expected": 1,
|
||||
"actual": 1,
|
||||
"reason": "所选组件实例数量满足条件"
|
||||
}
|
||||
],
|
||||
"assembly": {
|
||||
"status": "ready",
|
||||
"rootInstanceId": "DM-33333333333333333333333333333333:torso_0:1",
|
||||
"rootInstanceId": "DM-33333333333333333333333333333333:TORSO_0:1",
|
||||
"connections": [
|
||||
{
|
||||
"parentInstanceId": "DM-33333333333333333333333333333333:torso_0:1",
|
||||
"parentInstanceId": "DM-33333333333333333333333333333333:TORSO_0:1",
|
||||
"parentFrame": "J_ARM",
|
||||
"parentLink": "BASE",
|
||||
"childInstanceId": "DM-33333333333333333333333333333333:arm_r:1",
|
||||
"childInstanceId": "DM-33333333333333333333333333333333:ARM_R:1",
|
||||
"childFrame": "INCOMING_arm_r",
|
||||
"childRootLink": "ARM_ROOT",
|
||||
"interfaceChild": "LINK_arm_r",
|
||||
@@ -336,11 +384,11 @@ async function sendMessage(conversationId, message, onEvent, signal) {
|
||||
},
|
||||
"components": [
|
||||
{
|
||||
"instanceId": "DM-33333333333333333333333333333333:torso_0:1",
|
||||
"instanceId": "DM-33333333333333333333333333333333:TORSO_0:1",
|
||||
"component": {
|
||||
"componentCode": "CW-TORSO-001",
|
||||
"componentName": "铝合金躯干",
|
||||
"category": "torso_0",
|
||||
"category": "TORSO_0",
|
||||
"description": "机器人躯干",
|
||||
"material": "铝合金",
|
||||
"massKg": 2,
|
||||
@@ -366,7 +414,7 @@ async function sendMessage(conversationId, message, onEvent, signal) {
|
||||
"type": "fixed",
|
||||
"parent": "BASE",
|
||||
"child": "LINK_arm_r",
|
||||
"interfaceType": "arm_r",
|
||||
"interfaceType": "ARM_R",
|
||||
"originExplicit": true,
|
||||
"xyz": [
|
||||
0.1,
|
||||
@@ -409,11 +457,11 @@ async function sendMessage(conversationId, message, onEvent, signal) {
|
||||
"resourceIssues": []
|
||||
},
|
||||
{
|
||||
"instanceId": "DM-33333333333333333333333333333333:arm_r:1",
|
||||
"instanceId": "DM-33333333333333333333333333333333:ARM_R:1",
|
||||
"component": {
|
||||
"componentCode": "CW-ARM-001",
|
||||
"componentName": "标准右臂",
|
||||
"category": "arm_r",
|
||||
"category": "ARM_R",
|
||||
"description": "机器人右臂",
|
||||
"material": "铝合金",
|
||||
"massKg": 1.2,
|
||||
@@ -444,7 +492,7 @@ async function sendMessage(conversationId, message, onEvent, signal) {
|
||||
"type": "fixed",
|
||||
"parent": "ARM_ROOT",
|
||||
"child": "LINK_arm_r",
|
||||
"interfaceType": "arm_r",
|
||||
"interfaceType": "ARM_R",
|
||||
"xyz": [
|
||||
0,
|
||||
0,
|
||||
@@ -456,11 +504,7 @@ async function sendMessage(conversationId, message, onEvent, signal) {
|
||||
0
|
||||
]
|
||||
}
|
||||
],
|
||||
"assembly": {
|
||||
"mountingFrame": "ARM_ROOT",
|
||||
"pairingConvention": "coincident_frames"
|
||||
}
|
||||
]
|
||||
},
|
||||
"version": 2,
|
||||
"stepUrl": "https://models.example.com/cadworld/components/CW-ARM-001/step/batch-a/arm.step",
|
||||
@@ -486,14 +530,14 @@ async function sendMessage(conversationId, message, onEvent, signal) {
|
||||
],
|
||||
"alternatives": [
|
||||
{
|
||||
"category": "torso_0",
|
||||
"category": "TORSO_0",
|
||||
"items": [],
|
||||
"instanceId": "DM-33333333333333333333333333333333:torso_0:1"
|
||||
"instanceId": "DM-33333333333333333333333333333333:TORSO_0:1"
|
||||
},
|
||||
{
|
||||
"category": "arm_r",
|
||||
"category": "ARM_R",
|
||||
"items": [],
|
||||
"instanceId": "DM-33333333333333333333333333333333:arm_r:1"
|
||||
"instanceId": "DM-33333333333333333333333333333333:ARM_R:1"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -509,6 +553,8 @@ async function sendMessage(conversationId, message, onEvent, signal) {
|
||||
| `questions` | 新生成结果固定为 `[]`,不发起追问 |
|
||||
| `warnings` | 来源、推断或能力承载方面的说明,供核对 |
|
||||
| `result.request` | 规范化五字段需求;未提供的约束不会补成 0 |
|
||||
| `result.request.partRequirements[].quantity` | 部位实例数量,整数 1–24;省略/null 表示按可匹配接口填充,躯干固定一个;第 5 节给出多实例示例 |
|
||||
| `result.analysis.schemaVersion` | 新生成结果为 `multimodal-v1.4-component-types`;旧快照可能仍为旧协议 |
|
||||
| `result.analysis.intentItems` | 逐项需求,`must` 硬要求、`prefer` 偏好、`context` 参考;用于结果说明和逐项核对 |
|
||||
| `result.analysis.defaultTemplate` | 没有可匹配类型或部位时使用的默认模板编码,目前为 `biped`;没有采用默认模板时为空字符串 |
|
||||
| `match` | 已保存的完整机器人方案,包含组件资源、装配连接、缺件和逐项校验;处理未完成或已失效时为空 |
|
||||
@@ -526,12 +572,12 @@ async function sendMessage(conversationId, message, onEvent, signal) {
|
||||
|
||||
| 字段 | 说明 |
|
||||
| --- | --- |
|
||||
| `status` | `complete`:所需角色齐全且硬要求已验证满足;`partial`:缺件、硬要求未满足或未验证;`no_match`:没有可用组件 |
|
||||
| `status` | `complete`:所需类型及明确数量齐全且硬要求已验证满足;`partial`:缺件、数量不足、硬要求未满足或未验证;`no_match`:没有可用躯干,或明确排除躯干而无法生成组合 |
|
||||
| `components[]` | 稳定实例编码 + 完整公开组件 DTO,保留原始 `bomList` 和 `urdfInfo` JSON |
|
||||
| `alternatives[]` | 每个已选实例最多 5 个兼容替代项,以 `instanceId` 区分,见下文 |
|
||||
| `requirementChecks[]` | 对应 `intentId`,状态 `satisfied` / `unmet` / `unverified`;前端关联解析中的详细需求 |
|
||||
| `unmetRequirements` | 字段差距,包括偏好差距;硬要求判定以详细校验为准 |
|
||||
| `totals` | 组件标称参数求和;不重复统计 BOM。质量未知时 `massKg=null`,`knownMassKg` 为已知部分 |
|
||||
| `totals` | 按实例累计组件标称参数,同款组件安装 4 次就累计 4 次;不重复统计 BOM。质量未知时 `massKg=null`,`knownMassKg` 为已知部分 |
|
||||
| `missingParts` | 缺失角色和原因,仅提示完整性,不阻塞已有组件装配;没有可用躯干时返回 `no_match`,其他现存角色可标记 `NO_TORSO`;仍是 HTTP 200 |
|
||||
| `searchLimited` | 候选或搜索被截断,本方案不是已证明的全局最优 |
|
||||
| `degradationAcceptanceRequired` | 新生成方案及替代候选固定为 false;缺件和未满足/未验证项作为结果说明,不要求先接受 |
|
||||
@@ -543,7 +589,7 @@ async function sendMessage(conversationId, message, onEvent, signal) {
|
||||
|
||||
拼装仅检索同时具备非空 `step_object_key` 和已上传 URDF 主文件(非空 `urdf_main_object_key`)的组件;消息自动生成和替代候选使用同一筛选规则。仅上传 STEP 的组件不会参与拼装。接口以合法 `interfaceType` 确定目标 category,缺失或无效时从 `child` 的 LINK_ 后解析现有类别;只连接用户需求涉及的类型,且双方原始 `frames[].child` 必须非空并严格一致(区分大小写)。`name` 不参与兼容性判断。无法识别类型或无有效 child 的接口跳过并提示,不阻塞已有组合。
|
||||
|
||||
整机结果始终以 `torso_0` 为根,默认方案中的躯干只有一个。用户未单独提出躯干时,后端在规范化的 `requiredParts` 中补入 `torso_0` 并返回说明;原始对话和提取的用户条目保持其来源。明确要求“不要躯干”时保留排除项,返回 `no_match`、`missingParts.reason=EXCLUDED_TORSO`,不会偷偷补入躯干;同款组件支持多个独立实例,躯干始终固定一个。
|
||||
整机结果始终以 `TORSO_0` 为根,默认方案中的躯干只有一个。用户未单独提出躯干时,后端在规范化的 `requiredParts` 中补入 `TORSO_0` 并返回说明;原始对话和提取的用户条目保持其来源。明确要求“不要躯干”时保留排除项,返回 `no_match`、`missingParts.reason=EXCLUDED_TORSO`,不会偷偷补入躯干;同款组件支持多个独立实例,躯干始终固定一个。
|
||||
|
||||
躯干先按自身硬条件、数值差距、偏好、整机功能文本与关键词相关性排序;这些条件相同后优先选择能接更多所需角色的接口集合,最后按编码稳定排序。整机自由度和质量目标在后续组合阶段评价,不直接当作躯干单件的数值要求。
|
||||
|
||||
@@ -556,12 +602,12 @@ async function sendMessage(conversationId, message, onEvent, signal) {
|
||||
```json
|
||||
{
|
||||
"status": "partial",
|
||||
"rootCategory": "torso_0",
|
||||
"rootCategory": "TORSO_0",
|
||||
"degradationAcceptanceRequired": false,
|
||||
"degradationAccepted": false,
|
||||
"missingParts": [
|
||||
{
|
||||
"category": "head_0",
|
||||
"category": "HEAD_0",
|
||||
"reason": "NO_COMPONENT",
|
||||
"expectedQuantity": 1,
|
||||
"actualQuantity": 0,
|
||||
@@ -570,13 +616,13 @@ async function sendMessage(conversationId, message, onEvent, signal) {
|
||||
],
|
||||
"assembly": {
|
||||
"status": "ready",
|
||||
"rootInstanceId": "DM-33333333333333333333333333333333:torso_0:1",
|
||||
"rootInstanceId": "DM-33333333333333333333333333333333:TORSO_0:1",
|
||||
"connections": [
|
||||
{
|
||||
"parentInstanceId": "DM-33333333333333333333333333333333:torso_0:1",
|
||||
"parentInstanceId": "DM-33333333333333333333333333333333:TORSO_0:1",
|
||||
"parentFrame": "J_ARM",
|
||||
"parentLink": "BASE",
|
||||
"childInstanceId": "DM-33333333333333333333333333333333:arm_r:1",
|
||||
"childInstanceId": "DM-33333333333333333333333333333333:ARM_R:1",
|
||||
"childFrame": "INCOMING_arm_r",
|
||||
"childRootLink": "ARM_ROOT",
|
||||
"interfaceChild": "LINK_arm_r",
|
||||
@@ -595,120 +641,131 @@ async function sendMessage(conversationId, message, onEvent, signal) {
|
||||
|
||||
### 替代项示例
|
||||
|
||||
下面是 `alternatives[].items[]` 的完整对象示例,仍是同一右臂角色:
|
||||
下面是一个完整的 `alternatives[]` 分组示例,`instanceId` 指定被替换的右臂实例,`items[]` 是可替换它的候选组件。没有可用替代项时该分组的 `items=[]`:
|
||||
|
||||
```json
|
||||
{
|
||||
"component": {
|
||||
"componentCode": "CW-ARM-002",
|
||||
"componentName": "大扭矩右臂",
|
||||
"category": "arm_r",
|
||||
"description": "机器人右臂",
|
||||
"material": "铝合金",
|
||||
"massKg": 1.5,
|
||||
"degreesOfFreedom": 4,
|
||||
"rotationAxis": null,
|
||||
"functionDescription": "抓取",
|
||||
"shape": "长条",
|
||||
"size": "小型",
|
||||
"torqueNm": 30,
|
||||
"bomList": {
|
||||
"parts": [
|
||||
{
|
||||
"partCode": "MOTOR-01",
|
||||
"quantity": 4,
|
||||
"specification": {
|
||||
"ratedTorqueNm": 25
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"urdfInfo": {
|
||||
"robotName": "大扭矩右臂",
|
||||
"rootLink": "ARM_V2_ROOT",
|
||||
"frames": [
|
||||
{
|
||||
"name": "INCOMING_arm_r",
|
||||
"kind": "joint",
|
||||
"type": "fixed",
|
||||
"parent": "ARM_V2_ROOT",
|
||||
"child": "LINK_arm_r",
|
||||
"interfaceType": "arm_r",
|
||||
"xyz": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"rpy": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
"category": "ARM_R",
|
||||
"instanceId": "DM-33333333333333333333333333333333:ARM_R:1",
|
||||
"items": [
|
||||
{
|
||||
"component": {
|
||||
"componentCode": "CW-ARM-002",
|
||||
"componentName": "大扭矩右臂",
|
||||
"category": "ARM_R",
|
||||
"description": "机器人右臂",
|
||||
"material": "铝合金",
|
||||
"massKg": 1.5,
|
||||
"degreesOfFreedom": 4,
|
||||
"rotationAxis": null,
|
||||
"functionDescription": "抓取",
|
||||
"shape": "长条",
|
||||
"size": "小型",
|
||||
"torqueNm": 30,
|
||||
"bomList": {
|
||||
"parts": [
|
||||
{
|
||||
"partCode": "MOTOR-01",
|
||||
"quantity": 4,
|
||||
"specification": {
|
||||
"ratedTorqueNm": 25
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"urdfInfo": {
|
||||
"robotName": "大扭矩右臂",
|
||||
"rootLink": "ARM_V2_ROOT",
|
||||
"frames": [
|
||||
{
|
||||
"name": "INCOMING_arm_r",
|
||||
"kind": "joint",
|
||||
"type": "fixed",
|
||||
"parent": "ARM_V2_ROOT",
|
||||
"child": "LINK_arm_r",
|
||||
"interfaceType": "ARM_R",
|
||||
"xyz": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"rpy": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
"version": 1,
|
||||
"stepUrl": "https://models.example.com/cadworld/components/CW-ARM-002/step/batch-a/arm.step",
|
||||
"urdfUrl": "https://models.example.com/cadworld/components/CW-ARM-002/urdf/batch-a/robot.urdf"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"relativePath": "robot.urdf",
|
||||
"url": "https://models.example.com/cadworld/components/CW-ARM-002/urdf/batch-a/robot.urdf",
|
||||
"version": 1,
|
||||
"expiresAt": null
|
||||
},
|
||||
{
|
||||
"relativePath": "meshes/arm.stl",
|
||||
"url": "https://models.example.com/cadworld/components/CW-ARM-002/urdf/batch-a/meshes/arm.stl",
|
||||
"version": 1,
|
||||
"expiresAt": null
|
||||
}
|
||||
],
|
||||
"resourceIssues": [],
|
||||
"urdfMainPath": "robot.urdf",
|
||||
"totals": {
|
||||
"degreesOfFreedom": 4,
|
||||
"massKg": 3.5,
|
||||
"knownMassKg": 3.5,
|
||||
"massComplete": true
|
||||
},
|
||||
"unmetRequirements": [],
|
||||
"unmatchedKeywords": [],
|
||||
"requirementChecks": [
|
||||
{
|
||||
"intentId": "r1",
|
||||
"priority": "must",
|
||||
"status": "satisfied",
|
||||
"field": "torqueNm",
|
||||
"expected": 20,
|
||||
"actual": 30,
|
||||
"reason": "所选组件的登记参数满足该条件"
|
||||
},
|
||||
{
|
||||
"intentId": "r2",
|
||||
"priority": "must",
|
||||
"status": "satisfied",
|
||||
"field": "quantity",
|
||||
"expected": 1,
|
||||
"actual": 1,
|
||||
"reason": "所选组件实例数量满足条件"
|
||||
}
|
||||
],
|
||||
"assembly": {
|
||||
"mountingFrame": "ARM_V2_ROOT",
|
||||
"pairingConvention": "coincident_frames"
|
||||
}
|
||||
},
|
||||
"version": 1,
|
||||
"stepUrl": "https://models.example.com/cadworld/components/CW-ARM-002/step/batch-a/arm.step",
|
||||
"urdfUrl": "https://models.example.com/cadworld/components/CW-ARM-002/urdf/batch-a/robot.urdf"
|
||||
},
|
||||
"resources": [
|
||||
{
|
||||
"relativePath": "robot.urdf",
|
||||
"url": "https://models.example.com/cadworld/components/CW-ARM-002/urdf/batch-a/robot.urdf",
|
||||
"version": 1,
|
||||
"expiresAt": null
|
||||
},
|
||||
{
|
||||
"relativePath": "meshes/arm.stl",
|
||||
"url": "https://models.example.com/cadworld/components/CW-ARM-002/urdf/batch-a/meshes/arm.stl",
|
||||
"version": 1,
|
||||
"expiresAt": null
|
||||
"status": "ready",
|
||||
"rootInstanceId": "DM-33333333333333333333333333333333:TORSO_0:1",
|
||||
"connections": [
|
||||
{
|
||||
"parentInstanceId": "DM-33333333333333333333333333333333:TORSO_0:1",
|
||||
"parentFrame": "J_ARM",
|
||||
"parentLink": "BASE",
|
||||
"childInstanceId": "DM-33333333333333333333333333333333:ARM_R:1",
|
||||
"childFrame": "INCOMING_arm_r",
|
||||
"childRootLink": "ARM_V2_ROOT",
|
||||
"interfaceChild": "LINK_arm_r",
|
||||
"parentFrameIndex": 0,
|
||||
"childFrameIndex": 0
|
||||
}
|
||||
],
|
||||
"issues": []
|
||||
},
|
||||
"degradationAcceptanceRequired": false
|
||||
}
|
||||
],
|
||||
"resourceIssues": [],
|
||||
"urdfMainPath": "robot.urdf",
|
||||
"totals": {
|
||||
"degreesOfFreedom": 4,
|
||||
"massKg": 3.5,
|
||||
"knownMassKg": 3.5,
|
||||
"massComplete": true
|
||||
},
|
||||
"unmetRequirements": [],
|
||||
"unmatchedKeywords": [],
|
||||
"requirementChecks": [
|
||||
{
|
||||
"intentId": "r1",
|
||||
"priority": "must",
|
||||
"status": "satisfied",
|
||||
"field": "torqueNm",
|
||||
"expected": 20,
|
||||
"actual": 30,
|
||||
"reason": "所选组件的登记参数满足该条件"
|
||||
}
|
||||
],
|
||||
"assembly": {
|
||||
"status": "ready",
|
||||
"rootInstanceId": "DM-33333333333333333333333333333333:torso_0:1",
|
||||
"connections": [
|
||||
{
|
||||
"parentInstanceId": "DM-33333333333333333333333333333333:torso_0:1",
|
||||
"parentFrame": "J_ARM",
|
||||
"parentLink": "BASE",
|
||||
"childInstanceId": "DM-33333333333333333333333333333333:arm_r:1",
|
||||
"childFrame": "INCOMING_arm_r",
|
||||
"childRootLink": "ARM_V2_ROOT",
|
||||
"interfaceChild": "LINK_arm_r",
|
||||
"parentFrameIndex": 0,
|
||||
"childFrameIndex": 0
|
||||
}
|
||||
],
|
||||
"issues": []
|
||||
},
|
||||
"degradationAcceptanceRequired": false
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
@@ -716,38 +773,184 @@ async function sendMessage(conversationId, message, onEvent, signal) {
|
||||
|
||||
## 5. 实例、接口连接与加载
|
||||
|
||||
同一 `componentCode` 可以出现多次,表示同款组件的不同实例。AI 实例标识格式为 `{matchId}:{category}:{序号}`,序号从 1 开始;前端必须使用外层 `components[].instanceId` 区分模型,不能按组件编码去重。组件 DTO 中不嵌套短实例标识。
|
||||
### 组件包装与实例标识
|
||||
|
||||
明确数量优先:例如“拼一个躯干和4个右臂”,归一化 `partRequirements` 中的对应项为 `{"category":"arm_r","quantity":4}`。quantity 为 1–24 的 JSON 整数;省略或为 null 表示先覆盖各个所需类型,再填满这些类型的可匹配剩余接口。自动填充以可验证的硬要求为前提,不为多装组件而破坏本可满足的整机质量或自由度条件;明确数量不足或硬条件无法满足时保留差异。每个物理接口只能连接一个实例;同 child 的多个 frames 元素是不同接口,不合并。本次沿用已有 category 和模板,不新增 leg_0 或四足/六足模板。
|
||||
同一 `componentCode` 可以出现多次,表示同款组件的不同实例。AI 实例标识格式为 `{matchId}:{category}:{序号}`,序号从 1 开始;前端必须使用外层 `components[].instanceId` 区分模型,不能按组件编码去重。实例标识在当前方案内唯一,新方案的 matchId 和实例标识会变化。
|
||||
|
||||
`missingParts[]` 增加 `expectedQuantity`、`actualQuantity`、`missingQuantity`。明确要求4件但只能连接2件时返回缺少2件;接口不足沿用 `NO_COMPATIBLE_CONNECTION`。单次最多24个实例,达到实例、候选或搜索上限时 `searchLimited=true`,保留已有组合并提示。
|
||||
`data.match.components[]` 的字段如下;完整示例见第 3 节:
|
||||
|
||||
`assembly.connections[]` 示例:
|
||||
| 字段 | 类型 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `instanceId` | string | 当前实例标识;连接和替代分组均引用此值 |
|
||||
| `component` | object | 完整公开组件 DTO,包含 `componentCode`、`category`、`rotationAxis`、原始 `urdfInfo` 等;不嵌套短实例标识 |
|
||||
| `urdfMainPath` | string | URDF 主文件在资源包中的相对路径,保留目录层级 |
|
||||
| `resources[]` | object[] | 每项包含 `relativePath`、`url`、`version`、`expiresAt`,供前端加载 URDF 和 mesh |
|
||||
| `resourceIssues[]` | object[] | 当前组件的资源清单提示,每项含 `code`、`category`、`componentCode`、`message` |
|
||||
|
||||
### 数量入参与多实例返回示例
|
||||
|
||||
消息接口的数量仍用自然语言提交:
|
||||
|
||||
```json
|
||||
{
|
||||
"parentInstanceId": "DM-33333333333333333333333333333333:torso_0:1",
|
||||
"parentFrame": "J_ARM",
|
||||
"parentLink": "BASE",
|
||||
"childInstanceId": "DM-33333333333333333333333333333333:arm_r:1",
|
||||
"childFrame": "INCOMING_arm_r",
|
||||
"childRootLink": "ARM_ROOT",
|
||||
"interfaceChild": "LINK_arm_r",
|
||||
"parentFrameIndex": 0,
|
||||
"childFrameIndex": 0
|
||||
"messageId": "m-four-arms",
|
||||
"text": "拼一个躯干和4个右臂",
|
||||
"attachmentIds": []
|
||||
}
|
||||
```
|
||||
|
||||
`parentFrameIndex`、`childFrameIndex` 是双方各自原始 `urdfInfo.frames` 数组的零起始下标。双方该下标的 child 均等于 `interfaceChild`。frame 名称、root/link 名称仅辅助定位,缺失时允许为空/null;稳定定位应使用实例标识及数组下标。
|
||||
后端在 `data.result.request.partRequirements[]` 中生成右臂的数量条件,例如下面这个条目:
|
||||
|
||||
后端只返回连接关系,不返回 `matrixLayout`、三种装配矩阵或连接摆放用的 xyz/rpy。前端加载每个实例的 URDF 后,根据双方原始 frames 或模型信息决定摆放。原始 `urdfInfo` 中已有的 xyz/rpy、axis、limits 等仍完整保留。旧的 `urdfInfo.assembly` 可以存在,但不参与连接资格判断。
|
||||
```json
|
||||
{
|
||||
"category": "ARM_R",
|
||||
"quantity": 4
|
||||
}
|
||||
```
|
||||
|
||||
缺失安装基准、位姿异常、活动关节或资源清单问题均通过 `assembly.issues` / `resourceIssues` 提示,已有组合仍可为 ready。ready 表示逻辑连接关系已生成,不证明安装坐标、承载或运动能力通过验证。
|
||||
`quantity` 为 1–24 的 JSON 整数;省略或为 null 表示先覆盖各个所需类型,再填满这些类型的可匹配剩余接口。自动填充以可验证的硬要求为前提,不为多装组件而破坏本可满足的整机质量或自由度条件;明确数量不足或硬条件无法满足时保留差异。每个物理接口只能连接一个实例;同 child 的多个 frames 元素是不同接口,不合并。本次沿用已有 category 和模板,不新增 leg_0 或四足/六足模板。
|
||||
|
||||
替代候选组包含目标 `instanceId`;仅替换对应实例,应用该候选返回的完整 assembly、totals 和校验结果。多个同类型实例分别有替代组,不按 category 整批替换;多个替代预览不能直接叠加。
|
||||
双足模板直接使用 `LEG_L/LEG_R`。只要腰部与腿部的原始接口 child 分别严格匹配 `LINK_LEG_L`、`LINK_LEG_R`,就能沿腰部连接双腿;公开 `component.category` 返回 `LEG_L/LEG_R`,原始 `urdfInfo` 不变。旧 `pedal_l/pedal_r` 兼容输入会归一化为 `LEG_L/LEG_R`。部署类型统一修复后,旧方案需要发送新的 `messageId` 重新生成。
|
||||
|
||||
下面为独立的四实例场景:假设躯干 `CW-TORSO-004` 有四个原始接口 `frames[0]` 至 `frames[3]`,它们的 `interfaceType=ARM_R`、`child=LINK_arm_r`,`name` 均为 `J_ARM`;每个右臂实例均使用自身的 `frames[0]` 接入,其 `child` 同样为 `LINK_arm_r`。躯干质量 2kg,每个右臂质量 1.2kg、4 个自由度。
|
||||
|
||||
以下仅摘录该场景的 `data.match` 中与多实例有关的字段;`component` 仅展示编码和类别,实际仍返回上述完整 DTO、资源及其他方案字段:
|
||||
|
||||
```json
|
||||
{
|
||||
"status": "complete",
|
||||
"rootCategory": "TORSO_0",
|
||||
"searchLimited": false,
|
||||
"totals": {
|
||||
"degreesOfFreedom": 16,
|
||||
"massKg": 6.8,
|
||||
"knownMassKg": 6.8,
|
||||
"massComplete": true
|
||||
},
|
||||
"components": [
|
||||
{
|
||||
"instanceId": "DM-55555555555555555555555555555555:TORSO_0:1",
|
||||
"component": {
|
||||
"componentCode": "CW-TORSO-004",
|
||||
"category": "TORSO_0"
|
||||
}
|
||||
},
|
||||
{
|
||||
"instanceId": "DM-55555555555555555555555555555555:ARM_R:1",
|
||||
"component": {
|
||||
"componentCode": "CW-ARM-001",
|
||||
"category": "ARM_R"
|
||||
}
|
||||
},
|
||||
{
|
||||
"instanceId": "DM-55555555555555555555555555555555:ARM_R:2",
|
||||
"component": {
|
||||
"componentCode": "CW-ARM-001",
|
||||
"category": "ARM_R"
|
||||
}
|
||||
},
|
||||
{
|
||||
"instanceId": "DM-55555555555555555555555555555555:ARM_R:3",
|
||||
"component": {
|
||||
"componentCode": "CW-ARM-001",
|
||||
"category": "ARM_R"
|
||||
}
|
||||
},
|
||||
{
|
||||
"instanceId": "DM-55555555555555555555555555555555:ARM_R:4",
|
||||
"component": {
|
||||
"componentCode": "CW-ARM-001",
|
||||
"category": "ARM_R"
|
||||
}
|
||||
}
|
||||
],
|
||||
"assembly": {
|
||||
"status": "ready",
|
||||
"rootInstanceId": "DM-55555555555555555555555555555555:TORSO_0:1",
|
||||
"connections": [
|
||||
{
|
||||
"parentInstanceId": "DM-55555555555555555555555555555555:TORSO_0:1",
|
||||
"parentFrame": "J_ARM",
|
||||
"parentLink": "BASE",
|
||||
"childInstanceId": "DM-55555555555555555555555555555555:ARM_R:1",
|
||||
"childFrame": "INCOMING_arm_r",
|
||||
"childRootLink": "ARM_ROOT",
|
||||
"interfaceChild": "LINK_arm_r",
|
||||
"parentFrameIndex": 0,
|
||||
"childFrameIndex": 0
|
||||
},
|
||||
{
|
||||
"parentInstanceId": "DM-55555555555555555555555555555555:TORSO_0:1",
|
||||
"parentFrame": "J_ARM",
|
||||
"parentLink": "BASE",
|
||||
"childInstanceId": "DM-55555555555555555555555555555555:ARM_R:2",
|
||||
"childFrame": "INCOMING_arm_r",
|
||||
"childRootLink": "ARM_ROOT",
|
||||
"interfaceChild": "LINK_arm_r",
|
||||
"parentFrameIndex": 1,
|
||||
"childFrameIndex": 0
|
||||
},
|
||||
{
|
||||
"parentInstanceId": "DM-55555555555555555555555555555555:TORSO_0:1",
|
||||
"parentFrame": "J_ARM",
|
||||
"parentLink": "BASE",
|
||||
"childInstanceId": "DM-55555555555555555555555555555555:ARM_R:3",
|
||||
"childFrame": "INCOMING_arm_r",
|
||||
"childRootLink": "ARM_ROOT",
|
||||
"interfaceChild": "LINK_arm_r",
|
||||
"parentFrameIndex": 2,
|
||||
"childFrameIndex": 0
|
||||
},
|
||||
{
|
||||
"parentInstanceId": "DM-55555555555555555555555555555555:TORSO_0:1",
|
||||
"parentFrame": "J_ARM",
|
||||
"parentLink": "BASE",
|
||||
"childInstanceId": "DM-55555555555555555555555555555555:ARM_R:4",
|
||||
"childFrame": "INCOMING_arm_r",
|
||||
"childRootLink": "ARM_ROOT",
|
||||
"interfaceChild": "LINK_arm_r",
|
||||
"parentFrameIndex": 3,
|
||||
"childFrameIndex": 0
|
||||
}
|
||||
],
|
||||
"issues": []
|
||||
},
|
||||
"missingParts": []
|
||||
}
|
||||
```
|
||||
|
||||
四个右臂共用组件编码与资源 URL,但前端创建四个模型实例。双方接口均按 `(instanceId, frameIndex)` 记录占用:四个连接分别使用躯干下标 0–3;四个右臂的下标虽然都是 0,但属于不同实例,不会冲突。躯干和组件原始 `frames` 数组不重排、不改写。
|
||||
|
||||
`missingParts[]` 包含 `category`、`reason`、`expectedQuantity`、`actualQuantity`、`missingQuantity`。明确要求 4 件但只能连接 2 件时,后三项分别为 4、2、2;接口不兼容或接口数量不足沿用 `NO_COMPATIBLE_CONNECTION`。单次最多 24 个实例(含唯一躯干),达到实例、候选或搜索上限时 `searchLimited=true`,保留已有组合并通过 `assembly.issues` 提示。
|
||||
|
||||
### 连接字段与前端定位
|
||||
|
||||
`data.match.assembly` 包含 `status`、`rootInstanceId`、`connections[]`、`issues[]`。每个 `connections[]` 对象的字段如下:
|
||||
|
||||
| 字段 | 类型 | 说明 |
|
||||
| --- | --- | --- |
|
||||
| `parentInstanceId` | string | 父实例标识,对应 `components[].instanceId` |
|
||||
| `parentFrameIndex` | integer | 父组件原始 `component.urdfInfo.frames` 的零起始下标 |
|
||||
| `childInstanceId` | string | 子实例标识,对应 `components[].instanceId` |
|
||||
| `childFrameIndex` | integer | 子组件原始 `component.urdfInfo.frames` 的零起始下标 |
|
||||
| `interfaceChild` | string | 双方上述接口的共同 child,非空且区分大小写完全相等 |
|
||||
| `parentFrame` | string | 父接口原始 name,缺失时可为空字符串;仅作辅助信息 |
|
||||
| `parentLink` | string/null | 父接口原始 parent,缺失时为 null |
|
||||
| `childFrame` | string/null | 子接口原始 name,缺失时为 null;仅作辅助信息 |
|
||||
| `childRootLink` | string/null | 子组件原始 rootLink,缺失时为 null |
|
||||
|
||||
前端先按实例标识找到两个组件,再分别用 `parentFrameIndex`、`childFrameIndex` 读取各自的原始 frame;双方该 frame 的 child 均等于 `interfaceChild`。frame 名称可以重复或缺失,不能用名称代替实例与下标定位。
|
||||
|
||||
后端只返回连接关系,不返回 `matrixLayout`、`parentRootToInterface`、`childRootToInterface`、`childRootRelativeToParentRoot` 或连接摆放用的 `xyz/rpy`。前端加载每个实例的 URDF 后,根据双方原始 frames 或模型信息决定摆放。原始 `urdfInfo` 中已有的 `xyz/rpy`、`axis`、`limits` 等仍完整保留;旧的 `urdfInfo.assembly` 可以存在,不是必填项,不参与连接资格判断。
|
||||
|
||||
接口元数据、坐标和资源清单异常通过 `assembly.issues` / `resourceIssues` 提示,已有组合仍可为 `ready`。元数据提示可包含 `instanceId` 和 `frameIndex`,无法定位具体实例或下标时可能为 null;合并进 `assembly.issues` 的资源提示仍为上述四字段结构。`ready` 仅表示连接关系已生成,不证明安装坐标、承载或运动能力通过验证。
|
||||
|
||||
替代候选组包含目标 `instanceId`;仅替换对应实例,应用该候选返回的完整 `assembly`、`totals` 和校验结果。多个同类型实例分别有替代组,不按 category 整批替换;多个替代预览不能直接叠加。第 4 节提供包含分组外层的完整示例。
|
||||
|
||||
加载模型时保留 URDF 相对路径目录;OSS/CDN 须允许前端 CORS。每个实例都独立摆放,资源 URL 可以复用或缓存;用户需求图片继续使用需要 Cookie 的私有预览接口。
|
||||
|
||||
AI 接口与结构化 `POST /api/robot-matches` 共用选件连接规则,但返回包装不同:AI 使用 `components[].instanceId={matchId}:{category}:{序号}` 和 `assembly.connections[]`;结构化接口使用 `parts[].instanceId={category}:{序号}` 和顶层 `connections[]`,详见 [结构化接口文档](api.md)。
|
||||
|
||||
## 6. 结果刷新与错误
|
||||
|
||||
已保存方案是本次生成时的快照;本次升级不回写历史结果,旧矩阵格式或旧阻塞状态需要发送新 messageId 重新生成。调整需求、组件版本变化、补齐资源或需要重新选件时,在同一会话发送新的 `messageId`,例如“按原需求重新生成”,后端重新理解当前有效需求并生成新方案。旧版本查询返回 `superseded`,不会继续返回旧 `match`。重发原消息编号仅恢复原任务或结果,不触发刷新。
|
||||
|
||||
@@ -161,7 +161,7 @@ class DemandFlowApiTest {
|
||||
for (JsonNode check : match.path("requirementChecks")) assertThat(check.path("status").asText()).isEqualTo("satisfied");
|
||||
assertThat(match.path("components").get(0).path("component").path("bomList").path("nested").path("parts").get(0).asText()).isEqualTo("BOLT");
|
||||
assertThat(match.path("components").get(0).path("resources")).hasSize(2);
|
||||
assertThat(match.path("assembly").path("connections").get(0).path("interfaceChild").asText()).isEqualTo("LINK_arm_r");
|
||||
assertThat(match.path("assembly").path("connections").get(0).path("interfaceChild").asText()).isEqualTo("LINK_ARM_R");
|
||||
String body = match.toString();
|
||||
for (String field : List.of("\"id\"", "urdfPrefix", "urdfMainObjectKey", "ownerHash", "snapshot", "model_version", "thinking", "apiKey")) assertThat(body).doesNotContain(field);
|
||||
JsonNode alternate = match.path("alternatives").get(1).path("items").get(0);
|
||||
@@ -229,11 +229,51 @@ class DemandFlowApiTest {
|
||||
assertThat(generated.path("match").path("degradationAcceptanceRequired").asBoolean()).isFalse();
|
||||
}
|
||||
|
||||
@Test void humanoidDemandAttachesBothStoredLegsToWaist() throws Exception {
|
||||
save("CW-TORSO", "TORSO_0", 0, "2", 0, "BASE", true);
|
||||
ObjectNode torso = (ObjectNode) json.readTree(jdbc.queryForObject("SELECT urdf_info FROM component WHERE component_code='CW-TORSO'", String.class));
|
||||
((ObjectNode) torso.path("frames").get(0)).put("name", "LINK_WAIST_0").put("child", "LINK_WAIST_0").put("interfaceType", "WAIST_0");
|
||||
jdbc.update("UPDATE component SET category='TORSO_0',urdf_info=? WHERE component_code='CW-TORSO'", torso.toString());
|
||||
try (java.io.InputStream stream = getClass().getResourceAsStream("/fixtures/waist-leg-components.json")) {
|
||||
assertThat(stream).isNotNull();
|
||||
for (JsonNode row : json.readTree(stream)) {
|
||||
jdbc.update("INSERT INTO component (component_code,component_name,category,bom_list,urdf_info,step_object_key,urdf_main_object_key) VALUES (?,?,?,'[]',?,'model.step','robot.urdf')",
|
||||
row.path("component_code").asText(), row.path("component_name").asText(), row.path("category").asText(), row.path("urdf_info").toString());
|
||||
}
|
||||
}
|
||||
doAnswer(invocation -> {
|
||||
ObjectNode raw = raw(invocation.getArgument(0));
|
||||
raw.put("summary", "用户要求组装人形机器人");
|
||||
for (String field : List.of("constraints", "intentItems", "partCategories")) raw.putArray(field);
|
||||
intent(raw, "form", "整机", "为人形形态");
|
||||
raw.withArray("robotTypes").addObject().put("type", "biped").put("source", "inferred")
|
||||
.put("reason", "按双足人形模板生成候选").putArray("evidenceIds").add("e1");
|
||||
return raw;
|
||||
}).when(model).analyze(anyList());
|
||||
Session session = create();
|
||||
JsonNode generated = submit(session, "m-humanoid", "拼个人形机器人", List.of());
|
||||
JsonNode match = generated.path("match");
|
||||
List<String> selectedCodes = new ArrayList<>();
|
||||
for (JsonNode selection : match.path("components")) selectedCodes.add(selection.path("component").path("componentCode").asText());
|
||||
assertThat(selectedCodes)
|
||||
.containsExactlyInAnyOrder("CW-TORSO", "CW-AG3XMNWJMN3Q89NX", "CW-JP19A0XZY9H7YNBN", "CW-JBJWXQ7N4C9P03TJ");
|
||||
assertThat(match.path("missingParts").findValuesAsText("category")).doesNotContain("LEG_L", "LEG_R");
|
||||
assertThat(match.path("assembly").path("status").asText()).isEqualTo("ready");
|
||||
assertThat(match.path("assembly").path("connections").findValuesAsText("interfaceChild"))
|
||||
.containsExactlyInAnyOrder("LINK_WAIST_0", "LINK_LEG_L", "LINK_LEG_R");
|
||||
for (JsonNode edge : match.path("assembly").path("connections")) {
|
||||
if (!edge.path("interfaceChild").asText().startsWith("LINK_LEG_")) continue;
|
||||
assertThat(edge.path("parentInstanceId").asText()).endsWith(":WAIST_0:1");
|
||||
assertThat(edge.path("childFrameIndex").asInt()).isEqualTo(3);
|
||||
}
|
||||
assertThat(generatedMatch(session, generated.path("analysisId").asText(), 1)).isEqualTo(match);
|
||||
}
|
||||
|
||||
@Test void explicitlyExcludedTorsoIsNotSilentlyAddedByStructuredMatching() throws Exception {
|
||||
components(true, 20);
|
||||
doAnswer(invocation -> {
|
||||
ObjectNode raw = raw(invocation.getArgument(0));
|
||||
raw.withArray("excludedCategories").addObject().put("category", "torso_0").putArray("evidenceIds").add("e1");
|
||||
raw.withArray("excludedCategories").addObject().put("category", "TORSO_0").putArray("evidenceIds").add("e1");
|
||||
intent(raw, "exclusion", "躯干", "不要躯干");
|
||||
return raw;
|
||||
}).when(model).analyze(anyList());
|
||||
@@ -378,7 +418,7 @@ class DemandFlowApiTest {
|
||||
JsonNode result = generatedMatch(session, analysisId, 1);
|
||||
assertThat(result.path("status").asText()).isEqualTo("partial");
|
||||
assertThat(result.path("components").findValuesAsText("componentCode")).containsExactly("CW-TORSO");
|
||||
assertThat(result.path("missingParts").findValuesAsText("category")).containsExactly("arm_r");
|
||||
assertThat(result.path("missingParts").findValuesAsText("category")).containsExactly("ARM_R");
|
||||
assertThat(result.path("alternatives").findValuesAsText("componentCode")).doesNotContain("CW-ARM", "CW-ARM-ALT");
|
||||
mvc.perform(get("/api/components/CW-ARM")).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.data.componentCode").value("CW-ARM"))
|
||||
@@ -416,44 +456,44 @@ class DemandFlowApiTest {
|
||||
@Test void conversationMatchingFixesBestTorsoBeforeSearchingFallbackParts() throws Exception {
|
||||
components(true, 20);
|
||||
jdbc.update("UPDATE component SET material='铝合金',category='躯干_0' WHERE component_code='CW-TORSO'");
|
||||
save("CW-TORSO-ALT", "torso_0", 0, "2", 0, "BASE", true);
|
||||
save("CW-TORSO-ALT", "TORSO_0", 0, "2", 0, "BASE", true);
|
||||
jdbc.update("UPDATE component SET material='钢' WHERE component_code='CW-TORSO-ALT'");
|
||||
save("CW-HEAD", "head_0", 0, "0.5", 0, "HEAD_ROOT", true);
|
||||
save("CW-HEAD", "HEAD_0", 0, "0.5", 0, "HEAD_ROOT", true);
|
||||
ObjectNode info = (ObjectNode) json.readTree(jdbc.queryForObject("SELECT urdf_info FROM component WHERE component_code='CW-TORSO-ALT'", String.class));
|
||||
ObjectNode headFrame = info.withArray("frames").addObject().put("name", "J_HEAD").put("kind", "joint").put("type", "fixed").put("parent", "BASE")
|
||||
.put("child", "LINK_head").put("interfaceType", "head_0").put("originExplicit", true);
|
||||
.put("child", "LINK_head").put("interfaceType", "HEAD_0").put("originExplicit", true);
|
||||
headFrame.putArray("xyz").add(0).add(1).add(0); headFrame.putArray("rpy").add(0).add(0).add(0);
|
||||
jdbc.update("UPDATE component SET urdf_info=? WHERE component_code='CW-TORSO-ALT'", info.toString());
|
||||
doAnswer(invocation -> {
|
||||
ObjectNode raw = raw(invocation.getArgument(0));
|
||||
((ObjectNode) raw.path("constraints").get(2)).put("value", "30N·m");
|
||||
((ObjectNode) raw.path("intentItems").get(2)).put("requirement", "右臂扭矩至少30N·m");
|
||||
constraint(raw, "part", "material", "铝合金", "eq", "torso_0");
|
||||
constraint(raw, "part", "material", "铝合金", "eq", "TORSO_0");
|
||||
intent(raw, "material", "躯干", "躯干用铝合金");
|
||||
raw.withArray("partCategories").addObject().put("category", "head_0").put("source", "explicit").put("reason", "所需头部").putArray("evidenceIds").add("e1");
|
||||
raw.withArray("partCategories").addObject().put("category", "HEAD_0").put("source", "explicit").put("reason", "所需头部").putArray("evidenceIds").add("e1");
|
||||
return raw;
|
||||
}).when(model).analyze(anyList());
|
||||
Session session = create();
|
||||
JsonNode parsed = submit(session, "m1", TEXT.replace("20N·m", "30N·m") + ",躯干用铝合金,还需要头部", List.of());
|
||||
JsonNode result = generatedMatch(session, parsed.path("analysisId").asText(), 1);
|
||||
assertThat(result.path("rootCategory").asText()).isEqualTo("torso_0");
|
||||
assertThat(result.path("rootCategory").asText()).isEqualTo("TORSO_0");
|
||||
assertThat(result.path("components")).hasSize(2);
|
||||
assertThat(result.path("components").get(0).path("component").path("componentCode").asText()).isEqualTo("CW-TORSO");
|
||||
assertThat(result.path("components").get(0).path("component").path("category").asText()).isEqualTo("torso_0");
|
||||
assertThat(result.path("components").get(0).path("component").path("category").asText()).isEqualTo("TORSO_0");
|
||||
assertThat(result.path("components").get(1).path("component").path("torqueNm").asInt()).isEqualTo(20);
|
||||
assertThat(result.path("missingParts").get(0).path("category").asText()).isEqualTo("head_0");
|
||||
assertThat(result.path("missingParts").get(0).path("category").asText()).isEqualTo("HEAD_0");
|
||||
assertThat(result.path("status").asText()).isEqualTo("partial");
|
||||
assertThat(result.path("degradationAcceptanceRequired").asBoolean()).isFalse();
|
||||
assertThat(result.path("assembly").path("status").asText()).isEqualTo("ready");
|
||||
assertThat(result.path("assembly").path("issues")).isEmpty();
|
||||
assertThat(result.path("assembly").path("connections").get(0).path("parentInstanceId").asText()).endsWith(":torso_0:1");
|
||||
assertThat(result.path("assembly").path("connections").get(0).path("parentInstanceId").asText()).endsWith(":TORSO_0:1");
|
||||
}
|
||||
|
||||
@Test void missingPartsAllowImmediateAssemblyIncludingAlternatives() throws Exception {
|
||||
components(true, 20);
|
||||
doAnswer(invocation -> {
|
||||
ObjectNode raw = raw(invocation.getArgument(0));
|
||||
raw.withArray("partCategories").addObject().put("category", "head_0").put("source", "explicit").put("reason", "所需头部")
|
||||
raw.withArray("partCategories").addObject().put("category", "HEAD_0").put("source", "explicit").put("reason", "所需头部")
|
||||
.putArray("evidenceIds").add("e1");
|
||||
return raw;
|
||||
}).when(model).analyze(anyList());
|
||||
@@ -464,8 +504,8 @@ class DemandFlowApiTest {
|
||||
|
||||
assertThat(result.path("status").asText()).isEqualTo("partial");
|
||||
assertThat(result.path("components")).hasSize(2);
|
||||
assertThat(result.path("components").get(0).path("component").path("category").asText()).isEqualTo("torso_0");
|
||||
assertThat(result.path("missingParts").findValuesAsText("category")).containsExactly("head_0");
|
||||
assertThat(result.path("components").get(0).path("component").path("category").asText()).isEqualTo("TORSO_0");
|
||||
assertThat(result.path("missingParts").findValuesAsText("category")).containsExactly("HEAD_0");
|
||||
assertThat(result.path("requirementChecks").findValuesAsText("status")).contains("unverified");
|
||||
assertThat(result.path("degradationAcceptanceRequired").asBoolean()).isFalse();
|
||||
assertThat(result.path("degradationAccepted").asBoolean()).isFalse();
|
||||
@@ -483,7 +523,7 @@ class DemandFlowApiTest {
|
||||
assertThat(cached.path("assembly")).isEqualTo(result.path("assembly"));
|
||||
assertThat(cached.path("matchId").asText()).isEqualTo(result.path("matchId").asText());
|
||||
|
||||
jdbc.update("UPDATE component SET urdf_files='[]' WHERE category='arm_r'");
|
||||
jdbc.update("UPDATE component SET urdf_files='[]' WHERE category='ARM_R'");
|
||||
JsonNode invalidResources = submit(session, "m2", TEXT + ",还需要头部", List.of()).path("match");
|
||||
assertThat(invalidResources.path("status").asText()).isEqualTo("partial");
|
||||
assertThat(invalidResources.path("missingParts")).isEqualTo(result.path("missingParts"));
|
||||
@@ -506,16 +546,16 @@ class DemandFlowApiTest {
|
||||
}
|
||||
|
||||
@Test void onlyTorsoCanBeDisplayedWhenAllRequestedChildPartsAreMissing() throws Exception {
|
||||
save("CW-TORSO", "torso_0", 0, "2", 0, "BASE", true);
|
||||
save("CW-TORSO", "TORSO_0", 0, "2", 0, "BASE", true);
|
||||
Session session = create();
|
||||
JsonNode parsed = submit(session, "m1", TEXT, List.of());
|
||||
JsonNode result = generatedMatch(session, parsed.path("analysisId").asText(), 1);
|
||||
assertThat(result.path("status").asText()).isEqualTo("partial");
|
||||
assertThat(result.path("missingParts").findValuesAsText("category")).containsExactly("arm_r");
|
||||
assertThat(result.path("missingParts").findValuesAsText("category")).containsExactly("ARM_R");
|
||||
assertThat(result.path("components")).hasSize(1);
|
||||
assertThat(result.path("degradationAcceptanceRequired").asBoolean()).isFalse();
|
||||
assertThat(result.path("assembly").path("status").asText()).isEqualTo("ready");
|
||||
assertThat(result.path("assembly").path("rootInstanceId").asText()).endsWith(":torso_0:1");
|
||||
assertThat(result.path("assembly").path("rootInstanceId").asText()).endsWith(":TORSO_0:1");
|
||||
assertThat(result.path("assembly").path("connections")).isEmpty();
|
||||
assertThat(result.path("assembly").path("issues")).isEmpty();
|
||||
}
|
||||
@@ -636,8 +676,8 @@ class DemandFlowApiTest {
|
||||
List<DemandMessage> history = invocation.getArgument(0);
|
||||
ObjectNode raw = raw(List.of(history.get(0)));
|
||||
raw.putArray("constraints"); raw.putArray("intentItems"); raw.putArray("partCategories");
|
||||
raw.withArray("partCategories").addObject().put("category", "arm_r").put("source", "explicit").put("reason", "右臂").putArray("evidenceIds").add("e1");
|
||||
ObjectNode row = constraint(raw, "part", "torqueNm", history.size() > 1 ? "30N·m" : "30", "gte", "arm_r");
|
||||
raw.withArray("partCategories").addObject().put("category", "ARM_R").put("source", "explicit").put("reason", "右臂").putArray("evidenceIds").add("e1");
|
||||
ObjectNode row = constraint(raw, "part", "torqueNm", history.size() > 1 ? "30N·m" : "30", "gte", "ARM_R");
|
||||
intent(raw, "performance", "右臂", "右臂扭矩至少30");
|
||||
if (history.size() > 1) {
|
||||
assertThat(history.stream().anyMatch((DemandMessage message) -> "assistant".equals(message.role()))).isFalse();
|
||||
@@ -660,7 +700,7 @@ class DemandFlowApiTest {
|
||||
assertThat(second.path("revision").asInt()).isEqualTo(2);
|
||||
assertThat(second.path("result").path("request").path("partRequirements").get(0).path("torqueNm").asInt()).isEqualTo(30);
|
||||
assertThat(second.path("result").path("request").path("requiredParts")).hasSize(2);
|
||||
assertThat(second.path("result").path("request").path("requiredParts").get(0).asText()).isEqualTo("torso_0");
|
||||
assertThat(second.path("result").path("request").path("requiredParts").get(0).asText()).isEqualTo("TORSO_0");
|
||||
JsonNode matched = second.path("match");
|
||||
assertThat(matched.path("requirementChecks").get(0).path("status").asText()).isEqualTo("satisfied");
|
||||
}
|
||||
@@ -766,10 +806,10 @@ class DemandFlowApiTest {
|
||||
for (String field : List.of("intentItems", "images", "observations", "keywords", "robotTypes", "partCategories", "excludedCategories", "constraints", "unmodeled", "questions")) raw.putArray(field);
|
||||
raw.withArray("observations").addObject().put("id", "e1").put("messageId", user.id()).put("imageId", "").put("kind", "user_text").put("content", user.text()).put("clarity", "clear").putArray("region");
|
||||
raw.withArray("keywords").addObject().put("term", "机器人").put("source", "explicit").put("reason", "机器人需求").put("negated", false).putArray("evidenceIds").add("e1");
|
||||
for (String category : List.of("torso_0", "arm_r")) raw.withArray("partCategories").addObject().put("category", category).put("source", "explicit").put("reason", "所需组件").putArray("evidenceIds").add("e1");
|
||||
for (String category : List.of("TORSO_0", "ARM_R")) raw.withArray("partCategories").addObject().put("category", category).put("source", "explicit").put("reason", "所需组件").putArray("evidenceIds").add("e1");
|
||||
constraint(raw, "robot", "degreesOfFreedom", "4", "eq", null);
|
||||
constraint(raw, "robot", "massKg", "4kg", "lte", null);
|
||||
constraint(raw, "part", "torqueNm", "20N·m", "gte", "arm_r");
|
||||
constraint(raw, "part", "torqueNm", "20N·m", "gte", "ARM_R");
|
||||
intent(raw, "performance", "整机", "整体4自由度"); intent(raw, "performance", "整机", "质量不超过4kg"); intent(raw, "performance", "右臂", "右臂扭矩至少20N·m");
|
||||
return raw;
|
||||
}
|
||||
@@ -782,18 +822,18 @@ class DemandFlowApiTest {
|
||||
.put("requirement", requirement).put("priority", "must").put("source", "explicit").putArray("evidenceIds").add("e1");
|
||||
}
|
||||
private void components(boolean mount, int torque) {
|
||||
save("CW-TORSO", "torso_0", 0, "2", 0, "BASE", true);
|
||||
save("CW-ARM", "arm_r", 4, "1", torque, "ARM_ROOT", mount);
|
||||
save("CW-ARM-ALT", "arm_r", 4, "1.2", torque, "ARM_V2_ROOT", mount);
|
||||
save("CW-TORSO", "TORSO_0", 0, "2", 0, "BASE", true);
|
||||
save("CW-ARM", "ARM_R", 4, "1", torque, "ARM_ROOT", mount);
|
||||
save("CW-ARM-ALT", "ARM_R", 4, "1.2", torque, "ARM_V2_ROOT", mount);
|
||||
}
|
||||
private void save(String code, String category, int degrees, String mass, int torque, String root, boolean mount) {
|
||||
ObjectNode info = json.createObjectNode().put("rootLink", root).put("robotName", code);
|
||||
info.putArray("frames");
|
||||
if ("torso_0".equals(category)) {
|
||||
ObjectNode frame = info.withArray("frames").addObject().put("name", "J_ARM").put("kind", "joint").put("type", "fixed").put("parent", "BASE").put("child", "LINK_arm_r").put("interfaceType", "arm_r").put("originExplicit", true);
|
||||
if ("TORSO_0".equals(category)) {
|
||||
ObjectNode frame = info.withArray("frames").addObject().put("name", "J_ARM").put("kind", "joint").put("type", "fixed").put("parent", "BASE").put("child", "LINK_ARM_R").put("interfaceType", "ARM_R").put("originExplicit", true);
|
||||
frame.putArray("xyz").add(1).add(0).add(0); frame.putArray("rpy").add(0).add(0).add(0); frame.putArray("axis").add(0).add(0).add(0); frame.putObject("limits");
|
||||
}
|
||||
if (!"torso_0".equals(category)) {
|
||||
if (!"TORSO_0".equals(category)) {
|
||||
ObjectNode incoming = info.withArray("frames").addObject().put("name", "INCOMING").put("kind", "joint").put("type", "revolute")
|
||||
.put("parent", root).put("child", "LINK_" + category).put("interfaceType", category);
|
||||
incoming.putArray("xyz").add(0).add(0).add(0); incoming.putArray("rpy").add(0).add(0).add(0);
|
||||
|
||||
@@ -88,7 +88,7 @@ class MatchingApiTest {
|
||||
assertThat(context.getBeansOfType(ObjectStorageClient.class)).isEmpty();
|
||||
mvc.perform(get("/admin-api/components")).andExpect(status().isNotFound());
|
||||
mvc.perform(get("/api/components/CW-NO/assets/1/step")).andExpect(status().isNotFound());
|
||||
JsonNode empty = match(request("torso_0"));
|
||||
JsonNode empty = match(request("TORSO_0"));
|
||||
assertThat(empty.path("status").asText()).isEqualTo("NO_MATCH");
|
||||
assertThat(empty.path("parts")).isEmpty();
|
||||
assertThat(empty.path("missingParts").get(0).path("reason").asText()).isEqualTo("NO_COMPONENT");
|
||||
@@ -97,56 +97,74 @@ class MatchingApiTest {
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"X", "Y", "Z"})
|
||||
void rotationAxisIsReturnedInPublicDetailsSelectedPartsAndAlternatives(String axis) throws Exception {
|
||||
save("CW-A", "torso_0", 0, "1", "0", "", metadata("BASE"), json.readTree("[]"));
|
||||
save("CW-B", "torso_0", 0, "1", "0", "", metadata("BASE"), json.readTree("[]"));
|
||||
save("CW-A", "TORSO_0", 0, "1", "0", "", metadata("BASE"), json.readTree("[]"));
|
||||
save("CW-B", "TORSO_0", 0, "1", "0", "", metadata("BASE"), json.readTree("[]"));
|
||||
String alternativeAxis = "X".equals(axis) ? "Y" : "X";
|
||||
jdbc.update("UPDATE component SET rotation_axis=? WHERE component_code='CW-A'", axis);
|
||||
jdbc.update("UPDATE component SET rotation_axis=? WHERE component_code='CW-B'", alternativeAxis);
|
||||
mvc.perform(get("/api/components/CW-A")).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.data.rotationAxis").value(axis)).andExpect(jsonPath("$.data.id").doesNotExist());
|
||||
JsonNode result = match(request("torso_0"));
|
||||
assertThat(part(result, "torso_0").path("componentCode").asText()).isEqualTo("CW-A");
|
||||
assertThat(part(result, "torso_0").path("rotationAxis").asText()).isEqualTo(axis);
|
||||
assertThat(alternatives(result, "torso_0").get(0).path("component").path("rotationAxis").asText()).isEqualTo(alternativeAxis);
|
||||
JsonNode result = match(request("TORSO_0"));
|
||||
assertThat(part(result, "TORSO_0").path("componentCode").asText()).isEqualTo("CW-A");
|
||||
assertThat(part(result, "TORSO_0").path("rotationAxis").asText()).isEqualTo(axis);
|
||||
assertThat(alternatives(result, "TORSO_0").get(0).path("component").path("rotationAxis").asText()).isEqualTo(alternativeAxis);
|
||||
}
|
||||
|
||||
@Test
|
||||
void mapsEveryRoleAndDeduplicatesAliasesWithoutSwappingFeetOrSides() throws Exception {
|
||||
List<String> english = List.of("head_0", "waist_0", "arm_l", "arm_r", "hand_l", "hand_r",
|
||||
"pedal_l", "pedal_r", "foot_l", "foot_r", "tail_0");
|
||||
@ParameterizedTest
|
||||
@ValueSource(booleans = {true, false})
|
||||
void mapsEveryRoleAndDeduplicatesAliasesWithoutSwappingFeetOrSides(boolean standardCategories) throws Exception {
|
||||
List<String> english = List.of("HEAD_0", "WAIST_0", "ARM_L", "ARM_R", "HAND_L", "HAND_R",
|
||||
"LEG_L", "LEG_R", "FOOT_L", "FOOT_R", "TAIL_0");
|
||||
List<String> chinese = List.of("头_0", "腰_0", "臂_l", "臂_r", "手_l", "手_r", "足_l", "足_r", "脚_l", "脚_r", "尾_0");
|
||||
save("CW-TORSO", "躯干_0", 0, "1", "0", "", metadata("ROOT", english.toArray(String[]::new)), json.readTree("[]"));
|
||||
for (int index = 0; index < english.size(); index++) save("CW-" + english.get(index), chinese.get(index), 1, "1", "0", "");
|
||||
save("CW-TORSO", standardCategories ? "TORSO_0" : "躯干_0", 0, "1", "0", "", metadata("ROOT", english.toArray(String[]::new)), json.readTree("[]"));
|
||||
for (int index = 0; index < english.size(); index++) save("CW-" + english.get(index), standardCategories ? english.get(index) : chinese.get(index), 1, "1", "0", "");
|
||||
List<String> required = new ArrayList<>(chinese);
|
||||
required.addAll(List.of("躯干_0", "torso_0", "ARM_L"));
|
||||
required.addAll(List.of("躯干_0", "torso_0", "arm_l", "pedal_l", "PEDAL_R"));
|
||||
JsonNode result = match(Map.of("requiredParts", required));
|
||||
assertThat(result.path("status").asText()).isEqualTo("MATCHED");
|
||||
assertThat(result.path("parts").size()).isEqualTo(12);
|
||||
assertThat(result.path("connections").size()).isEqualTo(11);
|
||||
assertThat(part(result, "pedal_l").path("componentCode").asText()).isEqualTo("CW-pedal_l");
|
||||
assertThat(part(result, "foot_l").path("componentCode").asText()).isEqualTo("CW-foot_l");
|
||||
assertThat(part(result, "LEG_L").path("componentCode").asText()).isEqualTo("CW-LEG_L");
|
||||
assertThat(part(result, "FOOT_L").path("componentCode").asText()).isEqualTo("CW-FOOT_L");
|
||||
}
|
||||
|
||||
@Test void legacyStoredCategoriesAndRequestsReturnStandardCodesAndOriginalUrdf() throws Exception {
|
||||
JsonNode torso = metadata("BASE", "leg_l");
|
||||
JsonNode leg = metadata("LINK_leg_l");
|
||||
((com.fasterxml.jackson.databind.node.ObjectNode) leg).withArray("frames").addObject()
|
||||
.put("name", "__root_interface__").put("child", "LINK_leg_l").put("interfaceType", "pedal_l");
|
||||
jdbc.update("INSERT INTO component (component_code,category,bom_list,urdf_info,step_object_key,urdf_main_object_key) VALUES ('CW-T','torso_0','[]',?,'model.step','robot.urdf')", torso.toString());
|
||||
jdbc.update("INSERT INTO component (component_code,category,bom_list,urdf_info,step_object_key,urdf_main_object_key) VALUES ('CW-L','pedal_l','[]',?,'model.step','robot.urdf')", leg.toString());
|
||||
JsonNode result = match(request("pedal_l"));
|
||||
assertThat(result.path("status").asText()).isEqualTo("MATCHED");
|
||||
assertThat(result.path("rootCategory").asText()).isEqualTo("TORSO_0");
|
||||
assertThat(part(result, "LEG_L").path("instanceId").asText()).isEqualTo("LEG_L:1");
|
||||
assertThat(part(result, "LEG_L").path("urdfInfo")).isEqualTo(leg);
|
||||
assertThat(result.path("connections").get(0).path("interfaceChild").asText()).isEqualTo("LINK_leg_l");
|
||||
mvc.perform(get("/api/components/CW-L")).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.data.category").value("LEG_L")).andExpect(jsonPath("$.data.id").doesNotExist());
|
||||
}
|
||||
|
||||
@Test
|
||||
void returnsOriginalNestedJsonInSelectedAlternativeAndDetailWithEncodedDirectUrls() throws Exception {
|
||||
JsonNode original = metadata("BASE", "arm_r");
|
||||
JsonNode original = metadata("BASE", "ARM_R");
|
||||
JsonNode bom = json.readTree("{\"items\":[{\"code\":\"bolt\",\"qty\":4,\"details\":{\"material\":\"steel\"}}]}");
|
||||
save("CW-A", "torso_0", 0, "1", "0", "", original, bom);
|
||||
save("CW-A", "TORSO_0", 0, "1", "0", "", original, bom);
|
||||
JsonNode alternativeBom = json.readTree("[{\"code\":\"plate\",\"children\":[{\"qty\":2}]}]");
|
||||
JsonNode alternativeInfo = metadata("OTHER_BASE", "arm_r");
|
||||
JsonNode alternativeInfo = metadata("OTHER_BASE", "ARM_R");
|
||||
save("CW-B", "躯干_0", 0, "2", "0", "", alternativeInfo, alternativeBom);
|
||||
save("CW-ARM", "臂_r", 4, "1", "20", "");
|
||||
jdbc.update("UPDATE component SET step_object_key=?,urdf_main_object_key=? WHERE component_code=?",
|
||||
"cadworld_dev/components/CW-A/step/batch/模型 one.STEP",
|
||||
"cadworld_dev/components/CW-A/urdf/batch/L20/机器人.urdf", "CW-A");
|
||||
JsonNode result = match(request("torso_0", "arm_r"));
|
||||
JsonNode selected = part(result, "torso_0");
|
||||
JsonNode result = match(request("TORSO_0", "ARM_R"));
|
||||
JsonNode selected = part(result, "TORSO_0");
|
||||
assertThat(selected.get("bomList")).isEqualTo(bom);
|
||||
assertThat(selected.get("urdfInfo")).isEqualTo(original);
|
||||
assertThat(selected.path("stepUrl").asText()).startsWith("https://models.example.test/cadworld_dev/")
|
||||
.endsWith("%E6%A8%A1%E5%9E%8B%20one.STEP");
|
||||
assertThat(selected.path("urdfUrl").asText()).contains("/urdf/batch/L20/").endsWith("%E6%9C%BA%E5%99%A8%E4%BA%BA.urdf");
|
||||
JsonNode replacement = alternatives(result, "torso_0").get(0).path("component");
|
||||
JsonNode replacement = alternatives(result, "TORSO_0").get(0).path("component");
|
||||
assertThat(replacement.get("bomList")).isEqualTo(alternativeBom);
|
||||
assertThat(replacement.get("urdfInfo")).isEqualTo(alternativeInfo);
|
||||
assertPublic(selected);
|
||||
@@ -162,33 +180,69 @@ class MatchingApiTest {
|
||||
mvc.perform(get("/api/components/" + id)).andExpect(status().isNotFound());
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(booleans = {true, false})
|
||||
void attachesStoredLegCategoriesThroughWaistUsingInterfaceTypeOrChildFallback(boolean explicitType) throws Exception {
|
||||
try (java.io.InputStream stream = getClass().getResourceAsStream("/fixtures/waist-leg-components.json")) {
|
||||
assertThat(stream).isNotNull();
|
||||
for (JsonNode row : json.readTree(stream)) {
|
||||
JsonNode info = row.path("urdf_info");
|
||||
if (!explicitType) for (JsonNode frame : info.path("frames")) {
|
||||
((com.fasterxml.jackson.databind.node.ObjectNode) frame).remove("interfaceType");
|
||||
}
|
||||
jdbc.update("INSERT INTO component (component_code,component_name,category,bom_list,urdf_info,step_object_key,urdf_main_object_key) VALUES (?,?,?,'[]',?,'model.step','robot.urdf')",
|
||||
row.path("component_code").asText(), row.path("component_name").asText(),
|
||||
explicitType ? row.path("category").asText() : row.path("category").asText().toLowerCase(java.util.Locale.ROOT), info.toString());
|
||||
}
|
||||
}
|
||||
com.fasterxml.jackson.databind.node.ObjectNode torso = (com.fasterxml.jackson.databind.node.ObjectNode) metadata("BASE", "WAIST_0");
|
||||
save("CW-TORSO", "TORSO_0", 0, "1", "0", "", torso, json.readTree("[]"));
|
||||
JsonNode result = match(request("WAIST_0", "LEG_L", "LEG_R"));
|
||||
assertThat(result.path("status").asText()).isEqualTo("MATCHED");
|
||||
assertThat(result.path("parts")).hasSize(4);
|
||||
assertThat(part(result, "LEG_L").path("componentCode").asText()).isEqualTo("CW-JP19A0XZY9H7YNBN");
|
||||
assertThat(part(result, "LEG_R").path("componentCode").asText()).isEqualTo("CW-JBJWXQ7N4C9P03TJ");
|
||||
assertThat(result.path("missingParts")).isEmpty();
|
||||
assertThat(result.path("connections").findValuesAsText("interfaceChild"))
|
||||
.containsExactlyInAnyOrder("LINK_WAIST_0", "LINK_LEG_L", "LINK_LEG_R");
|
||||
for (JsonNode edge : result.path("connections")) {
|
||||
if (!"LEG_L".equals(edge.path("childCategory").asText()) && !"LEG_R".equals(edge.path("childCategory").asText())) continue;
|
||||
assertThat(edge.path("parentCategory").asText()).isEqualTo("WAIST_0");
|
||||
assertThat(edge.path("childFrameIndex").asInt()).isEqualTo(3);
|
||||
}
|
||||
mvc.perform(get("/api/components/CW-JP19A0XZY9H7YNBN")).andExpect(status().isOk())
|
||||
.andExpect(jsonPath("$.data.category").value("LEG_L"))
|
||||
.andExpect(jsonPath("$.data.urdfInfo.rootLink").value("LINK_LEG_L"))
|
||||
.andExpect(jsonPath("$.data.id").doesNotExist());
|
||||
}
|
||||
|
||||
@ParameterizedTest
|
||||
@ValueSource(strings = {"CW-7K3M9Q2R6V8X4T5N", "CW-0123456789ABCDEF0123456789ABCDEF"})
|
||||
void publicDetailPreservesJsonArraysForShortAndLegacyCodes(String componentCode) throws Exception {
|
||||
JsonNode info = json.readTree("[{\"robotName\":\"legacy\"}]");
|
||||
save(componentCode, "torso_0", 0, "1", "0", "", info, json.readTree("{}"));
|
||||
save(componentCode, "TORSO_0", 0, "1", "0", "", info, json.readTree("{}"));
|
||||
MvcResult detail = mvc.perform(get("/api/components/{componentCode}", componentCode))
|
||||
.andExpect(status().isOk()).andReturn();
|
||||
JsonNode component = json.readTree(detail.getResponse().getContentAsString()).path("data");
|
||||
assertThat(component.path("componentCode").asText()).isEqualTo(componentCode);
|
||||
assertThat(component.get("urdfInfo")).isEqualTo(info);
|
||||
assertPublic(component);
|
||||
JsonNode result = match(request("torso_0"));
|
||||
JsonNode result = match(request("TORSO_0"));
|
||||
assertThat(result.path("status").asText()).isEqualTo("MATCHED");
|
||||
assertThat(result.path("parts")).hasSize(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
void structuredRequirementsAndSynonymsDetermineExactMatchNotUserInput() throws Exception {
|
||||
save("CW-T", "torso_0", 0, "2", "0", "aluminium alloy", metadata("BASE", "arm_r"), json.readTree("[]"));
|
||||
save("CW-R", "arm_r", 20, "3", "20", "steel");
|
||||
save("CW-T", "TORSO_0", 0, "2", "0", "aluminium alloy", metadata("BASE", "ARM_R"), json.readTree("[]"));
|
||||
save("CW-R", "ARM_R", 20, "3", "20", "steel");
|
||||
jdbc.update("UPDATE component SET component_name='双足机器人',function_description='用于奔跑',shape='双足' ");
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("torso_0", "arm_r"));
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("TORSO_0", "ARM_R"));
|
||||
body.put("userInput", "这里写100自由度和质量1kg也不能覆盖结构化条件");
|
||||
body.put("requirements", List.of("running", "robot", "biped"));
|
||||
body.put("robotRequirements", Map.of("degreesOfFreedom", 20, "massKg", 10, "functionDescription", "跑步", "operators", Map.of("massKg", "lte")));
|
||||
body.put("partRequirements", List.of(Map.of("category", "躯干_0", "material", " 铝合金 "),
|
||||
Map.of("category", "arm_r", "torqueNm", 20, "operators", Map.of("torqueNm", "gte"))));
|
||||
Map.of("category", "ARM_R", "torqueNm", 20, "operators", Map.of("torqueNm", "gte"))));
|
||||
JsonNode result = match(body);
|
||||
assertThat(result.path("status").asText()).isEqualTo("MATCHED");
|
||||
assertThat(result.path("totals").path("degreesOfFreedom").asInt()).isEqualTo(20);
|
||||
@@ -199,95 +253,95 @@ class MatchingApiTest {
|
||||
|
||||
@Test
|
||||
void bestMatchingTorsoStaysSelectedEvenWhenAnotherTorsoCouldConnectMoreParts() throws Exception {
|
||||
save("CW-EXACT-LEAF", "torso_0", 20, "1", "0", "铝合金");
|
||||
save("CW-FALLBACK-T", "torso_0", 0, "8", "0", "steel", metadata("BASE", "arm_r"), json.readTree("[]"));
|
||||
save("CW-FALLBACK-R", "arm_r", 4, "5", "10", "steel");
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("torso_0", "arm_r"));
|
||||
save("CW-EXACT-LEAF", "TORSO_0", 20, "1", "0", "铝合金");
|
||||
save("CW-FALLBACK-T", "TORSO_0", 0, "8", "0", "steel", metadata("BASE", "ARM_R"), json.readTree("[]"));
|
||||
save("CW-FALLBACK-R", "ARM_R", 4, "5", "10", "steel");
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("TORSO_0", "ARM_R"));
|
||||
body.put("robotRequirements", Map.of("degreesOfFreedom", 20, "massKg", 10, "operators", Map.of("massKg", "lte")));
|
||||
body.put("partRequirements", List.of(Map.of("category", "torso_0", "material", "铝合金"),
|
||||
Map.of("category", "arm_r", "torqueNm", 20, "operators", Map.of("torqueNm", "gte"))));
|
||||
body.put("partRequirements", List.of(Map.of("category", "TORSO_0", "material", "铝合金"),
|
||||
Map.of("category", "ARM_R", "torqueNm", 20, "operators", Map.of("torqueNm", "gte"))));
|
||||
JsonNode result = match(body);
|
||||
assertThat(result.path("status").asText()).isEqualTo("PARTIAL");
|
||||
assertThat(result.path("parts").size()).isEqualTo(1);
|
||||
assertThat(part(result, "torso_0").path("componentCode").asText()).isEqualTo("CW-EXACT-LEAF");
|
||||
assertThat(part(result, "TORSO_0").path("componentCode").asText()).isEqualTo("CW-EXACT-LEAF");
|
||||
assertThat(result.path("unmetRequirements")).isEmpty();
|
||||
assertThat(result.path("missingParts").get(0).path("category").asText()).isEqualTo("arm_r");
|
||||
assertThat(result.path("missingParts").get(0).path("category").asText()).isEqualTo("ARM_R");
|
||||
assertThat(result.path("missingParts").get(0).path("reason").asText()).isEqualTo("NO_COMPATIBLE_CONNECTION");
|
||||
}
|
||||
|
||||
@Test
|
||||
void searchesGlobalDegreeCombinationInsteadOfChoosingEveryPartIndependently() throws Exception {
|
||||
save("CW-T", "torso_0", 0, "1", "0", "", metadata("BASE", "arm_l", "arm_r"), json.readTree("[]"));
|
||||
save("CW-L5", "arm_l", 5, "1", "0", "");
|
||||
save("CW-L8", "arm_l", 8, "1", "0", "");
|
||||
save("CW-R7", "arm_r", 7, "1", "0", "");
|
||||
save("CW-R12", "arm_r", 12, "1", "0", "");
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("torso_0", "arm_l", "arm_r"));
|
||||
save("CW-T", "TORSO_0", 0, "1", "0", "", metadata("BASE", "ARM_L", "ARM_R"), json.readTree("[]"));
|
||||
save("CW-L5", "ARM_L", 5, "1", "0", "");
|
||||
save("CW-L8", "ARM_L", 8, "1", "0", "");
|
||||
save("CW-R7", "ARM_R", 7, "1", "0", "");
|
||||
save("CW-R12", "ARM_R", 12, "1", "0", "");
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("TORSO_0", "ARM_L", "ARM_R"));
|
||||
body.put("robotRequirements", Map.of("degreesOfFreedom", 20));
|
||||
JsonNode result = match(body);
|
||||
assertThat(result.path("status").asText()).isEqualTo("MATCHED");
|
||||
assertThat(part(result, "arm_l").path("componentCode").asText()).isEqualTo("CW-L8");
|
||||
assertThat(part(result, "arm_r").path("componentCode").asText()).isEqualTo("CW-R12");
|
||||
assertThat(part(result, "ARM_L").path("componentCode").asText()).isEqualTo("CW-L8");
|
||||
assertThat(part(result, "ARM_R").path("componentCode").asText()).isEqualTo("CW-R12");
|
||||
assertThat(result.path("totals").path("degreesOfFreedom").asInt()).isEqualTo(20);
|
||||
}
|
||||
|
||||
@Test
|
||||
void torsoKeywordRelevancePrecedesInterfaceCoverageAndIncludesTorsoWhenOmitted() throws Exception {
|
||||
save("CW-A-RELEVANT", "torso_0", 0, "1", "0", "", metadata("BASE", "arm_r"), json.readTree("[]"));
|
||||
save("CW-B-MORE-PORTS", "torso_0", 0, "1", "0", "", metadata("BASE", "arm_r", "head_0"), json.readTree("[]"));
|
||||
save("CW-R", "arm_r", 4, "1", "20", "");
|
||||
save("CW-H", "head_0", 0, "1", "0", "");
|
||||
save("CW-A-RELEVANT", "TORSO_0", 0, "1", "0", "", metadata("BASE", "ARM_R"), json.readTree("[]"));
|
||||
save("CW-B-MORE-PORTS", "TORSO_0", 0, "1", "0", "", metadata("BASE", "ARM_R", "HEAD_0"), json.readTree("[]"));
|
||||
save("CW-R", "ARM_R", 4, "1", "20", "");
|
||||
save("CW-H", "HEAD_0", 0, "1", "0", "");
|
||||
jdbc.update("UPDATE component SET function_description='用于奔跑' WHERE component_code='CW-A-RELEVANT'");
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("arm_r", "head_0"));
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("ARM_R", "HEAD_0"));
|
||||
body.put("requirements", List.of("跑步"));
|
||||
JsonNode result = match(body);
|
||||
assertThat(result.path("rootCategory").asText()).isEqualTo("torso_0");
|
||||
assertThat(part(result, "torso_0").path("componentCode").asText()).isEqualTo("CW-A-RELEVANT");
|
||||
assertThat(result.path("rootCategory").asText()).isEqualTo("TORSO_0");
|
||||
assertThat(part(result, "TORSO_0").path("componentCode").asText()).isEqualTo("CW-A-RELEVANT");
|
||||
assertThat(result.path("parts")).hasSize(2);
|
||||
assertThat(result.path("status").asText()).isEqualTo("PARTIAL");
|
||||
assertThat(result.path("missingParts").get(0).path("category").asText()).isEqualTo("head_0");
|
||||
assertThat(result.path("missingParts").get(0).path("category").asText()).isEqualTo("HEAD_0");
|
||||
assertThat(result.path("unmatchedKeywords")).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
void evaluatesWholeRobotTotalsAfterTorsoSelectionAndKeepsTorsoFixedInFallbackSearch() throws Exception {
|
||||
save("CW-A", "torso_0", 0, "1", "0", "", metadata("BASE", "arm_r"), json.readTree("[]"));
|
||||
save("CW-B", "torso_0", 16, "1", "0", "", metadata("BASE", "arm_r"), json.readTree("[]"));
|
||||
save("CW-R", "arm_r", 4, "1", "20", "");
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("躯干_0", "torso_0", "臂_r"));
|
||||
save("CW-A", "TORSO_0", 0, "1", "0", "", metadata("BASE", "ARM_R"), json.readTree("[]"));
|
||||
save("CW-B", "TORSO_0", 16, "1", "0", "", metadata("BASE", "ARM_R"), json.readTree("[]"));
|
||||
save("CW-R", "ARM_R", 4, "1", "20", "");
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("躯干_0", "TORSO_0", "臂_r"));
|
||||
body.put("robotRequirements", Map.of("degreesOfFreedom", 20));
|
||||
body.put("partRequirements", List.of(Map.of("category", "arm_r", "torqueNm", 30, "operators", Map.of("torqueNm", "gte"))));
|
||||
body.put("partRequirements", List.of(Map.of("category", "ARM_R", "torqueNm", 30, "operators", Map.of("torqueNm", "gte"))));
|
||||
RobotMatchingService service = context.getBean(RobotMatchingService.class);
|
||||
RobotMatchResponse result = service.matchConfirmed(json.convertValue(body, RobotMatchRequest.class));
|
||||
assertThat(result.rootCategory()).isEqualTo("torso_0");
|
||||
assertThat(result.parts()).filteredOn((com.linkerbot.cadworld.dto.matching.PublicComponentResponse component) -> component.category().equals("torso_0"))
|
||||
assertThat(result.rootCategory()).isEqualTo("TORSO_0");
|
||||
assertThat(result.parts()).filteredOn((com.linkerbot.cadworld.dto.matching.PublicComponentResponse component) -> component.category().equals("TORSO_0"))
|
||||
.hasSize(1).extracting(com.linkerbot.cadworld.dto.matching.PublicComponentResponse::componentCode).containsExactly("CW-A");
|
||||
assertThat(result.parts()).hasSize(2);
|
||||
assertThat(result.totals().degreesOfFreedom()).isEqualTo(4);
|
||||
assertThat(result.unmetRequirements()).extracting(RobotMatchResponse.UnmetRequirement::field).contains("degreesOfFreedom", "torqueNm");
|
||||
assertThat(result.connections()).allMatch((RobotMatchResponse.Connection connection) -> !connection.childCategory().equals("torso_0"));
|
||||
assertThat(result.connections()).allMatch((RobotMatchResponse.Connection connection) -> !connection.childCategory().equals("TORSO_0"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void followsChainsWithoutAssumingRequestedRoleOrderAndNeverCreatesCycles() throws Exception {
|
||||
save("CW-T", "torso_0", 0, "1", "0", "", metadata("BASE", "arm_r"), json.readTree("[]"));
|
||||
save("CW-R", "arm_r", 3, "1", "0", "", metadata("RIGHT", "head_0", "hand_r", "torso_0"), json.readTree("[]"));
|
||||
save("CW-H", "head_0", 0, "1", "0", "");
|
||||
save("CW-HAND", "hand_r", 2, "1", "0", "");
|
||||
JsonNode result = match(request("head_0", "hand_r", "torso_0", "arm_r"));
|
||||
save("CW-T", "TORSO_0", 0, "1", "0", "", metadata("BASE", "ARM_R"), json.readTree("[]"));
|
||||
save("CW-R", "ARM_R", 3, "1", "0", "", metadata("RIGHT", "HEAD_0", "HAND_R", "TORSO_0"), json.readTree("[]"));
|
||||
save("CW-H", "HEAD_0", 0, "1", "0", "");
|
||||
save("CW-HAND", "HAND_R", 2, "1", "0", "");
|
||||
JsonNode result = match(request("HEAD_0", "HAND_R", "TORSO_0", "ARM_R"));
|
||||
assertThat(result.path("status").asText()).isEqualTo("MATCHED");
|
||||
assertThat(result.path("connections").size()).isEqualTo(3);
|
||||
for (JsonNode connection : result.path("connections")) {
|
||||
assertThat(connection.path("childCategory").asText()).isNotEqualTo("torso_0");
|
||||
assertThat(connection.path("childCategory").asText()).isNotEqualTo("TORSO_0");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void doesNotAddUnrequestedConnectorsAndKeepsLeftRightIndependent() throws Exception {
|
||||
save("CW-T", "torso_0", 0, "1", "0", "", metadata("BASE", "arm_l", "arm_r"), json.readTree("[]"));
|
||||
save("CW-L", "arm_l", 1, "1", "0", "", metadata("LEFT", "hand_l"), json.readTree("[]"));
|
||||
save("CW-HAND", "hand_l", 1, "1", "0", "");
|
||||
JsonNode result = match(request("torso_0", "hand_l", "arm_r"));
|
||||
save("CW-T", "TORSO_0", 0, "1", "0", "", metadata("BASE", "ARM_L", "ARM_R"), json.readTree("[]"));
|
||||
save("CW-L", "ARM_L", 1, "1", "0", "", metadata("LEFT", "HAND_L"), json.readTree("[]"));
|
||||
save("CW-HAND", "HAND_L", 1, "1", "0", "");
|
||||
JsonNode result = match(request("TORSO_0", "HAND_L", "ARM_R"));
|
||||
assertThat(result.path("status").asText()).isEqualTo("PARTIAL");
|
||||
assertThat(result.path("parts").size()).isEqualTo(1);
|
||||
assertThat(result.path("missingParts").size()).isEqualTo(2);
|
||||
@@ -296,10 +350,10 @@ class MatchingApiTest {
|
||||
|
||||
@Test
|
||||
void missingTorsoCannotUseAnotherRoleAsAssemblyRoot() throws Exception {
|
||||
save("CW-HEAD", "head_0", 0, "1", "0", "");
|
||||
save("CW-R", "arm_r", 3, "1", "0", "", metadata("RIGHT", "hand_r"), json.readTree("[]"));
|
||||
save("CW-HAND", "hand_r", 2, "1", "0", "");
|
||||
JsonNode result = match(request("torso_0", "head_0", "arm_r", "hand_r"));
|
||||
save("CW-HEAD", "HEAD_0", 0, "1", "0", "");
|
||||
save("CW-R", "ARM_R", 3, "1", "0", "", metadata("RIGHT", "HAND_R"), json.readTree("[]"));
|
||||
save("CW-HAND", "HAND_R", 2, "1", "0", "");
|
||||
JsonNode result = match(request("TORSO_0", "HEAD_0", "ARM_R", "HAND_R"));
|
||||
assertThat(result.path("status").asText()).isEqualTo("NO_MATCH");
|
||||
assertThat(result.path("rootCategory").isNull()).isTrue();
|
||||
assertThat(result.path("parts")).isEmpty();
|
||||
@@ -310,11 +364,11 @@ class MatchingApiTest {
|
||||
|
||||
@Test
|
||||
void unknownMassDoesNotPretendToMeetMassLimit() throws Exception {
|
||||
save("CW-T", "torso_0", 0, "0", "0", "", metadata("BASE", "arm_r"), json.readTree("[]"));
|
||||
save("CW-R", "arm_r", 4, "2", "0", "");
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("torso_0", "arm_r"));
|
||||
save("CW-T", "TORSO_0", 0, "0", "0", "", metadata("BASE", "ARM_R"), json.readTree("[]"));
|
||||
save("CW-R", "ARM_R", 4, "2", "0", "");
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("TORSO_0", "ARM_R"));
|
||||
body.put("robotRequirements", Map.of("massKg", 10, "operators", Map.of("massKg", "lte")));
|
||||
body.put("partRequirements", List.of(Map.of("category", "torso_0", "massKg", 1, "operators", Map.of("massKg", "lte"))));
|
||||
body.put("partRequirements", List.of(Map.of("category", "TORSO_0", "massKg", 1, "operators", Map.of("massKg", "lte"))));
|
||||
JsonNode result = match(body);
|
||||
assertThat(result.path("status").asText()).isEqualTo("FALLBACK");
|
||||
assertThat(result.path("totals").path("massKg").isNull()).isTrue();
|
||||
@@ -326,20 +380,20 @@ class MatchingApiTest {
|
||||
|
||||
@Test
|
||||
void alternativesKeepChildrenRecomputePosesRootsAndGlobalConstraints() throws Exception {
|
||||
JsonNode first = metadata("BASE_A", "arm_r");
|
||||
JsonNode second = metadata("BASE_B", "arm_r");
|
||||
JsonNode first = metadata("BASE_A", "ARM_R");
|
||||
JsonNode second = metadata("BASE_B", "ARM_R");
|
||||
((com.fasterxml.jackson.databind.node.ObjectNode) second.path("frames").get(0))
|
||||
.set("xyz", json.readTree("[2,3,4]"));
|
||||
save("CW-A", "torso_0", 5, "1", "0", "", first, json.readTree("[]"));
|
||||
save("CW-B", "torso_0", 9, "3", "0", "", second, json.readTree("{\"replacement\":true}"));
|
||||
save("CW-BAD", "torso_0", 5, "1", "0", "");
|
||||
save("CW-R", "arm_r", 1, "1", "0", "", metadata("ROOT_R"), json.readTree("[]"));
|
||||
save("CW-R2", "arm_r", 1, "1", "0", "", metadata("NEW_ROOT_R"), json.readTree("[]"));
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("torso_0", "arm_r"));
|
||||
save("CW-A", "TORSO_0", 5, "1", "0", "", first, json.readTree("[]"));
|
||||
save("CW-B", "TORSO_0", 9, "3", "0", "", second, json.readTree("{\"replacement\":true}"));
|
||||
save("CW-BAD", "TORSO_0", 5, "1", "0", "");
|
||||
save("CW-R", "ARM_R", 1, "1", "0", "", metadata("ROOT_R"), json.readTree("[]"));
|
||||
save("CW-R2", "ARM_R", 1, "1", "0", "", metadata("NEW_ROOT_R"), json.readTree("[]"));
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("TORSO_0", "ARM_R"));
|
||||
body.put("robotRequirements", Map.of("degreesOfFreedom", 6, "massKg", 3, "operators", Map.of("massKg", "lte")));
|
||||
JsonNode result = match(body);
|
||||
assertThat(part(result, "torso_0").path("componentCode").asText()).isEqualTo("CW-A");
|
||||
JsonNode torsoItems = alternatives(result, "torso_0");
|
||||
assertThat(part(result, "TORSO_0").path("componentCode").asText()).isEqualTo("CW-A");
|
||||
JsonNode torsoItems = alternatives(result, "TORSO_0");
|
||||
assertThat(torsoItems.size()).isEqualTo(1);
|
||||
JsonNode replacement = torsoItems.get(0);
|
||||
assertThat(replacement.path("component").path("componentCode").asText()).isEqualTo("CW-B");
|
||||
@@ -347,59 +401,59 @@ class MatchingApiTest {
|
||||
assertThat(replacement.path("connections").get(0).path("parentLink").asText()).isEqualTo("BASE_B");
|
||||
assertThat(replacement.path("totals").path("massKg").decimalValue()).isEqualByComparingTo("4");
|
||||
assertThat(replacement.path("unmetRequirements").size()).isEqualTo(2);
|
||||
assertThat(alternatives(result, "arm_r").get(0).path("connections").get(0).path("childRootLink").asText()).isEqualTo("NEW_ROOT_R");
|
||||
assertThat(alternatives(result, "ARM_R").get(0).path("connections").get(0).path("childRootLink").asText()).isEqualTo("NEW_ROOT_R");
|
||||
}
|
||||
|
||||
@Test
|
||||
void ignoresInvalidAndDuplicatePortsWithoutChangingReturnedMetadata() throws Exception {
|
||||
JsonNode metadata = json.readTree("""
|
||||
{"rootLink":"BASE","frames":[
|
||||
{"name":"duplicate","kind":"joint","type":"fixed","parent":"BASE","child":"LINK_arm_r","interfaceType":"arm_r","xyz":[0,0,0],"rpy":[0,0,0]},
|
||||
{"name":"duplicate","kind":"joint","type":"fixed","parent":"BASE","child":"LINK_arm_r","interfaceType":"arm_r","xyz":[0,0,0],"rpy":[0,0,0]},
|
||||
{"name":"bad_pose","kind":"joint","type":"fixed","parent":"BASE","child":"C","interfaceType":"head_0","xyz":[0,0],"rpy":[0,0,0]},
|
||||
{"name":"implicit","kind":"joint","type":"fixed","parent":"BASE","child":"LINK_hand_r","interfaceType":"hand_r","originExplicit":false}
|
||||
{"name":"duplicate","kind":"joint","type":"fixed","parent":"BASE","child":"LINK_ARM_R","interfaceType":"ARM_R","xyz":[0,0,0],"rpy":[0,0,0]},
|
||||
{"name":"duplicate","kind":"joint","type":"fixed","parent":"BASE","child":"LINK_ARM_R","interfaceType":"ARM_R","xyz":[0,0,0],"rpy":[0,0,0]},
|
||||
{"name":"bad_pose","kind":"joint","type":"fixed","parent":"BASE","child":"C","interfaceType":"HEAD_0","xyz":[0,0],"rpy":[0,0,0]},
|
||||
{"name":"implicit","kind":"joint","type":"fixed","parent":"BASE","child":"LINK_HAND_R","interfaceType":"HAND_R","originExplicit":false}
|
||||
]}
|
||||
""");
|
||||
save("CW-T", "torso_0", 0, "1", "0", "", metadata, json.readTree("[]"));
|
||||
save("CW-R", "arm_r", 1, "1", "0", "");
|
||||
save("CW-H", "hand_r", 1, "1", "0", "");
|
||||
JsonNode result = match(request("torso_0", "arm_r", "hand_r"));
|
||||
save("CW-T", "TORSO_0", 0, "1", "0", "", metadata, json.readTree("[]"));
|
||||
save("CW-R", "ARM_R", 1, "1", "0", "");
|
||||
save("CW-H", "HAND_R", 1, "1", "0", "");
|
||||
JsonNode result = match(request("TORSO_0", "ARM_R", "HAND_R"));
|
||||
assertThat(result.path("parts")).hasSize(4);
|
||||
assertThat(result.path("connections")).hasSize(3);
|
||||
assertThat(result.path("connections").get(0).has("xyz")).isFalse();
|
||||
assertThat(part(result, "torso_0").get("urdfInfo")).isEqualTo(metadata);
|
||||
assertThat(part(result, "TORSO_0").get("urdfInfo")).isEqualTo(metadata);
|
||||
}
|
||||
|
||||
@Test
|
||||
void logicDeletedComponentsDisappearAndResourceReplacementChangesDirectUrl() throws Exception {
|
||||
save("CW-T", "torso_0", 0, "1", "0", "");
|
||||
save("CW-T", "TORSO_0", 0, "1", "0", "");
|
||||
String firstUrl = components.get("CW-T").urdfUrl();
|
||||
jdbc.update("UPDATE component SET version=2,urdf_main_object_key='cadworld/components/CW-T/urdf/new-batch/robot.urdf' WHERE component_code='CW-T'");
|
||||
assertThat(components.get("CW-T").urdfUrl()).isNotEqualTo(firstUrl).contains("/new-batch/");
|
||||
jdbc.update("UPDATE component SET deleted=1 WHERE component_code='CW-T'");
|
||||
mvc.perform(get("/api/components/CW-T")).andExpect(status().isNotFound());
|
||||
assertThat(match(request("torso_0")).path("status").asText()).isEqualTo("NO_MATCH");
|
||||
assertThat(match(request("TORSO_0")).path("status").asText()).isEqualTo("NO_MATCH");
|
||||
}
|
||||
|
||||
@Test
|
||||
void stableResultsAndAlternativesAreCappedAtFive() throws Exception {
|
||||
for (int index = 9; index >= 0; index--) save("CW-" + index, "torso_0", 0, "1", "0", "");
|
||||
JsonNode first = match(request("torso_0"));
|
||||
JsonNode second = match(request("torso_0"));
|
||||
for (int index = 9; index >= 0; index--) save("CW-" + index, "TORSO_0", 0, "1", "0", "");
|
||||
JsonNode first = match(request("TORSO_0"));
|
||||
JsonNode second = match(request("TORSO_0"));
|
||||
assertThat(first).isEqualTo(second);
|
||||
assertThat(first.path("parts").get(0).path("componentCode").asText()).isEqualTo("CW-0");
|
||||
assertThat(alternatives(first, "torso_0").size()).isEqualTo(5);
|
||||
assertThat(alternatives(first, "TORSO_0").size()).isEqualTo(5);
|
||||
}
|
||||
|
||||
@Test
|
||||
void boundedSearchReturnsBestKnownConnectedResultAndMarksLimit() throws Exception {
|
||||
save("CW-T", "torso_0", 0, "1", "0", "", metadata("BASE", "arm_l", "arm_r", "head_0"), json.readTree("[]"));
|
||||
save("CW-L", "arm_l", 1, "1", "0", "");
|
||||
save("CW-R", "arm_r", 1, "1", "0", "");
|
||||
save("CW-H", "head_0", 1, "1", "0", "");
|
||||
save("CW-T", "TORSO_0", 0, "1", "0", "", metadata("BASE", "ARM_L", "ARM_R", "HEAD_0"), json.readTree("[]"));
|
||||
save("CW-L", "ARM_L", 1, "1", "0", "");
|
||||
save("CW-R", "ARM_R", 1, "1", "0", "");
|
||||
save("CW-H", "HEAD_0", 1, "1", "0", "");
|
||||
MatchingProperties tiny = new MatchingProperties(50, 30, 128, 1, Map.of());
|
||||
RobotMatchingService service = new RobotMatchingService(components, evaluator, new AssemblySearchEngine(tiny, evaluator), tiny);
|
||||
RobotMatchResponse result = service.match(json.convertValue(request("torso_0", "arm_l", "arm_r", "head_0"), RobotMatchRequest.class));
|
||||
RobotMatchResponse result = service.match(json.convertValue(request("TORSO_0", "ARM_L", "ARM_R", "HEAD_0"), RobotMatchRequest.class));
|
||||
assertThat(result.searchLimited()).isTrue();
|
||||
assertThat(result.status()).isEqualTo("PARTIAL");
|
||||
assertThat(result.parts()).hasSize(2);
|
||||
@@ -409,11 +463,11 @@ class MatchingApiTest {
|
||||
|
||||
@Test
|
||||
void candidateTruncationIsReportedRatherThanClaimingAnExactOptimum() throws Exception {
|
||||
save("CW-A", "torso_0", 1, "1", "0", "");
|
||||
save("CW-B", "torso_0", 2, "1", "0", "");
|
||||
save("CW-A", "TORSO_0", 1, "1", "0", "");
|
||||
save("CW-B", "TORSO_0", 2, "1", "0", "");
|
||||
MatchingProperties tiny = new MatchingProperties(1, 1, 128, 50000, Map.of());
|
||||
RobotMatchingService service = new RobotMatchingService(components, evaluator, new AssemblySearchEngine(tiny, evaluator), tiny);
|
||||
RobotMatchResponse result = service.match(json.convertValue(request("torso_0"), RobotMatchRequest.class));
|
||||
RobotMatchResponse result = service.match(json.convertValue(request("TORSO_0"), RobotMatchRequest.class));
|
||||
assertThat(result.parts()).hasSize(1);
|
||||
assertThat(result.searchLimited()).isTrue();
|
||||
}
|
||||
@@ -421,41 +475,41 @@ class MatchingApiTest {
|
||||
@Test
|
||||
void scansPastFirstDatabasePageAndKeepsAConnectorOutsidePreferredCandidates() throws Exception {
|
||||
for (int index = 0; index < 205; index++) {
|
||||
save(String.format(java.util.Locale.ROOT, "CW-P%03d", index), "torso_0", 0, "1", "0", "");
|
||||
save(String.format(java.util.Locale.ROOT, "CW-P%03d", index), "TORSO_0", 0, "1", "0", "");
|
||||
}
|
||||
save("CW-Z-CONNECTOR", "torso_0", 0, "1", "0", "", metadata("BASE", "arm_r"), json.readTree("[]"));
|
||||
save("CW-ARM", "arm_r", 1, "1", "0", "");
|
||||
JsonNode result = match(request("torso_0", "arm_r"));
|
||||
save("CW-Z-CONNECTOR", "TORSO_0", 0, "1", "0", "", metadata("BASE", "ARM_R"), json.readTree("[]"));
|
||||
save("CW-ARM", "ARM_R", 1, "1", "0", "");
|
||||
JsonNode result = match(request("TORSO_0", "ARM_R"));
|
||||
assertThat(result.path("status").asText()).isEqualTo("MATCHED");
|
||||
assertThat(result.path("searchLimited").asBoolean()).isTrue();
|
||||
assertThat(part(result, "torso_0").path("componentCode").asText()).isEqualTo("CW-Z-CONNECTOR");
|
||||
assertThat(part(result, "TORSO_0").path("componentCode").asText()).isEqualTo("CW-Z-CONNECTOR");
|
||||
}
|
||||
|
||||
@Test
|
||||
void keepsNumericExtremesOutsidePreferredCandidatesForGlobalGoals() throws Exception {
|
||||
save("CW-T", "torso_0", 0, "1", "0", "", metadata("BASE", "arm_r"), json.readTree("[]"));
|
||||
save("CW-T", "TORSO_0", 0, "1", "0", "", metadata("BASE", "ARM_R"), json.readTree("[]"));
|
||||
for (int index = 0; index < 60; index++) {
|
||||
save(String.format(java.util.Locale.ROOT, "CW-P%03d", index), "arm_r", 1, "1", "0", "");
|
||||
save(String.format(java.util.Locale.ROOT, "CW-P%03d", index), "ARM_R", 1, "1", "0", "");
|
||||
}
|
||||
save("CW-Z-EXTREME", "arm_r", 20, "1", "0", "");
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("torso_0", "arm_r"));
|
||||
save("CW-Z-EXTREME", "ARM_R", 20, "1", "0", "");
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("TORSO_0", "ARM_R"));
|
||||
body.put("robotRequirements", Map.of("degreesOfFreedom", 20));
|
||||
JsonNode result = match(body);
|
||||
assertThat(result.path("status").asText()).isEqualTo("MATCHED");
|
||||
assertThat(result.path("searchLimited").asBoolean()).isTrue();
|
||||
assertThat(part(result, "arm_r").path("componentCode").asText()).isEqualTo("CW-Z-EXTREME");
|
||||
assertThat(part(result, "ARM_R").path("componentCode").asText()).isEqualTo("CW-Z-EXTREME");
|
||||
}
|
||||
|
||||
@Test
|
||||
void defaultsNumericComparisonToEqualityAndUsesGteLteWithoutRounding() throws Exception {
|
||||
save("CW-T", "torso_0", 0, "1", "0", "", metadata("BASE", "arm_r"), json.readTree("[]"));
|
||||
save("CW-R", "arm_r", 5, "1.000001", "20.000001", "");
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("arm_r"));
|
||||
save("CW-T", "TORSO_0", 0, "1", "0", "", metadata("BASE", "ARM_R"), json.readTree("[]"));
|
||||
save("CW-R", "ARM_R", 5, "1.000001", "20.000001", "");
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("ARM_R"));
|
||||
body.put("robotRequirements", Map.of("degreesOfFreedom", 4, "operators", Map.of("degreesOfFreedom", "gte")));
|
||||
body.put("partRequirements", List.of(Map.of("category", "arm_r", "torqueNm", new BigDecimal("20.000001"),
|
||||
body.put("partRequirements", List.of(Map.of("category", "ARM_R", "torqueNm", new BigDecimal("20.000001"),
|
||||
"massKg", new BigDecimal("1.000001"), "operators", Map.of("massKg", "lte"))));
|
||||
assertThat(match(body).path("status").asText()).isEqualTo("MATCHED");
|
||||
body.put("partRequirements", List.of(Map.of("category", "arm_r", "torqueNm", 20)));
|
||||
body.put("partRequirements", List.of(Map.of("category", "ARM_R", "torqueNm", 20)));
|
||||
JsonNode fallback = match(body);
|
||||
assertThat(fallback.path("status").asText()).isEqualTo("FALLBACK");
|
||||
assertThat(fallback.path("unmetRequirements").get(0).path("operator").asText()).isEqualTo("eq");
|
||||
@@ -466,7 +520,7 @@ class MatchingApiTest {
|
||||
@ValueSource(strings = {"-1", "1.5", "1.0", "\"1\"", "true", "2147483648"})
|
||||
void rejectsInvalidDegreesBeforeSearching(String value) throws Exception {
|
||||
mvc.perform(post("/api/robot-matches").contentType(MediaType.APPLICATION_JSON)
|
||||
.content("{\"requiredParts\":[\"arm_r\"],\"robotRequirements\":{\"degreesOfFreedom\":" + value + "}}"))
|
||||
.content("{\"requiredParts\":[\"ARM_R\"],\"robotRequirements\":{\"degreesOfFreedom\":" + value + "}}"))
|
||||
.andExpect(status().isUnprocessableEntity());
|
||||
}
|
||||
|
||||
@@ -474,21 +528,21 @@ class MatchingApiTest {
|
||||
@ValueSource(strings = {"-1", "20.0000001", "1000000000000", "\"bad\""})
|
||||
void rejectsInvalidTorqueBeforeSearching(String value) throws Exception {
|
||||
mvc.perform(post("/api/robot-matches").contentType(MediaType.APPLICATION_JSON)
|
||||
.content("{\"requiredParts\":[\"arm_r\"],\"partRequirements\":[{\"category\":\"arm_r\",\"torqueNm\":" + value + "}]}"))
|
||||
.content("{\"requiredParts\":[\"ARM_R\"],\"partRequirements\":[{\"category\":\"ARM_R\",\"torqueNm\":" + value + "}]}"))
|
||||
.andExpect(status().isUnprocessableEntity());
|
||||
}
|
||||
|
||||
@Test
|
||||
void acceptsNumericBoundariesAndRejectsAmbiguousOrUnsupportedRequirements() throws Exception {
|
||||
match(Map.of("requiredParts", List.of("arm_r"), "robotRequirements", Map.of("degreesOfFreedom", 2147483647),
|
||||
"partRequirements", List.of(Map.of("category", "arm_r", "torqueNm", new BigDecimal("999999999999.999999")))));
|
||||
match(Map.of("requiredParts", List.of("ARM_R"), "robotRequirements", Map.of("degreesOfFreedom", 2147483647),
|
||||
"partRequirements", List.of(Map.of("category", "ARM_R", "torqueNm", new BigDecimal("999999999999.999999")))));
|
||||
List<Map<String, Object>> invalid = List.of(
|
||||
Map.of("requiredParts", List.of()), Map.of("requiredParts", List.of("unknown")),
|
||||
Map.of("requiredParts", List.of("arm_r"), "robotRequirements", Map.of("operators", Map.of("massKg", "lte"))),
|
||||
Map.of("requiredParts", List.of("arm_r"), "robotRequirements", Map.of("massKg", 10, "operators", Map.of("massKg", "lt"))),
|
||||
Map.of("requiredParts", List.of("arm_r"), "partRequirements", List.of(Map.of("category", "head_0"))),
|
||||
Map.of("requiredParts", List.of("arm_r"), "partRequirements", List.of(Map.of("category", "arm_r"), Map.of("category", "臂_r"))),
|
||||
Map.of("requiredParts", List.of("arm_r"), "robotRequirements", Map.of("torqueNm", 1)));
|
||||
Map.of("requiredParts", List.of("ARM_R"), "robotRequirements", Map.of("operators", Map.of("massKg", "lte"))),
|
||||
Map.of("requiredParts", List.of("ARM_R"), "robotRequirements", Map.of("massKg", 10, "operators", Map.of("massKg", "lt"))),
|
||||
Map.of("requiredParts", List.of("ARM_R"), "partRequirements", List.of(Map.of("category", "HEAD_0"))),
|
||||
Map.of("requiredParts", List.of("ARM_R"), "partRequirements", List.of(Map.of("category", "ARM_R"), Map.of("category", "臂_r"))),
|
||||
Map.of("requiredParts", List.of("ARM_R"), "robotRequirements", Map.of("torqueNm", 1)));
|
||||
for (Map<String, Object> body : invalid) {
|
||||
mvc.perform(post("/api/robot-matches").contentType(MediaType.APPLICATION_JSON).content(json.writeValueAsString(body)))
|
||||
.andExpect(status().isUnprocessableEntity());
|
||||
@@ -502,15 +556,15 @@ class MatchingApiTest {
|
||||
appender.start();
|
||||
logger.addAppender(appender);
|
||||
try {
|
||||
save("CW-T", "torso_0", 0, "1", "0", "", metadata("private-urdf-marker"),
|
||||
save("CW-T", "TORSO_0", 0, "1", "0", "", metadata("private-urdf-marker"),
|
||||
json.readTree("{\"private-bom-marker\":true}"));
|
||||
match(Map.of("requiredParts", List.of("torso_0"), "userInput", "private-input-marker"));
|
||||
match(Map.of("requiredParts", List.of("torso_0"), "userInput", "private-input-marker",
|
||||
match(Map.of("requiredParts", List.of("TORSO_0"), "userInput", "private-input-marker"));
|
||||
match(Map.of("requiredParts", List.of("TORSO_0"), "userInput", "private-input-marker",
|
||||
"robotRequirements", Map.of("massKg", 0, "operators", Map.of("massKg", "lte"))));
|
||||
String messages = appender.list.stream().map(ILoggingEvent::getFormattedMessage).reduce("", String::concat);
|
||||
assertThat(messages).contains("组件匹配完成", "selectedCount=1", "massKg:VALUE_MISMATCH")
|
||||
.doesNotContain("private-input-marker", "private-bom-marker", "private-urdf-marker");
|
||||
assertThat(json.convertValue(Map.of("requiredParts", List.of("torso_0"), "userInput", "private-input-marker"),
|
||||
assertThat(json.convertValue(Map.of("requiredParts", List.of("TORSO_0"), "userInput", "private-input-marker"),
|
||||
RobotMatchRequest.class).toString()).doesNotContain("private-input-marker");
|
||||
assertThat(components.get("CW-T").toString()).doesNotContain("private-bom-marker", "private-urdf-marker");
|
||||
} finally {
|
||||
@@ -522,17 +576,17 @@ class MatchingApiTest {
|
||||
@ParameterizedTest
|
||||
@org.junit.jupiter.params.provider.ValueSource(ints = {4, 6})
|
||||
void sameComponentFillsEachPhysicalInterfaceAndAlternativesTargetOneInstance(int count) throws Exception {
|
||||
String[] ports = java.util.Collections.nCopies(count, "arm_r").toArray(String[]::new);
|
||||
save("CW-T", "torso_0", 0, "1", "0", "", metadata("BASE", ports), json.readTree("[]"));
|
||||
save("CW-ARM", "arm_r", 1, "1", "10", "");
|
||||
save("CW-ARM-ALT", "arm_r", 1, "2", "10", "");
|
||||
JsonNode result = match(request("arm_r"));
|
||||
String[] ports = java.util.Collections.nCopies(count, "ARM_R").toArray(String[]::new);
|
||||
save("CW-T", "TORSO_0", 0, "1", "0", "", metadata("BASE", ports), json.readTree("[]"));
|
||||
save("CW-ARM", "ARM_R", 1, "1", "10", "");
|
||||
save("CW-ARM-ALT", "ARM_R", 1, "2", "10", "");
|
||||
JsonNode result = match(request("ARM_R"));
|
||||
assertThat(result.path("parts")).hasSize(count + 1);
|
||||
assertThat(result.path("connections")).hasSize(count);
|
||||
List<String> instances = new ArrayList<>();
|
||||
for (JsonNode component : result.path("parts")) {
|
||||
instances.add(component.path("instanceId").asText());
|
||||
if ("arm_r".equals(component.path("category").asText())) assertThat(component.path("componentCode").asText()).isEqualTo("CW-ARM");
|
||||
if ("ARM_R".equals(component.path("category").asText())) assertThat(component.path("componentCode").asText()).isEqualTo("CW-ARM");
|
||||
}
|
||||
assertThat(instances).doesNotHaveDuplicates();
|
||||
assertThat(result.path("totals").path("degreesOfFreedom").asInt()).isEqualTo(count);
|
||||
@@ -540,26 +594,26 @@ class MatchingApiTest {
|
||||
List<Integer> indexes = new ArrayList<>();
|
||||
for (JsonNode edge : result.path("connections")) {
|
||||
indexes.add(edge.path("parentFrameIndex").asInt());
|
||||
assertThat(edge.path("interfaceChild").asText()).isEqualTo("LINK_arm_r");
|
||||
assertThat(edge.path("interfaceChild").asText()).isEqualTo("LINK_ARM_R");
|
||||
assertThat(edge.path("childFrameIndex").asInt()).isZero();
|
||||
assertThat(edge.has("xyz")).isFalse();
|
||||
}
|
||||
assertThat(indexes).doesNotHaveDuplicates();
|
||||
JsonNode group = result.path("alternatives").get(1);
|
||||
assertThat(group.path("instanceId").asText()).isEqualTo("arm_r:1");
|
||||
assertThat(group.path("instanceId").asText()).isEqualTo("ARM_R:1");
|
||||
JsonNode replacement = group.path("items").get(0);
|
||||
assertThat(replacement.path("component").path("instanceId").asText()).isEqualTo("arm_r:1");
|
||||
assertThat(replacement.path("component").path("instanceId").asText()).isEqualTo("ARM_R:1");
|
||||
assertThat(replacement.path("totals").path("massKg").decimalValue()).isEqualByComparingTo(Integer.toString(count + 2));
|
||||
assertThat(replacement.path("connections").findValuesAsText("childComponentCode")).filteredOn((String code) -> code.equals("CW-ARM-ALT")).hasSize(1);
|
||||
}
|
||||
|
||||
@Test void explicitQuantityCapsCopiesAndReportsInsufficientPorts() throws Exception {
|
||||
save("CW-T", "torso_0", 0, "1", "0", "", metadata("BASE", "arm_r", "arm_r", "arm_r", "arm_r"), json.readTree("[]"));
|
||||
save("CW-A", "arm_r", 1, "1", "0", "");
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("arm_r"));
|
||||
body.put("partRequirements", List.of(Map.of("category", "arm_r", "quantity", 2)));
|
||||
save("CW-T", "TORSO_0", 0, "1", "0", "", metadata("BASE", "ARM_R", "ARM_R", "ARM_R", "ARM_R"), json.readTree("[]"));
|
||||
save("CW-A", "ARM_R", 1, "1", "0", "");
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("ARM_R"));
|
||||
body.put("partRequirements", List.of(Map.of("category", "ARM_R", "quantity", 2)));
|
||||
assertThat(match(body).path("parts")).hasSize(3);
|
||||
body.put("partRequirements", List.of(Map.of("category", "arm_r", "quantity", 6)));
|
||||
body.put("partRequirements", List.of(Map.of("category", "ARM_R", "quantity", 6)));
|
||||
JsonNode result = match(body);
|
||||
assertThat(result.path("parts")).hasSize(5);
|
||||
assertThat(result.path("missingParts").get(0).path("expectedQuantity").asInt()).isEqualTo(6);
|
||||
@@ -568,45 +622,45 @@ class MatchingApiTest {
|
||||
}
|
||||
|
||||
@Test void matchingUsesChildAndInterfaceTypeWithFallbackRegardlessOfNamesOrPoses() throws Exception {
|
||||
save("CW-T", "torso_0", 0, "1", "0", "", metadata("BASE", "head_0"), json.readTree("[]"));
|
||||
save("CW-A", "arm_r", 0, "1", "0", "");
|
||||
save("CW-H", "head_0", 0, "1", "0", "");
|
||||
save("CW-T", "TORSO_0", 0, "1", "0", "", metadata("BASE", "HEAD_0"), json.readTree("[]"));
|
||||
save("CW-A", "ARM_R", 0, "1", "0", "");
|
||||
save("CW-H", "HEAD_0", 0, "1", "0", "");
|
||||
com.fasterxml.jackson.databind.node.ObjectNode torso = (com.fasterxml.jackson.databind.node.ObjectNode) components.get("CW-T").urdfInfo();
|
||||
com.fasterxml.jackson.databind.node.ObjectNode port = (com.fasterxml.jackson.databind.node.ObjectNode) torso.path("frames").get(0);
|
||||
port.put("interfaceType", "arm_r").put("name", "SAME_NAME").put("type", "revolute");
|
||||
port.put("interfaceType", "ARM_R").put("name", "SAME_NAME").put("type", "revolute");
|
||||
port.remove("xyz"); torso.remove("rootLink");
|
||||
jdbc.update("UPDATE component SET urdf_info=? WHERE component_code='CW-T'", torso.toString());
|
||||
com.fasterxml.jackson.databind.node.ObjectNode arm = (com.fasterxml.jackson.databind.node.ObjectNode) components.get("CW-A").urdfInfo();
|
||||
((com.fasterxml.jackson.databind.node.ObjectNode) arm.path("frames").get(0)).put("child", "LINK_head_0");
|
||||
((com.fasterxml.jackson.databind.node.ObjectNode) arm.path("frames").get(0)).put("child", "LINK_HEAD_0");
|
||||
jdbc.update("UPDATE component SET urdf_info=? WHERE component_code='CW-A'", arm.toString());
|
||||
JsonNode result = match(request("arm_r", "head_0"));
|
||||
assertThat(result.path("parts").findValuesAsText("category")).containsExactly("torso_0", "arm_r");
|
||||
JsonNode result = match(request("ARM_R", "HEAD_0"));
|
||||
assertThat(result.path("parts").findValuesAsText("category")).containsExactly("TORSO_0", "ARM_R");
|
||||
port.put("interfaceType", "invalid");
|
||||
jdbc.update("UPDATE component SET urdf_info=? WHERE component_code='CW-T'", torso.toString());
|
||||
result = match(request("arm_r", "head_0"));
|
||||
assertThat(result.path("parts").findValuesAsText("category")).containsExactly("torso_0", "head_0");
|
||||
port.put("child", "LINK_HEAD_0");
|
||||
result = match(request("ARM_R", "HEAD_0"));
|
||||
assertThat(result.path("parts").findValuesAsText("category")).containsExactly("TORSO_0", "HEAD_0");
|
||||
port.put("child", "LINK_head_0");
|
||||
jdbc.update("UPDATE component SET urdf_info=? WHERE component_code='CW-T'", torso.toString());
|
||||
assertThat(match(request("head_0")).path("parts")).hasSize(1);
|
||||
assertThat(match(request("HEAD_0")).path("parts")).hasSize(1);
|
||||
}
|
||||
|
||||
@Test void instanceLimitReturnsBoundedCombination() throws Exception {
|
||||
save("CW-T", "torso_0", 0, "1", "0", "", metadata("BASE", java.util.Collections.nCopies(25, "arm_r").toArray(String[]::new)), json.readTree("[]"));
|
||||
save("CW-A", "arm_r", 0, "1", "0", "");
|
||||
JsonNode result = match(request("arm_r"));
|
||||
save("CW-T", "TORSO_0", 0, "1", "0", "", metadata("BASE", java.util.Collections.nCopies(25, "ARM_R").toArray(String[]::new)), json.readTree("[]"));
|
||||
save("CW-A", "ARM_R", 0, "1", "0", "");
|
||||
JsonNode result = match(request("ARM_R"));
|
||||
assertThat(result.path("parts")).hasSize(24);
|
||||
assertThat(result.path("searchLimited").asBoolean()).isTrue();
|
||||
}
|
||||
|
||||
@Test void fillsRequiredDownstreamTypesBeforeAutomaticExtraCopiesReachLimit() throws Exception {
|
||||
save("CW-T", "torso_0", 0, "1", "0", "", metadata("BASE", java.util.Collections.nCopies(25, "arm_r").toArray(String[]::new)), json.readTree("[]"));
|
||||
save("CW-A", "arm_r", 0, "1", "0", "", metadata("ARM", "head_0"), json.readTree("[]"));
|
||||
save("CW-H", "head_0", 0, "1", "0", "");
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("arm_r", "head_0"));
|
||||
body.put("partRequirements", List.of(Map.of("category", "arm_r", "quantity", 24)));
|
||||
save("CW-T", "TORSO_0", 0, "1", "0", "", metadata("BASE", java.util.Collections.nCopies(25, "ARM_R").toArray(String[]::new)), json.readTree("[]"));
|
||||
save("CW-A", "ARM_R", 0, "1", "0", "", metadata("ARM", "HEAD_0"), json.readTree("[]"));
|
||||
save("CW-H", "HEAD_0", 0, "1", "0", "");
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("ARM_R", "HEAD_0"));
|
||||
body.put("partRequirements", List.of(Map.of("category", "ARM_R", "quantity", 24)));
|
||||
JsonNode result = match(body);
|
||||
assertThat(result.path("parts")).hasSize(24);
|
||||
assertThat(result.path("parts").findValuesAsText("category")).contains("head_0");
|
||||
assertThat(result.path("parts").findValuesAsText("category")).contains("HEAD_0");
|
||||
assertThat(result.path("missingParts").get(0).path("missingQuantity").asInt()).isEqualTo(2);
|
||||
assertThat(result.path("searchLimited").asBoolean()).isTrue();
|
||||
}
|
||||
@@ -619,24 +673,24 @@ class MatchingApiTest {
|
||||
row.path("component_code").asText(), row.path("component_name").asText(), row.path("category").asText(), row.path("urdf_info").toString());
|
||||
}
|
||||
}
|
||||
JsonNode result = match(request("head_0", "torso_0", "waist_0"));
|
||||
assertThat(part(result, "torso_0").path("componentCode").asText()).isEqualTo("CW-BFXXH6TAVTBATHRV");
|
||||
JsonNode result = match(request("HEAD_0", "TORSO_0", "WAIST_0"));
|
||||
assertThat(part(result, "TORSO_0").path("componentCode").asText()).isEqualTo("CW-BFXXH6TAVTBATHRV");
|
||||
assertThat(result.path("parts")).hasSize(2);
|
||||
assertThat(result.path("missingParts").get(0).path("category").asText()).isEqualTo("waist_0");
|
||||
assertThat(result.path("missingParts").get(0).path("category").asText()).isEqualTo("WAIST_0");
|
||||
assertThat(result.path("connections").get(0).path("interfaceChild").asText()).isEqualTo("LINK_HEAD_0");
|
||||
com.fasterxml.jackson.databind.node.ObjectNode waist = (com.fasterxml.jackson.databind.node.ObjectNode) components.get("CW-HANKCSXC8XRV1BRP").urdfInfo();
|
||||
waist.withArray("frames").addObject().put("name", "inbound").put("child", "LINK_WAIST_0").put("interfaceType", "waist_0");
|
||||
waist.withArray("frames").addObject().put("name", "inbound").put("child", "LINK_WAIST_0").put("interfaceType", "WAIST_0");
|
||||
jdbc.update("UPDATE component SET urdf_info=? WHERE component_code='CW-HANKCSXC8XRV1BRP'", waist.toString());
|
||||
JsonNode matched = match(request("head_0", "torso_0", "waist_0"));
|
||||
JsonNode matched = match(request("HEAD_0", "TORSO_0", "WAIST_0"));
|
||||
assertThat(matched.path("parts")).hasSize(3);
|
||||
assertThat(matched.path("connections")).hasSize(2);
|
||||
assertThat(matched.path("missingParts")).isEmpty();
|
||||
}
|
||||
|
||||
@Test void automaticCopiesRespectFeasibleWholeRobotNumericRequirements() throws Exception {
|
||||
save("CW-T", "torso_0", 0, "1", "0", "", metadata("BASE", "arm_r", "arm_r", "arm_r", "arm_r"), json.readTree("[]"));
|
||||
save("CW-A", "arm_r", 1, "1", "0", "");
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("arm_r"));
|
||||
save("CW-T", "TORSO_0", 0, "1", "0", "", metadata("BASE", "ARM_R", "ARM_R", "ARM_R", "ARM_R"), json.readTree("[]"));
|
||||
save("CW-A", "ARM_R", 1, "1", "0", "");
|
||||
Map<String, Object> body = new LinkedHashMap<>(request("ARM_R"));
|
||||
body.put("robotRequirements", Map.of("massKg", 2, "operators", Map.of("massKg", "lte")));
|
||||
JsonNode result = match(body);
|
||||
assertThat(result.path("parts")).hasSize(2);
|
||||
@@ -651,8 +705,8 @@ class MatchingApiTest {
|
||||
@Test void quantitiesRejectFractionsStringsAndOutOfRangeIntegers() throws Exception {
|
||||
for (Object value : List.of(0, -1, 25, 1.5, "4")) {
|
||||
mvc.perform(post("/api/robot-matches").contentType(MediaType.APPLICATION_JSON)
|
||||
.content(json.writeValueAsBytes(Map.of("requiredParts", List.of("arm_r"),
|
||||
"partRequirements", List.of(Map.of("category", "arm_r", "quantity", value))))))
|
||||
.content(json.writeValueAsBytes(Map.of("requiredParts", List.of("ARM_R"),
|
||||
"partRequirements", List.of(Map.of("category", "ARM_R", "quantity", value))))))
|
||||
.andExpect(status().isUnprocessableEntity());
|
||||
}
|
||||
}
|
||||
@@ -701,7 +755,7 @@ class MatchingApiTest {
|
||||
|
||||
private void save(String code, String category, int degrees, String mass, String torque, String material, JsonNode info, JsonNode bom) throws Exception {
|
||||
String role = com.linkerbot.cadworld.service.matching.ComponentRole.find(category).orElseThrow().code();
|
||||
if (!"torso_0".equals(role) && info.isObject()) {
|
||||
if (!"TORSO_0".equals(role) && info.isObject()) {
|
||||
((com.fasterxml.jackson.databind.node.ObjectNode) info).withArray("frames").addObject()
|
||||
.put("name", "INCOMING").put("kind", "joint").put("type", "fixed").put("parent", info.path("rootLink").asText())
|
||||
.put("child", "LINK_" + role).put("interfaceType", role).put("originExplicit", true)
|
||||
|
||||
@@ -24,7 +24,7 @@ class MatchingFailureTest {
|
||||
when(matching.match(any())).thenThrow(new DataAccessResourceFailureException("test database unavailable"));
|
||||
MockMvc mvc = MockMvcBuilders.standaloneSetup(new ComponentMatchingController(matching, mock(PublicComponentQueryService.class)))
|
||||
.setControllerAdvice(new GlobalExceptionHandler()).build();
|
||||
mvc.perform(post("/api/robot-matches").contentType(MediaType.APPLICATION_JSON).content("{\"requiredParts\":[\"torso_0\"]}"))
|
||||
mvc.perform(post("/api/robot-matches").contentType(MediaType.APPLICATION_JSON).content("{\"requiredParts\":[\"TORSO_0\"]}"))
|
||||
.andExpect(status().isServiceUnavailable()).andExpect(jsonPath("$.code").value("DATABASE_UNAVAILABLE"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,335 @@
|
||||
[
|
||||
{
|
||||
"component_code": "CW-AG3XMNWJMN3Q89NX",
|
||||
"component_name": "腰_0_椭圆形(大白)装配",
|
||||
"category": "WAIST_0",
|
||||
"urdf_info": {
|
||||
"frames": [
|
||||
{
|
||||
"rpy": [
|
||||
3.1416,
|
||||
0,
|
||||
3.1416
|
||||
],
|
||||
"xyz": [
|
||||
0,
|
||||
-0.065004,
|
||||
-0.0525
|
||||
],
|
||||
"axis": [
|
||||
0,
|
||||
0,
|
||||
-1
|
||||
],
|
||||
"kind": "joint",
|
||||
"name": "LINK_LEG_R",
|
||||
"type": "continuous",
|
||||
"child": "LINK_LEG_R",
|
||||
"limits": {},
|
||||
"parent": "LINK_WAIST_0",
|
||||
"interfaceName": "LINK_LEG_R",
|
||||
"interfaceType": "LEG_R",
|
||||
"originExplicit": true
|
||||
},
|
||||
{
|
||||
"rpy": [
|
||||
-3.1416,
|
||||
0,
|
||||
3.1416
|
||||
],
|
||||
"xyz": [
|
||||
0,
|
||||
0.064996,
|
||||
-0.0525
|
||||
],
|
||||
"axis": [
|
||||
0,
|
||||
0,
|
||||
-1
|
||||
],
|
||||
"kind": "joint",
|
||||
"name": "LINK_LEG_L",
|
||||
"type": "continuous",
|
||||
"child": "LINK_LEG_L",
|
||||
"limits": {},
|
||||
"parent": "LINK_WAIST_0",
|
||||
"interfaceName": "LINK_LEG_L",
|
||||
"interfaceType": "LEG_L",
|
||||
"originExplicit": true
|
||||
},
|
||||
{
|
||||
"rpy": [
|
||||
-2.3562,
|
||||
0,
|
||||
1.5708
|
||||
],
|
||||
"xyz": [
|
||||
-0.046279,
|
||||
0,
|
||||
-0.031093
|
||||
],
|
||||
"axis": [
|
||||
0,
|
||||
0,
|
||||
-1
|
||||
],
|
||||
"kind": "joint",
|
||||
"name": "LINK_TAIL_0",
|
||||
"type": "continuous",
|
||||
"child": "LINK_TAIL_0",
|
||||
"limits": {},
|
||||
"parent": "LINK_WAIST_0",
|
||||
"interfaceName": "LINK_TAIL_0",
|
||||
"interfaceType": "TAIL_0",
|
||||
"originExplicit": true
|
||||
},
|
||||
{
|
||||
"rpy": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"xyz": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"kind": "interface",
|
||||
"name": "__root_interface__",
|
||||
"child": "LINK_WAIST_0",
|
||||
"isRoot": true,
|
||||
"limits": {},
|
||||
"parent": null,
|
||||
"synthetic": true,
|
||||
"interfaceName": "LINK_WAIST_0",
|
||||
"interfaceType": "WAIST_0",
|
||||
"originExplicit": false
|
||||
}
|
||||
],
|
||||
"rootLink": "LINK_WAIST_0",
|
||||
"robotName": "腰_0_椭圆形(大白)装配"
|
||||
}
|
||||
},
|
||||
{
|
||||
"component_code": "CW-JP19A0XZY9H7YNBN",
|
||||
"component_name": "足_L_足下出基础",
|
||||
"category": "LEG_L",
|
||||
"urdf_info": {
|
||||
"frames": [
|
||||
{
|
||||
"rpy": [
|
||||
0.0012343,
|
||||
0,
|
||||
0.039823
|
||||
],
|
||||
"xyz": [
|
||||
-0.072777,
|
||||
-0.20292,
|
||||
-0.040497
|
||||
],
|
||||
"axis": [
|
||||
0,
|
||||
0,
|
||||
-1
|
||||
],
|
||||
"kind": "joint",
|
||||
"name": "j_1_Link",
|
||||
"type": "continuous",
|
||||
"child": "1_Link",
|
||||
"limits": {},
|
||||
"parent": "LINK_LEG_L",
|
||||
"interfaceName": null,
|
||||
"interfaceType": null,
|
||||
"originExplicit": true
|
||||
},
|
||||
{
|
||||
"rpy": [
|
||||
1.5708,
|
||||
0,
|
||||
0.056332
|
||||
],
|
||||
"xyz": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"axis": [
|
||||
0,
|
||||
0,
|
||||
-1
|
||||
],
|
||||
"kind": "joint",
|
||||
"name": "j_2_Link",
|
||||
"type": "continuous",
|
||||
"child": "2_Link",
|
||||
"limits": {},
|
||||
"parent": "1_Link",
|
||||
"interfaceName": null,
|
||||
"interfaceType": null,
|
||||
"originExplicit": true
|
||||
},
|
||||
{
|
||||
"rpy": [
|
||||
-1.5708,
|
||||
-0.096155,
|
||||
0
|
||||
],
|
||||
"xyz": [
|
||||
0,
|
||||
0.000525,
|
||||
0.085
|
||||
],
|
||||
"axis": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"kind": "joint",
|
||||
"name": "J_LINK_FOOT_0",
|
||||
"type": "fixed",
|
||||
"child": "LINK_FOOT_0",
|
||||
"limits": {},
|
||||
"parent": "2_Link",
|
||||
"interfaceName": "LINK_FOOT_0",
|
||||
"interfaceType": "FOOT_0",
|
||||
"originExplicit": true
|
||||
},
|
||||
{
|
||||
"rpy": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"xyz": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"kind": "interface",
|
||||
"name": "__root_interface__",
|
||||
"child": "LINK_LEG_L",
|
||||
"isRoot": true,
|
||||
"limits": {},
|
||||
"parent": null,
|
||||
"synthetic": true,
|
||||
"interfaceName": "LINK_LEG_L",
|
||||
"interfaceType": "LEG_L",
|
||||
"originExplicit": false
|
||||
}
|
||||
],
|
||||
"rootLink": "LINK_LEG_L",
|
||||
"robotName": "足_L_足下出基础"
|
||||
}
|
||||
},
|
||||
{
|
||||
"component_code": "CW-JBJWXQ7N4C9P03TJ",
|
||||
"component_name": "足_R_足下出基础",
|
||||
"category": "LEG_R",
|
||||
"urdf_info": {
|
||||
"frames": [
|
||||
{
|
||||
"rpy": [
|
||||
0.0012343,
|
||||
0,
|
||||
0.039823
|
||||
],
|
||||
"xyz": [
|
||||
-0.072777,
|
||||
-0.20292,
|
||||
-0.040497
|
||||
],
|
||||
"axis": [
|
||||
0,
|
||||
0,
|
||||
-1
|
||||
],
|
||||
"kind": "joint",
|
||||
"name": "j_1_Link",
|
||||
"type": "continuous",
|
||||
"child": "1_Link",
|
||||
"limits": {},
|
||||
"parent": "LINK_LEG_R",
|
||||
"interfaceName": null,
|
||||
"interfaceType": null,
|
||||
"originExplicit": true
|
||||
},
|
||||
{
|
||||
"rpy": [
|
||||
1.5708,
|
||||
0,
|
||||
0.056332
|
||||
],
|
||||
"xyz": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"axis": [
|
||||
0,
|
||||
0,
|
||||
-1
|
||||
],
|
||||
"kind": "joint",
|
||||
"name": "j_2_Link",
|
||||
"type": "continuous",
|
||||
"child": "2_Link",
|
||||
"limits": {},
|
||||
"parent": "1_Link",
|
||||
"interfaceName": null,
|
||||
"interfaceType": null,
|
||||
"originExplicit": true
|
||||
},
|
||||
{
|
||||
"rpy": [
|
||||
-1.5708,
|
||||
-0.096155,
|
||||
0
|
||||
],
|
||||
"xyz": [
|
||||
0,
|
||||
0.000525,
|
||||
0.085
|
||||
],
|
||||
"axis": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"kind": "joint",
|
||||
"name": "J_LINK_FOOT_0",
|
||||
"type": "fixed",
|
||||
"child": "LINK_FOOT_0",
|
||||
"limits": {},
|
||||
"parent": "2_Link",
|
||||
"interfaceName": "LINK_FOOT_0",
|
||||
"interfaceType": "FOOT_0",
|
||||
"originExplicit": true
|
||||
},
|
||||
{
|
||||
"rpy": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"xyz": [
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"kind": "interface",
|
||||
"name": "__root_interface__",
|
||||
"child": "LINK_LEG_R",
|
||||
"isRoot": true,
|
||||
"limits": {},
|
||||
"parent": null,
|
||||
"synthetic": true,
|
||||
"interfaceName": "LINK_LEG_R",
|
||||
"interfaceType": "LEG_R",
|
||||
"originExplicit": false
|
||||
}
|
||||
],
|
||||
"rootLink": "LINK_LEG_R",
|
||||
"robotName": "足_R_足下出基础"
|
||||
}
|
||||
}
|
||||
]
|
||||
+3
-3
@@ -35,9 +35,9 @@ public final class DemandAssemblyValidator {
|
||||
issues.add(new Issue("NO_COMPONENTS", null, null, "没有可展示的组件", null, null));
|
||||
return new Assembly("blocked", null, List.of(), List.copyOf(issues));
|
||||
}
|
||||
PublicComponentResponse torso = match.parts().stream().filter((PublicComponentResponse part) -> "torso_0".equals(part.category())).findFirst().orElse(null);
|
||||
if (torso == null || !"torso_0".equals(match.rootCategory())) {
|
||||
issues.add(new Issue("INVALID_TORSO_ROOT", "torso_0", null, "整机需要以躯干为根", null, null));
|
||||
PublicComponentResponse torso = match.parts().stream().filter((PublicComponentResponse part) -> "TORSO_0".equals(part.category())).findFirst().orElse(null);
|
||||
if (torso == null || !"TORSO_0".equals(match.rootCategory())) {
|
||||
issues.add(new Issue("INVALID_TORSO_ROOT", "TORSO_0", null, "整机需要以躯干为根", null, null));
|
||||
return new Assembly("blocked", null, List.of(), List.copyOf(issues));
|
||||
}
|
||||
for (RobotMatchResponse.Connection edge : match.connections()) {
|
||||
|
||||
+2
-2
@@ -42,13 +42,13 @@ public final class DemandMatchService {
|
||||
long started = System.nanoTime();
|
||||
boolean torsoExcluded = false;
|
||||
for (JsonNode excluded : analysis.result().path("analysis").path("excludedCategories")) {
|
||||
torsoExcluded |= "torso_0".equals(excluded.path("category").asText());
|
||||
torsoExcluded |= "TORSO_0".equals(excluded.path("category").asText());
|
||||
}
|
||||
RobotMatchResponse response;
|
||||
if (torsoExcluded || analysis.result().path("request").path("requiredParts").isEmpty()) {
|
||||
// 结构化匹配会自动补入躯干;此处先尊重对话里的明确排除项。
|
||||
List<RobotMatchResponse.MissingPart> missing = torsoExcluded
|
||||
? List.of(new RobotMatchResponse.MissingPart("torso_0", "EXCLUDED_TORSO")) : List.of();
|
||||
? List.of(new RobotMatchResponse.MissingPart("TORSO_0", "EXCLUDED_TORSO")) : List.of();
|
||||
response = new RobotMatchResponse("NO_MATCH", null, List.of(), List.of(), List.of(),
|
||||
new RobotMatchResponse.Totals(0, null, BigDecimal.ZERO, false), List.of(), List.of(), missing, false);
|
||||
} else {
|
||||
|
||||
+4
-4
@@ -29,7 +29,7 @@ final class DemandMechanicalNormalizer {
|
||||
LinkedHashSet<String> categories = new LinkedHashSet<>();
|
||||
Set<String> excluded = new LinkedHashSet<>();
|
||||
for (JsonNode item : raw.path("excludedCategories")) excluded.add(item.path("category").asText());
|
||||
if (excluded.contains("torso_0")) warnings.add("已保留排除躯干的要求;现有装配规则必须以躯干为根,因此无法形成整机。");
|
||||
if (excluded.contains("TORSO_0")) warnings.add("已保留排除躯干的要求;现有装配规则必须以躯干为根,因此无法形成整机。");
|
||||
for (JsonNode type : raw.path("robotTypes")) {
|
||||
JsonNode template = template(type.path("type").asText());
|
||||
categories.addAll(texts(template.path("parts")));
|
||||
@@ -112,8 +112,8 @@ final class DemandMechanicalNormalizer {
|
||||
for (JsonNode item : unmodeled) requirements.add(item.path("text").asText());
|
||||
request.set("requirements", json.valueToTree(requirements));
|
||||
ArrayNode required = request.putArray("requiredParts");
|
||||
boolean defaultTorsoAdded = !categories.isEmpty() && !categories.contains("torso_0") && !excluded.contains("torso_0");
|
||||
if (!categories.isEmpty() && !excluded.contains("torso_0")) categories.add("torso_0");
|
||||
boolean defaultTorsoAdded = !categories.isEmpty() && !categories.contains("TORSO_0") && !excluded.contains("TORSO_0");
|
||||
if (!categories.isEmpty() && !excluded.contains("TORSO_0")) categories.add("TORSO_0");
|
||||
for (JsonNode category : catalog.path("categories")) if (categories.contains(category.asText()) && !excluded.contains(category.asText())) required.add(category);
|
||||
if (required.isEmpty()) warnings.add("当前需求没有可选部位,将返回无匹配结果。");
|
||||
request.set("robotRequirements", robot);
|
||||
@@ -122,7 +122,7 @@ final class DemandMechanicalNormalizer {
|
||||
analysis.set("unmodeled", unmodeled);
|
||||
analysis.putArray("questions");
|
||||
analysis.put("defaultTemplate", defaultTemplate);
|
||||
if (defaultTorsoAdded) warnings.add("整机拼装固定一个躯干,已补入torso_0作为基础组件。");
|
||||
if (defaultTorsoAdded) warnings.add("整机拼装固定一个躯干,已补入TORSO_0作为基础组件。");
|
||||
for (JsonNode type : raw.path("robotTypes")) if ("inferred".equals(type.path("source").asText())) {
|
||||
warnings.add("机器人类型含推断,仅用于兼容候选,不能视为用户确认或全部功能满足。"); break;
|
||||
}
|
||||
|
||||
+30
-3
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import com.linkerbot.cadworld.service.matching.ComponentRole;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
@@ -19,8 +20,9 @@ public final class DemandNormalizer {
|
||||
public DemandNormalizer(DemandRules rules, ObjectMapper json) { this.rules = rules; this.json = json; }
|
||||
|
||||
public DemandResult normalize(JsonNode input, List<DemandMessage> history) {
|
||||
rules.validate(input);
|
||||
ObjectNode raw = input.deepCopy();
|
||||
JsonNode canonical = canonicalCategories(input);
|
||||
rules.validate(canonical);
|
||||
ObjectNode raw = (ObjectNode) canonical;
|
||||
Map<String, DemandMessage> messages = new LinkedHashMap<>();
|
||||
Map<String, String> attachments = new LinkedHashMap<>();
|
||||
for (DemandMessage message : history) if ("user".equals(message.role())) {
|
||||
@@ -136,12 +138,37 @@ public final class DemandNormalizer {
|
||||
for (JsonNode item : raw.path("keywords")) keywordEvidence.addObject().put("term", item.path("term").asText()).set("evidenceIds", item.get("evidenceIds"));
|
||||
warnings.addAll(DemandMechanicalNormalizer.texts(analysis.path("warnings")));
|
||||
analysis.set("warnings", json.valueToTree(warnings));
|
||||
analysis.put("schemaVersion", "multimodal-v1.3-child-instances");
|
||||
analysis.put("schemaVersion", "multimodal-v1.4-component-types");
|
||||
analysis.putArray("questions");
|
||||
analysis.put("canSubmit", true).put("status", "ready");
|
||||
return result;
|
||||
}
|
||||
|
||||
/** 兼容历史模型编码,仅规范化类别字段,保留用户原文和证据。 */
|
||||
private JsonNode canonicalCategories(JsonNode input) {
|
||||
if (input == null) return null;
|
||||
JsonNode canonical = input.deepCopy();
|
||||
for (String field : List.of("partCategories", "excludedCategories")) {
|
||||
for (JsonNode item : canonical.path(field)) {
|
||||
if (item.isObject() && item.path("category").isTextual()) {
|
||||
((ObjectNode) item).put("category", canonicalCategory(item.path("category").asText()));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (JsonNode constraint : canonical.path("constraints")) {
|
||||
if (!constraint.path("categories").isArray()) continue;
|
||||
ArrayNode categories = (ArrayNode) constraint.path("categories");
|
||||
for (int index = 0; index < categories.size(); index++) {
|
||||
if (categories.get(index).isTextual()) categories.set(index, json.getNodeFactory().textNode(canonicalCategory(categories.get(index).asText())));
|
||||
}
|
||||
}
|
||||
return canonical;
|
||||
}
|
||||
|
||||
private String canonicalCategory(String category) {
|
||||
return ComponentRole.find(category).map(ComponentRole::code).orElse(category);
|
||||
}
|
||||
|
||||
private List<JsonNode> resolve(JsonNode item, Map<String, JsonNode> evidence) {
|
||||
List<JsonNode> sources = new ArrayList<>();
|
||||
Set<String> seen = new LinkedHashSet<>();
|
||||
|
||||
+9
-7
@@ -10,18 +10,19 @@ import com.linkerbot.cadworld.service.matching.MatchTextService;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
/** 只有能确定关联到受支持字段的需求才给出满足结论,物理能力不由文本命中证明。 */
|
||||
public final class DemandRequirementChecker {
|
||||
private static final Map<String, List<String>> ROLE_WORDS = Map.ofEntries(
|
||||
Map.entry("torso_0", List.of("torso_0", "躯干")), Map.entry("head_0", List.of("head_0", "头部", "头_0")),
|
||||
Map.entry("waist_0", List.of("waist_0", "腰")), Map.entry("arm_l", List.of("arm_l", "左臂")),
|
||||
Map.entry("arm_r", List.of("arm_r", "右臂")), Map.entry("hand_l", List.of("hand_l", "左手")),
|
||||
Map.entry("hand_r", List.of("hand_r", "右手")), Map.entry("pedal_l", List.of("pedal_l", "左足")),
|
||||
Map.entry("pedal_r", List.of("pedal_r", "右足")), Map.entry("foot_l", List.of("foot_l", "左脚")),
|
||||
Map.entry("foot_r", List.of("foot_r", "右脚")), Map.entry("tail_0", List.of("tail_0", "尾")));
|
||||
Map.entry("TORSO_0", List.of("TORSO_0", "躯干")), Map.entry("HEAD_0", List.of("HEAD_0", "头部", "头_0")),
|
||||
Map.entry("WAIST_0", List.of("WAIST_0", "腰")), Map.entry("ARM_L", List.of("ARM_L", "左臂")),
|
||||
Map.entry("ARM_R", List.of("ARM_R", "右臂")), Map.entry("HAND_L", List.of("HAND_L", "左手")),
|
||||
Map.entry("HAND_R", List.of("HAND_R", "右手")), Map.entry("LEG_L", List.of("LEG_L", "PEDAL_L", "左足", "左腿")),
|
||||
Map.entry("LEG_R", List.of("LEG_R", "PEDAL_R", "右足", "右腿")), Map.entry("FOOT_L", List.of("FOOT_L", "左脚")),
|
||||
Map.entry("FOOT_R", List.of("FOOT_R", "右脚")), Map.entry("TAIL_0", List.of("TAIL_0", "尾")));
|
||||
private final ObjectMapper json;
|
||||
private final MatchTextService text;
|
||||
public DemandRequirementChecker(ObjectMapper json, MatchTextService text) { this.json = json; this.text = text; }
|
||||
@@ -185,9 +186,10 @@ public final class DemandRequirementChecker {
|
||||
String value = subject.matches(".*(?:整机|整体|全机|机器人).*") && !"exclusion".equals(subject) ? subject : subject + " " + requirement;
|
||||
// 禁止项常以整机为对象,具体排除角色写在 requirement 中。
|
||||
if (requirement.matches(".*(?:不配备|不要|禁止|不包含|无尾).*")) value += " " + requirement;
|
||||
value = value.toUpperCase(Locale.ROOT);
|
||||
Set<String> roles = new LinkedHashSet<>();
|
||||
for (Map.Entry<String, List<String>> entry : ROLE_WORDS.entrySet()) for (String word : entry.getValue()) if (value.contains(word)) roles.add(entry.getKey());
|
||||
if (subject.contains("双臂") || subject.contains("两臂")) { roles.add("arm_l"); roles.add("arm_r"); }
|
||||
if (subject.contains("双臂") || subject.contains("两臂")) { roles.add("ARM_L"); roles.add("ARM_R"); }
|
||||
return roles.stream().sorted().toList();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ record AssemblyState(ComponentRole root, Map<String, MatchingCandidate> parts, L
|
||||
}
|
||||
|
||||
static AssemblyState root(MatchingCandidate candidate) {
|
||||
return new AssemblyState(ComponentRole.TORSO, Map.of("torso_0:1", candidate), List.of());
|
||||
return new AssemblyState(ComponentRole.TORSO, Map.of(ComponentRole.TORSO.code() + ":1", candidate), List.of());
|
||||
}
|
||||
|
||||
int count(ComponentRole role) {
|
||||
|
||||
+10
-10
@@ -5,29 +5,29 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
public enum ComponentRole {
|
||||
TORSO("torso_0", "躯干_0"), HEAD("head_0", "头_0"), WAIST("waist_0", "腰_0"),
|
||||
ARM_L("arm_l", "臂_l"), ARM_R("arm_r", "臂_r"), HAND_L("hand_l", "手_l"), HAND_R("hand_r", "手_r"),
|
||||
PEDAL_L("pedal_l", "足_l"), PEDAL_R("pedal_r", "足_r"),
|
||||
FOOT_L("foot_l", "脚_l"), FOOT_R("foot_r", "脚_r"), TAIL("tail_0", "尾_0");
|
||||
TORSO("TORSO_0", "躯干_0"), HEAD("HEAD_0", "头_0"), WAIST("WAIST_0", "腰_0"),
|
||||
ARM_L("ARM_L", "臂_l"), ARM_R("ARM_R", "臂_r"), HAND_L("HAND_L", "手_l"), HAND_R("HAND_R", "手_r"),
|
||||
LEG_L("LEG_L", "足_l", "pedal_l"), LEG_R("LEG_R", "足_r", "pedal_r"),
|
||||
FOOT_L("FOOT_L", "脚_l"), FOOT_R("FOOT_R", "脚_r"), TAIL("TAIL_0", "尾_0");
|
||||
|
||||
private final String code;
|
||||
private final String chinese;
|
||||
private final List<String> aliases;
|
||||
|
||||
ComponentRole(String code, String chinese) {
|
||||
ComponentRole(String code, String chinese, String... compatibleAliases) {
|
||||
this.code = code;
|
||||
this.chinese = chinese;
|
||||
this.aliases = Stream.concat(Stream.of(code.toLowerCase(Locale.ROOT), chinese), Arrays.stream(compatibleAliases)).toList();
|
||||
}
|
||||
|
||||
public String code() { return code; }
|
||||
int bit() { return 1 << ordinal(); }
|
||||
List<String> aliases() { return List.of(code, chinese); }
|
||||
List<String> aliases() { return aliases; }
|
||||
|
||||
public static Optional<ComponentRole> find(String value) {
|
||||
String normalized = value == null ? "" : value.trim().toLowerCase(Locale.ROOT);
|
||||
return Arrays.stream(values()).filter((ComponentRole role) ->
|
||||
role.code.equals(normalized) || role.chinese.equals(normalized)).findFirst();
|
||||
return Arrays.stream(values()).filter((ComponentRole role) -> role.aliases.contains(normalized)).findFirst();
|
||||
}
|
||||
|
||||
static ComponentRole require(String value) {
|
||||
|
||||
+4
-1
@@ -9,8 +9,10 @@ import com.linkerbot.cadworld.service.impl.ObjectStorageUrlResolver;
|
||||
import java.util.Collection;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Stream;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -29,7 +31,8 @@ public class PublicComponentQueryService {
|
||||
}
|
||||
|
||||
void scan(List<ComponentRole> roles, Consumer<Component> consumer) {
|
||||
List<String> aliases = roles.stream().flatMap((ComponentRole role) -> role.aliases().stream()).toList();
|
||||
List<String> aliases = roles.stream().flatMap((ComponentRole role) -> role.aliases().stream())
|
||||
.flatMap((String alias) -> Stream.of(alias, alias.toUpperCase(Locale.ROOT))).distinct().toList();
|
||||
long cursor = 0;
|
||||
while (true) {
|
||||
List<Component> page = mapper.selectList(candidateFields().in(Component::getCategory, aliases)
|
||||
|
||||
@@ -247,18 +247,18 @@
|
||||
"category": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"torso_0",
|
||||
"head_0",
|
||||
"waist_0",
|
||||
"arm_l",
|
||||
"arm_r",
|
||||
"hand_l",
|
||||
"hand_r",
|
||||
"pedal_l",
|
||||
"pedal_r",
|
||||
"foot_l",
|
||||
"foot_r",
|
||||
"tail_0"
|
||||
"TORSO_0",
|
||||
"HEAD_0",
|
||||
"WAIST_0",
|
||||
"ARM_L",
|
||||
"ARM_R",
|
||||
"HAND_L",
|
||||
"HAND_R",
|
||||
"LEG_L",
|
||||
"LEG_R",
|
||||
"FOOT_L",
|
||||
"FOOT_R",
|
||||
"TAIL_0"
|
||||
]
|
||||
},
|
||||
"source": {
|
||||
@@ -295,18 +295,18 @@
|
||||
"category": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"torso_0",
|
||||
"head_0",
|
||||
"waist_0",
|
||||
"arm_l",
|
||||
"arm_r",
|
||||
"hand_l",
|
||||
"hand_r",
|
||||
"pedal_l",
|
||||
"pedal_r",
|
||||
"foot_l",
|
||||
"foot_r",
|
||||
"tail_0"
|
||||
"TORSO_0",
|
||||
"HEAD_0",
|
||||
"WAIST_0",
|
||||
"ARM_L",
|
||||
"ARM_R",
|
||||
"HAND_L",
|
||||
"HAND_R",
|
||||
"LEG_L",
|
||||
"LEG_R",
|
||||
"FOOT_L",
|
||||
"FOOT_R",
|
||||
"TAIL_0"
|
||||
]
|
||||
},
|
||||
"evidenceIds": {
|
||||
@@ -341,18 +341,18 @@
|
||||
"items": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"torso_0",
|
||||
"head_0",
|
||||
"waist_0",
|
||||
"arm_l",
|
||||
"arm_r",
|
||||
"hand_l",
|
||||
"hand_r",
|
||||
"pedal_l",
|
||||
"pedal_r",
|
||||
"foot_l",
|
||||
"foot_r",
|
||||
"tail_0"
|
||||
"TORSO_0",
|
||||
"HEAD_0",
|
||||
"WAIST_0",
|
||||
"ARM_L",
|
||||
"ARM_R",
|
||||
"HAND_L",
|
||||
"HAND_R",
|
||||
"LEG_L",
|
||||
"LEG_R",
|
||||
"FOOT_L",
|
||||
"FOOT_R",
|
||||
"TAIL_0"
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,36 +1,36 @@
|
||||
{
|
||||
"version": "2026-10-14-auto-assembly",
|
||||
"version": "2026-10-16-component-types",
|
||||
"defaultTemplate": "biped",
|
||||
"categories": [
|
||||
"torso_0",
|
||||
"head_0",
|
||||
"waist_0",
|
||||
"arm_l",
|
||||
"arm_r",
|
||||
"hand_l",
|
||||
"hand_r",
|
||||
"pedal_l",
|
||||
"pedal_r",
|
||||
"foot_l",
|
||||
"foot_r",
|
||||
"tail_0"
|
||||
"TORSO_0",
|
||||
"HEAD_0",
|
||||
"WAIST_0",
|
||||
"ARM_L",
|
||||
"ARM_R",
|
||||
"HAND_L",
|
||||
"HAND_R",
|
||||
"LEG_L",
|
||||
"LEG_R",
|
||||
"FOOT_L",
|
||||
"FOOT_R",
|
||||
"TAIL_0"
|
||||
],
|
||||
"templates": [
|
||||
{
|
||||
"id": "biped",
|
||||
"label": "双足机器人候选",
|
||||
"parts": [
|
||||
"torso_0",
|
||||
"head_0",
|
||||
"waist_0",
|
||||
"arm_l",
|
||||
"arm_r",
|
||||
"hand_l",
|
||||
"hand_r",
|
||||
"pedal_l",
|
||||
"pedal_r",
|
||||
"foot_l",
|
||||
"foot_r"
|
||||
"TORSO_0",
|
||||
"HEAD_0",
|
||||
"WAIST_0",
|
||||
"ARM_L",
|
||||
"ARM_R",
|
||||
"HAND_L",
|
||||
"HAND_R",
|
||||
"LEG_L",
|
||||
"LEG_R",
|
||||
"FOOT_L",
|
||||
"FOOT_R"
|
||||
],
|
||||
"keyword": "双足"
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
三、类型与部位
|
||||
11. 配置目录:{{CATALOG_JSON}}。robotTypes 只使用目录中的模板 id;程序展开 requiredParts,你不输出该字段。能辨认形态时选对应模板,图片推断标 inferred。未指定形态时 robotTypes=[],后端使用默认模板并说明。目录不代表库存齐全或能力达标。
|
||||
12. 未配置的四足、轮式、履带、鸟形等保留为 unmodeled,不谎称双足能够满足;后端可返回默认参考方案并保留差异。“仿生鸟类”保留机器人、仿生、鸟类等关键词,可将双足作为 inferred 候选;飞行能力保留为未验证,企鹅、鸵鸟或明确不飞行时不推断飞行。
|
||||
13. 类别为 torso_0 躯干、head_0 头、waist_0 腰、arm_l/r 臂、hand_l/r 手、pedal_l/r 足、foot_l/r 脚、tail_0 尾。0 不分左右,l/r 是机械左右,足和脚不同。双臂明确展开两侧;单侧部件未说明左右时按右侧生成 inferred 参考部位,并在 reason 中说明默认选择,不伪装成用户明确要求。
|
||||
13. 类别仅限以下12个大写编码:TORSO_0 躯干、HEAD_0 头、WAIST_0 腰、ARM_L 左臂、ARM_R 右臂、HAND_L 左手、HAND_R 右手、LEG_L 左足、LEG_R 右足、FOOT_L 左脚、FOOT_R 右脚、TAIL_0 尾。0 不分左右,L/R 是机械左右,足和脚不同;腿部对应 LEG_L/LEG_R,不输出 pedal 类别。双臂明确展开两侧;单侧部件未说明左右时按右侧生成 inferred 参考部位,并在 reason 中说明默认选择,不伪装成用户明确要求。
|
||||
14. 明确排除的部件放 excludedCategories,不作为正向包含。仅凭草图没画出某部件不能当作排除。翅膀、轮子、旋翼、电池、传感器、爪等目录外部件放 unmodeled,不造类别或把手臂当翅膀。现有部位支持同款组件的多个独立实例;明确数量写入quantity维度intentItems,并以part范围、field=quantity、operator=eq写入constraints,value保留原始数量,支持1至24。跨多个部位的合计数量仅保留intentItems,不平均分配。数量缺失时不要补1;后端按需求类型和实际可用接口填充。整机固定一个躯干。不要新增目录外类别或四足、六足模板。
|
||||
15. 解析器不生成安装接口、坐标、旋转、父子关系或配对方案。真实连接来自后端组件数据:interfaceType优先决定目标部位,双方frames.child严格一致才能连接;同child的多个接口独立处理,后端只返回实例连接关系,摆放由前端处理。不要从草图像素生成3D位置。
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
20. 无论缺参数、单位不明、左右不明、数量超限、图文冲突、图片用途不明还是库存未知,questions 都输出 []。summary 简短描述当前方案方向,unmodeled 说明未覆盖信息;不输出请确认、请补充、是否、以哪个为准等追问。不能自行宣称所有性能满足或装配成功,后端会校验。
|
||||
|
||||
例子:
|
||||
“我要双足跑步机器人,整体20自由度,质量不超过10kg,躯干用铝合金,右臂扭矩至少20N·m”:biped explicit;整机 DOF eq20、质量 lte10kg、跑步需求;torso_0 材料铝合金、arm_r 扭矩 gte20N·m,questions=[]。跑步的真实能力仍需后端证据验证。
|
||||
“我要双足跑步机器人,整体20自由度,质量不超过10kg,躯干用铝合金,右臂扭矩至少20N·m”:biped explicit;整机 DOF eq20、质量 lte10kg、跑步需求;TORSO_0 材料铝合金、ARM_R 扭矩 gte20N·m,questions=[]。跑步的真实能力仍需后端证据验证。
|
||||
“给我拼一个机器人”:keywords 保留机器人,robotTypes/partCategories/constraints 为空,交给后端默认模板,questions=[]。
|
||||
草图双腿且 OCR“20”不清:可用 biped inferred;不清的 20 留作参考,不写硬 DOF,questions=[]。
|
||||
文字 8kg 与图片 10kg 且无覆盖说明:保留两条约束和冲突,不选择一侧,questions=[]。明确“改为不超过8kg”时只保留当前 8kg 条件。
|
||||
|
||||
+14
-14
@@ -18,10 +18,10 @@ class DemandAssemblyValidatorTest {
|
||||
RobotMatchResponse match = match(info("BASE"), info("ARM_ROOT"));
|
||||
DemandAssemblyValidator.Assembly result = validator.validate("DM-test", match);
|
||||
assertThat(result.status()).isEqualTo("ready");
|
||||
assertThat(result.rootInstanceId()).isEqualTo("DM-test:torso_0:1");
|
||||
assertThat(result.rootInstanceId()).isEqualTo("DM-test:TORSO_0:1");
|
||||
assertThat(result.connections()).hasSize(1);
|
||||
assertThat(result.connections().get(0).parentInstanceId()).isEqualTo("DM-test:torso_0:1");
|
||||
assertThat(result.connections().get(0).childInstanceId()).isEqualTo("DM-test:arm_r:1");
|
||||
assertThat(result.connections().get(0).parentInstanceId()).isEqualTo("DM-test:TORSO_0:1");
|
||||
assertThat(result.connections().get(0).childInstanceId()).isEqualTo("DM-test:ARM_R:1");
|
||||
assertThat(result.connections().get(0).interfaceChild()).isEqualTo("LINK_arm_r");
|
||||
JsonNode body = json.valueToTree(result);
|
||||
assertThat(body.has("matrixLayout")).isFalse();
|
||||
@@ -42,21 +42,21 @@ class DemandAssemblyValidatorTest {
|
||||
|
||||
@Test void repeatedComponentCodesRemainIndependentInstances() {
|
||||
RobotMatchResponse base = match(info("BASE"), info("ARM_ROOT"));
|
||||
PublicComponentResponse second = base.parts().get(1).withInstanceId("arm_r:2");
|
||||
RobotMatchResponse.Connection edge = new RobotMatchResponse.Connection("torso_0", "PARENT", "BASE", "J2", "arm_r", "CHILD", "ARM_ROOT",
|
||||
"torso_0:1", "arm_r:2", "LINK_arm_r", 1, 0);
|
||||
RobotMatchResponse repeated = new RobotMatchResponse("MATCHED", "torso_0", List.of(base.parts().get(0), base.parts().get(1), second),
|
||||
PublicComponentResponse second = base.parts().get(1).withInstanceId("ARM_R:2");
|
||||
RobotMatchResponse.Connection edge = new RobotMatchResponse.Connection("TORSO_0", "PARENT", "BASE", "J2", "ARM_R", "CHILD", "ARM_ROOT",
|
||||
"TORSO_0:1", "ARM_R:2", "LINK_arm_r", 1, 0);
|
||||
RobotMatchResponse repeated = new RobotMatchResponse("MATCHED", "TORSO_0", List.of(base.parts().get(0), base.parts().get(1), second),
|
||||
List.of(base.connections().get(0), edge), List.of(), base.totals(), List.of(), List.of(), List.of(), false);
|
||||
DemandAssemblyValidator.Assembly result = validator.validate("DM-test", repeated);
|
||||
assertThat(result.status()).isEqualTo("ready");
|
||||
assertThat(result.connections()).extracting(DemandAssemblyValidator.Connection::childInstanceId)
|
||||
.containsExactly("DM-test:arm_r:1", "DM-test:arm_r:2");
|
||||
.containsExactly("DM-test:ARM_R:1", "DM-test:ARM_R:2");
|
||||
}
|
||||
|
||||
@Test void missingRequestedPartsAndMetadataWarningsDoNotBlockExistingCombination() {
|
||||
RobotMatchResponse base = match(info("BASE"), info("ARM_ROOT"));
|
||||
RobotMatchResponse partial = new RobotMatchResponse("PARTIAL", "torso_0", base.parts(), base.connections(), List.of(), base.totals(),
|
||||
List.of(), List.of(), List.of(new RobotMatchResponse.MissingPart("head_0", "NO_COMPONENT")), false);
|
||||
RobotMatchResponse partial = new RobotMatchResponse("PARTIAL", "TORSO_0", base.parts(), base.connections(), List.of(), base.totals(),
|
||||
List.of(), List.of(), List.of(new RobotMatchResponse.MissingPart("HEAD_0", "NO_COMPONENT")), false);
|
||||
assertThat(validator.validate("DM-test", partial).status()).isEqualTo("ready");
|
||||
assertThat(validator.validate("DM-test", partial).connections()).hasSize(1);
|
||||
}
|
||||
@@ -71,7 +71,7 @@ class DemandAssemblyValidatorTest {
|
||||
|
||||
private ObjectNode info(String root) {
|
||||
ObjectNode info = json.createObjectNode().put("rootLink", root);
|
||||
ObjectNode frame = info.putArray("frames").addObject().put("name", "J").put("parent", root).put("child", "LINK_arm_r").put("interfaceType", "arm_r");
|
||||
ObjectNode frame = info.putArray("frames").addObject().put("name", "J").put("parent", root).put("child", "LINK_arm_r").put("interfaceType", "ARM_R");
|
||||
frame.putArray("xyz").add(0).add(0).add(0); frame.putArray("rpy").add(0).add(0).add(0);
|
||||
return info;
|
||||
}
|
||||
@@ -79,9 +79,9 @@ class DemandAssemblyValidatorTest {
|
||||
return new PublicComponentResponse(code, code, role, "", "", BigDecimal.ONE, 0, null, "", "", "", BigDecimal.ZERO, json.createArrayNode(), info, 1L, "https://model/a.step", "https://model/a.urdf").withInstanceId(role + ":1");
|
||||
}
|
||||
private RobotMatchResponse match(ObjectNode parent, ObjectNode child) {
|
||||
RobotMatchResponse.Connection edge = new RobotMatchResponse.Connection("torso_0", "PARENT", "BASE", "J", "arm_r", "CHILD", "ARM_ROOT",
|
||||
"torso_0:1", "arm_r:1", "LINK_arm_r", 0, 0);
|
||||
return new RobotMatchResponse("MATCHED", "torso_0", List.of(part("PARENT", "torso_0", parent), part("CHILD", "arm_r", child)), List.of(edge), List.of(),
|
||||
RobotMatchResponse.Connection edge = new RobotMatchResponse.Connection("TORSO_0", "PARENT", "BASE", "J", "ARM_R", "CHILD", "ARM_ROOT",
|
||||
"TORSO_0:1", "ARM_R:1", "LINK_arm_r", 0, 0);
|
||||
return new RobotMatchResponse("MATCHED", "TORSO_0", List.of(part("PARENT", "TORSO_0", parent), part("CHILD", "ARM_R", child)), List.of(edge), List.of(),
|
||||
new RobotMatchResponse.Totals(0, BigDecimal.valueOf(2), BigDecimal.valueOf(2), true), List.of(), List.of(), List.of(), false);
|
||||
}
|
||||
}
|
||||
|
||||
+34
-14
@@ -35,8 +35,28 @@ class DemandNormalizerTest {
|
||||
assertThat(actual.analysis().path("status").asText()).isEqualTo("ready");
|
||||
assertThat(actual.analysis().path("canSubmit").asBoolean()).isTrue();
|
||||
assertThat(actual.analysis().path("questions")).isEmpty();
|
||||
assertThat(actual.analysis().path("schemaVersion").asText()).isEqualTo("multimodal-v1.3-child-instances");
|
||||
assertThat(actual.analysis().path("catalogVersion").asText()).isEqualTo("2026-10-14-auto-assembly");
|
||||
assertThat(actual.analysis().path("schemaVersion").asText()).isEqualTo("multimodal-v1.4-component-types");
|
||||
assertThat(actual.analysis().path("catalogVersion").asText()).isEqualTo("2026-10-16-component-types");
|
||||
}
|
||||
|
||||
@Test void normalizesLegacyCategoriesInPartsConstraintsAndExclusionsWithoutChangingEvidence() {
|
||||
String input = "左足扭矩至少20N·m,不要右足";
|
||||
ObjectNode raw = minimal(input);
|
||||
raw.putArray("robotTypes");
|
||||
raw.withArray("partCategories").addObject().put("category", "pedal_l").put("source", "explicit")
|
||||
.put("reason", "用户需要左足").putArray("evidenceIds").add("e1");
|
||||
raw.withArray("excludedCategories").addObject().put("category", "leg_r").putArray("evidenceIds").add("e1");
|
||||
constraint(raw, "part", "torqueNm", "20N·m", "gte", "PEDAL_L", "e1");
|
||||
DemandResult result = normalizer.normalize(raw, text(input));
|
||||
assertThat(result.request().path("requiredParts")).isEqualTo(json.valueToTree(List.of("TORSO_0", "LEG_L")));
|
||||
assertThat(result.request().path("partRequirements").get(0).path("category").asText()).isEqualTo("LEG_L");
|
||||
assertThat(result.analysis().path("partCategories").get(0).path("category").asText()).isEqualTo("LEG_L");
|
||||
assertThat(result.analysis().path("excludedCategories").get(0).path("category").asText()).isEqualTo("LEG_R");
|
||||
assertThat(result.analysis().path("constraints").get(0).path("categories")).isEqualTo(json.valueToTree(List.of("LEG_L")));
|
||||
assertThat(result.analysis().path("observations").get(0).path("content").asText()).isEqualTo(input);
|
||||
assertThat(raw.path("partCategories").get(0).path("category").asText()).isEqualTo("pedal_l");
|
||||
((ObjectNode) raw.path("partCategories").get(0)).put("category", "WHEEL_0");
|
||||
assertThatThrownBy(() -> normalizer.normalize(raw, text(input))).isInstanceOf(BizException.class);
|
||||
}
|
||||
|
||||
@Test void rejectsUnknownFieldsFakeQuotesAndMissingImageEvidence() throws Exception {
|
||||
@@ -55,7 +75,7 @@ class DemandNormalizerTest {
|
||||
|
||||
@Test void recoversUnitsOnlyFromMatchingNumbersAndAcceptsLaterUnitOnlyClarification() {
|
||||
ObjectNode raw = minimal("双足机器人右臂扭矩至少30,单位未确定");
|
||||
constraint(raw, "part", "torqueNm", "30", "gte", "arm_r", "e1");
|
||||
constraint(raw, "part", "torqueNm", "30", "gte", "ARM_R", "e1");
|
||||
DemandResult unclear = normalizer.normalize(raw, text("双足机器人右臂扭矩至少30,单位未确定"));
|
||||
assertThat(unclear.analysis().path("canSubmit").asBoolean()).isTrue();
|
||||
assertThat(unclear.analysis().path("questions")).isEmpty();
|
||||
@@ -103,20 +123,20 @@ class DemandNormalizerTest {
|
||||
ObjectNode raw = minimal(text);
|
||||
raw.putArray("robotTypes");
|
||||
((ObjectNode) raw.path("keywords").get(0)).put("term", "右臂");
|
||||
raw.withArray("partCategories").addObject().put("category", "arm_r").put("source", "explicit").put("reason", "用户需要右臂").putArray("evidenceIds").add("e1");
|
||||
raw.withArray("partCategories").addObject().put("category", "ARM_R").put("source", "explicit").put("reason", "用户需要右臂").putArray("evidenceIds").add("e1");
|
||||
DemandResult result = normalizer.normalize(raw, text(text));
|
||||
assertThat(result.request().path("requiredParts")).hasSize(2);
|
||||
assertThat(result.request().path("requiredParts").get(0).asText()).isEqualTo("torso_0");
|
||||
assertThat(result.request().path("requiredParts").get(0).asText()).isEqualTo("TORSO_0");
|
||||
assertThat(result.analysis().path("partCategories")).hasSize(1);
|
||||
assertThat(result.analysis().path("warnings")).isNotEmpty();
|
||||
String exclusionText = text + ",不要躯干";
|
||||
((ObjectNode) raw.path("observations").get(0)).put("content", exclusionText);
|
||||
raw.withArray("excludedCategories").addObject().put("category", "torso_0").putArray("evidenceIds").add("e1");
|
||||
raw.withArray("excludedCategories").addObject().put("category", "TORSO_0").putArray("evidenceIds").add("e1");
|
||||
DemandResult excluded = normalizer.normalize(raw, text(exclusionText));
|
||||
assertThat(excluded.analysis().path("canSubmit").asBoolean()).isTrue();
|
||||
assertThat(excluded.analysis().path("questions")).isEmpty();
|
||||
assertThat(excluded.analysis().path("warnings").toString()).contains("必须以躯干为根");
|
||||
assertThat(excluded.request().path("requiredParts").toString()).doesNotContain("torso_0");
|
||||
assertThat(excluded.request().path("requiredParts").toString()).doesNotContain("TORSO_0");
|
||||
}
|
||||
|
||||
@Test void unspecifiedFormUsesDefaultTemplateWithoutInventingParameters() {
|
||||
@@ -141,11 +161,11 @@ class DemandNormalizerTest {
|
||||
ObjectNode raw = minimal(text);
|
||||
raw.putArray("robotTypes");
|
||||
((ObjectNode) raw.path("keywords").get(0)).put("term", "手臂");
|
||||
raw.withArray("partCategories").addObject().put("category", "arm_r").put("source", "inferred")
|
||||
raw.withArray("partCategories").addObject().put("category", "ARM_R").put("source", "inferred")
|
||||
.put("reason", "未指定左右,默认右臂候选").putArray("evidenceIds").add("e1");
|
||||
DemandResult result = normalizer.normalize(raw, text(text));
|
||||
assertThat(result.request().path("requiredParts").get(0).asText()).isEqualTo("torso_0");
|
||||
assertThat(result.request().path("requiredParts").get(1).asText()).isEqualTo("arm_r");
|
||||
assertThat(result.request().path("requiredParts").get(0).asText()).isEqualTo("TORSO_0");
|
||||
assertThat(result.request().path("requiredParts").get(1).asText()).isEqualTo("ARM_R");
|
||||
assertThat(result.request().path("requiredParts")).hasSize(2);
|
||||
assertThat(result.analysis().path("partCategories").get(0).path("source").asText()).isEqualTo("inferred");
|
||||
assertThat(result.analysis().path("questions")).isEmpty();
|
||||
@@ -177,7 +197,7 @@ class DemandNormalizerTest {
|
||||
String input = count + "个右臂";
|
||||
ObjectNode raw = minimal(input);
|
||||
raw.putArray("robotTypes");
|
||||
raw.withArray("partCategories").addObject().put("category", "arm_r").put("source", "explicit").put("reason", "用户明确部位").putArray("evidenceIds").add("e1");
|
||||
raw.withArray("partCategories").addObject().put("category", "ARM_R").put("source", "explicit").put("reason", "用户明确部位").putArray("evidenceIds").add("e1");
|
||||
raw.withArray("intentItems").addObject().put("id", "q1").put("dimension", "quantity").put("subject", "右臂")
|
||||
.put("requirement", input).put("priority", "must").put("source", "explicit").putArray("evidenceIds").add("e1");
|
||||
DemandResult result = normalizer.normalize(raw, text(input));
|
||||
@@ -193,7 +213,7 @@ class DemandNormalizerTest {
|
||||
String input = count + "个右臂";
|
||||
ObjectNode raw = minimal(input);
|
||||
raw.putArray("robotTypes");
|
||||
constraint(raw, "part", "quantity", count, "eq", "arm_r", "e1");
|
||||
constraint(raw, "part", "quantity", count, "eq", "ARM_R", "e1");
|
||||
raw.withArray("intentItems").addObject().put("id", "q1").put("dimension", "quantity").put("subject", "右臂")
|
||||
.put("requirement", input).put("priority", "must").put("source", "explicit").putArray("evidenceIds").add("e1");
|
||||
DemandResult result = normalizer.normalize(raw, text(input));
|
||||
@@ -207,13 +227,13 @@ class DemandNormalizerTest {
|
||||
assertThat(DemandNumberParser.inEvidence("quantity", "1", "负一个右臂", List.of())).isFalse();
|
||||
ObjectNode raw = minimal("右臂扭矩20N·m");
|
||||
raw.putArray("robotTypes");
|
||||
constraint(raw, "part", "quantity", "20", "eq", "arm_r", "e1");
|
||||
constraint(raw, "part", "quantity", "20", "eq", "ARM_R", "e1");
|
||||
DemandResult result = normalizer.normalize(raw, text("右臂扭矩20N·m"));
|
||||
assertThat(result.request().path("partRequirements").findValues("quantity")).isEmpty();
|
||||
assertThat(result.analysis().path("unmodeled")).isNotEmpty();
|
||||
raw = minimal("右臂数量为4");
|
||||
raw.putArray("robotTypes");
|
||||
constraint(raw, "part", "quantity", "4", "eq", "arm_r", "e1");
|
||||
constraint(raw, "part", "quantity", "4", "eq", "ARM_R", "e1");
|
||||
result = normalizer.normalize(raw, text("右臂数量为4"));
|
||||
assertThat(result.request().path("partRequirements").get(0).path("quantity").asInt()).isEqualTo(4);
|
||||
}
|
||||
|
||||
@@ -447,17 +447,17 @@
|
||||
"双足"
|
||||
],
|
||||
"requiredParts": [
|
||||
"torso_0",
|
||||
"head_0",
|
||||
"waist_0",
|
||||
"arm_l",
|
||||
"arm_r",
|
||||
"hand_l",
|
||||
"hand_r",
|
||||
"pedal_l",
|
||||
"pedal_r",
|
||||
"foot_l",
|
||||
"foot_r"
|
||||
"TORSO_0",
|
||||
"HEAD_0",
|
||||
"WAIST_0",
|
||||
"ARM_L",
|
||||
"ARM_R",
|
||||
"HAND_L",
|
||||
"HAND_R",
|
||||
"LEG_L",
|
||||
"LEG_R",
|
||||
"FOOT_L",
|
||||
"FOOT_R"
|
||||
],
|
||||
"robotRequirements": {
|
||||
"degreesOfFreedom": 20,
|
||||
@@ -465,11 +465,11 @@
|
||||
},
|
||||
"partRequirements": [
|
||||
{
|
||||
"category": "torso_0",
|
||||
"category": "TORSO_0",
|
||||
"material": "铝合金"
|
||||
},
|
||||
{
|
||||
"category": "arm_r",
|
||||
"category": "ARM_R",
|
||||
"torqueNm": 20,
|
||||
"operators": {
|
||||
"torqueNm": "gte"
|
||||
@@ -547,67 +547,67 @@
|
||||
],
|
||||
"partCategories": [
|
||||
{
|
||||
"category": "torso_0",
|
||||
"category": "TORSO_0",
|
||||
"source": "explicit",
|
||||
"reason": "双足机器人标配躯干部件,且需求明确标注躯干材质要求",
|
||||
"evidence": "我要图中的双足机器人,整机质量为8kg;双足跑步机器人;躯干材质:铝合金"
|
||||
},
|
||||
{
|
||||
"category": "head_0",
|
||||
"category": "HEAD_0",
|
||||
"source": "explicit",
|
||||
"reason": "双足机器人标配头部部件",
|
||||
"evidence": "我要图中的双足机器人,整机质量为8kg;双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "waist_0",
|
||||
"category": "WAIST_0",
|
||||
"source": "explicit",
|
||||
"reason": "双足机器人标配腰部部件",
|
||||
"evidence": "我要图中的双足机器人,整机质量为8kg;双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "arm_l",
|
||||
"category": "ARM_L",
|
||||
"source": "explicit",
|
||||
"reason": "双足机器人标配左臂部件",
|
||||
"evidence": "我要图中的双足机器人,整机质量为8kg;双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "arm_r",
|
||||
"category": "ARM_R",
|
||||
"source": "explicit",
|
||||
"reason": "双足机器人标配右臂部件,且需求明确标注右臂扭矩要求",
|
||||
"evidence": "我要图中的双足机器人,整机质量为8kg;双足跑步机器人;右臂扭矩:至少20N·m"
|
||||
},
|
||||
{
|
||||
"category": "hand_l",
|
||||
"category": "HAND_L",
|
||||
"source": "explicit",
|
||||
"reason": "双足机器人标配左手部件",
|
||||
"evidence": "我要图中的双足机器人,整机质量为8kg;双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "hand_r",
|
||||
"category": "HAND_R",
|
||||
"source": "explicit",
|
||||
"reason": "双足机器人标配右手部件",
|
||||
"evidence": "我要图中的双足机器人,整机质量为8kg;双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "pedal_l",
|
||||
"category": "LEG_L",
|
||||
"source": "explicit",
|
||||
"reason": "双足机器人标配左足部件",
|
||||
"evidence": "我要图中的双足机器人,整机质量为8kg;双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "pedal_r",
|
||||
"category": "LEG_R",
|
||||
"source": "explicit",
|
||||
"reason": "双足机器人标配右足部件",
|
||||
"evidence": "我要图中的双足机器人,整机质量为8kg;双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "foot_l",
|
||||
"category": "FOOT_L",
|
||||
"source": "explicit",
|
||||
"reason": "双足机器人标配左脚部件",
|
||||
"evidence": "我要图中的双足机器人,整机质量为8kg;双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "foot_r",
|
||||
"category": "FOOT_R",
|
||||
"source": "explicit",
|
||||
"reason": "双足机器人标配右脚部件",
|
||||
"evidence": "我要图中的双足机器人,整机质量为8kg;双足跑步机器人"
|
||||
@@ -636,7 +636,7 @@
|
||||
{
|
||||
"scope": "part",
|
||||
"categories": [
|
||||
"torso_0"
|
||||
"TORSO_0"
|
||||
],
|
||||
"field": "material",
|
||||
"value": "铝合金",
|
||||
@@ -647,7 +647,7 @@
|
||||
{
|
||||
"scope": "part",
|
||||
"categories": [
|
||||
"arm_r"
|
||||
"ARM_R"
|
||||
],
|
||||
"field": "torqueNm",
|
||||
"value": "20N·m",
|
||||
@@ -663,7 +663,7 @@
|
||||
"warnings": [
|
||||
"部分二维来源框格式不可靠,已省略定位框,请查看整张原图核对。"
|
||||
],
|
||||
"catalogVersion": "2026-10-13-draft",
|
||||
"catalogVersion": "2026-10-16-component-types",
|
||||
"status": "needs_clarification",
|
||||
"canSubmit": false,
|
||||
"observations": [
|
||||
@@ -896,7 +896,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"schemaVersion": "multimodal-v1.1"
|
||||
"schemaVersion": "multimodal-v1.4-component-types"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -396,17 +396,17 @@
|
||||
"双足"
|
||||
],
|
||||
"requiredParts": [
|
||||
"torso_0",
|
||||
"head_0",
|
||||
"waist_0",
|
||||
"arm_l",
|
||||
"arm_r",
|
||||
"hand_l",
|
||||
"hand_r",
|
||||
"pedal_l",
|
||||
"pedal_r",
|
||||
"foot_l",
|
||||
"foot_r"
|
||||
"TORSO_0",
|
||||
"HEAD_0",
|
||||
"WAIST_0",
|
||||
"ARM_L",
|
||||
"ARM_R",
|
||||
"HAND_L",
|
||||
"HAND_R",
|
||||
"LEG_L",
|
||||
"LEG_R",
|
||||
"FOOT_L",
|
||||
"FOOT_R"
|
||||
],
|
||||
"robotRequirements": {
|
||||
"degreesOfFreedom": 20,
|
||||
@@ -415,11 +415,11 @@
|
||||
},
|
||||
"partRequirements": [
|
||||
{
|
||||
"category": "torso_0",
|
||||
"category": "TORSO_0",
|
||||
"material": "铝合金"
|
||||
},
|
||||
{
|
||||
"category": "arm_r",
|
||||
"category": "ARM_R",
|
||||
"torqueNm": 20,
|
||||
"operators": {
|
||||
"torqueNm": "gte"
|
||||
@@ -490,67 +490,67 @@
|
||||
],
|
||||
"partCategories": [
|
||||
{
|
||||
"category": "torso_0",
|
||||
"category": "TORSO_0",
|
||||
"source": "explicit",
|
||||
"reason": "用户明确指定躯干材质要求,对应躯干部件",
|
||||
"evidence": "躯干材质:铝合金"
|
||||
},
|
||||
{
|
||||
"category": "arm_r",
|
||||
"category": "ARM_R",
|
||||
"source": "explicit",
|
||||
"reason": "用户明确指定右臂扭矩要求,对应右侧臂部件",
|
||||
"evidence": "右臂扭矩:至少20N·m"
|
||||
},
|
||||
{
|
||||
"category": "arm_l",
|
||||
"category": "ARM_L",
|
||||
"source": "inferred",
|
||||
"reason": "双足机器人标准双臂对称配置,用户未要求仅单侧臂",
|
||||
"evidence": "双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "head_0",
|
||||
"category": "HEAD_0",
|
||||
"source": "inferred",
|
||||
"reason": "双足机器人标准头部配置",
|
||||
"evidence": "双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "waist_0",
|
||||
"category": "WAIST_0",
|
||||
"source": "inferred",
|
||||
"reason": "双足机器人标准腰部配置",
|
||||
"evidence": "双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "hand_l",
|
||||
"category": "HAND_L",
|
||||
"source": "inferred",
|
||||
"reason": "左侧臂对应手部标准配置",
|
||||
"evidence": "双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "hand_r",
|
||||
"category": "HAND_R",
|
||||
"source": "inferred",
|
||||
"reason": "右侧臂对应手部标准配置",
|
||||
"evidence": "双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "pedal_l",
|
||||
"category": "LEG_L",
|
||||
"source": "inferred",
|
||||
"reason": "双足结构对应左侧腿部配置",
|
||||
"evidence": "双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "pedal_r",
|
||||
"category": "LEG_R",
|
||||
"source": "inferred",
|
||||
"reason": "双足结构对应右侧腿部配置",
|
||||
"evidence": "双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "foot_l",
|
||||
"category": "FOOT_L",
|
||||
"source": "inferred",
|
||||
"reason": "左侧腿部对应脚部配置",
|
||||
"evidence": "双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "foot_r",
|
||||
"category": "FOOT_R",
|
||||
"source": "inferred",
|
||||
"reason": "右侧腿部对应脚部配置",
|
||||
"evidence": "双足跑步机器人"
|
||||
@@ -588,7 +588,7 @@
|
||||
{
|
||||
"scope": "part",
|
||||
"categories": [
|
||||
"torso_0"
|
||||
"TORSO_0"
|
||||
],
|
||||
"field": "material",
|
||||
"value": "铝合金",
|
||||
@@ -599,7 +599,7 @@
|
||||
{
|
||||
"scope": "part",
|
||||
"categories": [
|
||||
"arm_r"
|
||||
"ARM_R"
|
||||
],
|
||||
"field": "torqueNm",
|
||||
"value": "20N·m",
|
||||
@@ -613,7 +613,7 @@
|
||||
"warnings": [
|
||||
"部分二维来源框格式不可靠,已省略定位框,请查看整张原图核对。"
|
||||
],
|
||||
"catalogVersion": "2026-10-13-draft",
|
||||
"catalogVersion": "2026-10-16-component-types",
|
||||
"status": "ready",
|
||||
"canSubmit": true,
|
||||
"observations": [
|
||||
@@ -803,7 +803,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"schemaVersion": "multimodal-v1.1"
|
||||
"schemaVersion": "multimodal-v1.4-component-types"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -419,17 +419,17 @@
|
||||
"双足"
|
||||
],
|
||||
"requiredParts": [
|
||||
"torso_0",
|
||||
"head_0",
|
||||
"waist_0",
|
||||
"arm_l",
|
||||
"arm_r",
|
||||
"hand_l",
|
||||
"hand_r",
|
||||
"pedal_l",
|
||||
"pedal_r",
|
||||
"foot_l",
|
||||
"foot_r"
|
||||
"TORSO_0",
|
||||
"HEAD_0",
|
||||
"WAIST_0",
|
||||
"ARM_L",
|
||||
"ARM_R",
|
||||
"HAND_L",
|
||||
"HAND_R",
|
||||
"LEG_L",
|
||||
"LEG_R",
|
||||
"FOOT_L",
|
||||
"FOOT_R"
|
||||
],
|
||||
"robotRequirements": {
|
||||
"degreesOfFreedom": 20,
|
||||
@@ -441,11 +441,11 @@
|
||||
},
|
||||
"partRequirements": [
|
||||
{
|
||||
"category": "torso_0",
|
||||
"category": "TORSO_0",
|
||||
"material": "铝合金"
|
||||
},
|
||||
{
|
||||
"category": "arm_r",
|
||||
"category": "ARM_R",
|
||||
"torqueNm": 20,
|
||||
"operators": {
|
||||
"torqueNm": "gte"
|
||||
@@ -516,67 +516,67 @@
|
||||
],
|
||||
"partCategories": [
|
||||
{
|
||||
"category": "torso_0",
|
||||
"category": "TORSO_0",
|
||||
"source": "explicit",
|
||||
"reason": "需求明确提出躯干材质要求,对应躯干部件",
|
||||
"evidence": "躯干材质:铝合金"
|
||||
},
|
||||
{
|
||||
"category": "head_0",
|
||||
"category": "HEAD_0",
|
||||
"source": "inferred",
|
||||
"reason": "匹配双足机器人模板的标准组成部件",
|
||||
"evidence": "双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "waist_0",
|
||||
"category": "WAIST_0",
|
||||
"source": "inferred",
|
||||
"reason": "匹配双足机器人模板的标准组成部件",
|
||||
"evidence": "双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "arm_l",
|
||||
"category": "ARM_L",
|
||||
"source": "inferred",
|
||||
"reason": "匹配双足机器人模板的标准组成部件",
|
||||
"evidence": "双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "arm_r",
|
||||
"category": "ARM_R",
|
||||
"source": "explicit",
|
||||
"reason": "需求明确提出右臂扭矩要求,对应右臂部件",
|
||||
"evidence": "右臂扭矩:至少20N· m"
|
||||
},
|
||||
{
|
||||
"category": "hand_l",
|
||||
"category": "HAND_L",
|
||||
"source": "inferred",
|
||||
"reason": "匹配双足机器人模板的标准组成部件",
|
||||
"evidence": "双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "hand_r",
|
||||
"category": "HAND_R",
|
||||
"source": "inferred",
|
||||
"reason": "匹配双足机器人模板的标准组成部件",
|
||||
"evidence": "双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "pedal_l",
|
||||
"category": "LEG_L",
|
||||
"source": "inferred",
|
||||
"reason": "匹配双足机器人模板的标准组成部件",
|
||||
"evidence": "双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "pedal_r",
|
||||
"category": "LEG_R",
|
||||
"source": "inferred",
|
||||
"reason": "匹配双足机器人模板的标准组成部件",
|
||||
"evidence": "双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "foot_l",
|
||||
"category": "FOOT_L",
|
||||
"source": "inferred",
|
||||
"reason": "匹配双足机器人模板的标准组成部件",
|
||||
"evidence": "双足跑步机器人"
|
||||
},
|
||||
{
|
||||
"category": "foot_r",
|
||||
"category": "FOOT_R",
|
||||
"source": "inferred",
|
||||
"reason": "匹配双足机器人模板的标准组成部件",
|
||||
"evidence": "双足跑步机器人"
|
||||
@@ -605,7 +605,7 @@
|
||||
{
|
||||
"scope": "part",
|
||||
"categories": [
|
||||
"torso_0"
|
||||
"TORSO_0"
|
||||
],
|
||||
"field": "material",
|
||||
"value": "铝合金",
|
||||
@@ -616,7 +616,7 @@
|
||||
{
|
||||
"scope": "part",
|
||||
"categories": [
|
||||
"arm_r"
|
||||
"ARM_R"
|
||||
],
|
||||
"field": "torqueNm",
|
||||
"value": "20N·m",
|
||||
@@ -639,7 +639,7 @@
|
||||
"warnings": [
|
||||
"部分二维来源框格式不可靠,已省略定位框,请查看整张原图核对。"
|
||||
],
|
||||
"catalogVersion": "2026-10-13-draft",
|
||||
"catalogVersion": "2026-10-16-component-types",
|
||||
"status": "ready",
|
||||
"canSubmit": true,
|
||||
"observations": [
|
||||
@@ -852,7 +852,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"schemaVersion": "multimodal-v1.1"
|
||||
"schemaVersion": "multimodal-v1.4-component-types"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,17 +186,17 @@
|
||||
"双足"
|
||||
],
|
||||
"requiredParts": [
|
||||
"torso_0",
|
||||
"head_0",
|
||||
"waist_0",
|
||||
"arm_l",
|
||||
"arm_r",
|
||||
"hand_l",
|
||||
"hand_r",
|
||||
"pedal_l",
|
||||
"pedal_r",
|
||||
"foot_l",
|
||||
"foot_r"
|
||||
"TORSO_0",
|
||||
"HEAD_0",
|
||||
"WAIST_0",
|
||||
"ARM_L",
|
||||
"ARM_R",
|
||||
"HAND_L",
|
||||
"HAND_R",
|
||||
"LEG_L",
|
||||
"LEG_R",
|
||||
"FOOT_L",
|
||||
"FOOT_R"
|
||||
],
|
||||
"robotRequirements": {},
|
||||
"partRequirements": []
|
||||
@@ -257,49 +257,49 @@
|
||||
],
|
||||
"partCategories": [
|
||||
{
|
||||
"category": "head_0",
|
||||
"category": "HEAD_0",
|
||||
"source": "inferred",
|
||||
"reason": "草图顶部空心圆形结构对应头部部件",
|
||||
"evidence": "简笔黑白线条绘制的人形结构:顶部为空心圆形轮廓,中部为竖直空心长方形躯干,躯干左右两侧各连接一条两段折线形的手臂,无手部细节;躯干下方向左右两侧倾斜伸出两条长直线形腿,每条腿末端各有一段短横向平底结构作为足部,图中无任何文字标注。"
|
||||
},
|
||||
{
|
||||
"category": "torso_0",
|
||||
"category": "TORSO_0",
|
||||
"source": "inferred",
|
||||
"reason": "草图中部竖直空心长方形结构对应躯干部件",
|
||||
"evidence": "简笔黑白线条绘制的人形结构:顶部为空心圆形轮廓,中部为竖直空心长方形躯干,躯干左右两侧各连接一条两段折线形的手臂,无手部细节;躯干下方向左右两侧倾斜伸出两条长直线形腿,每条腿末端各有一段短横向平底结构作为足部,图中无任何文字标注。"
|
||||
},
|
||||
{
|
||||
"category": "arm_l",
|
||||
"category": "ARM_L",
|
||||
"source": "inferred",
|
||||
"reason": "躯干左侧连接的折线结构对应左侧手臂部件",
|
||||
"evidence": "简笔黑白线条绘制的人形结构:顶部为空心圆形轮廓,中部为竖直空心长方形躯干,躯干左右两侧各连接一条两段折线形的手臂,无手部细节;躯干下方向左右两侧倾斜伸出两条长直线形腿,每条腿末端各有一段短横向平底结构作为足部,图中无任何文字标注。"
|
||||
},
|
||||
{
|
||||
"category": "arm_r",
|
||||
"category": "ARM_R",
|
||||
"source": "inferred",
|
||||
"reason": "躯干右侧连接的折线结构对应右侧手臂部件",
|
||||
"evidence": "简笔黑白线条绘制的人形结构:顶部为空心圆形轮廓,中部为竖直空心长方形躯干,躯干左右两侧各连接一条两段折线形的手臂,无手部细节;躯干下方向左右两侧倾斜伸出两条长直线形腿,每条腿末端各有一段短横向平底结构作为足部,图中无任何文字标注。"
|
||||
},
|
||||
{
|
||||
"category": "pedal_l",
|
||||
"category": "LEG_L",
|
||||
"source": "inferred",
|
||||
"reason": "躯干下方左侧倾斜伸出的长直结构对应左侧腿部部件",
|
||||
"evidence": "简笔黑白线条绘制的人形结构:顶部为空心圆形轮廓,中部为竖直空心长方形躯干,躯干左右两侧各连接一条两段折线形的手臂,无手部细节;躯干下方向左右两侧倾斜伸出两条长直线形腿,每条腿末端各有一段短横向平底结构作为足部,图中无任何文字标注。"
|
||||
},
|
||||
{
|
||||
"category": "pedal_r",
|
||||
"category": "LEG_R",
|
||||
"source": "inferred",
|
||||
"reason": "躯干下方右侧倾斜伸出的长直结构对应右侧腿部部件",
|
||||
"evidence": "简笔黑白线条绘制的人形结构:顶部为空心圆形轮廓,中部为竖直空心长方形躯干,躯干左右两侧各连接一条两段折线形的手臂,无手部细节;躯干下方向左右两侧倾斜伸出两条长直线形腿,每条腿末端各有一段短横向平底结构作为足部,图中无任何文字标注。"
|
||||
},
|
||||
{
|
||||
"category": "foot_l",
|
||||
"category": "FOOT_L",
|
||||
"source": "inferred",
|
||||
"reason": "左侧腿末端的短横向结构对应左脚平底部件",
|
||||
"evidence": "简笔黑白线条绘制的人形结构:顶部为空心圆形轮廓,中部为竖直空心长方形躯干,躯干左右两侧各连接一条两段折线形的手臂,无手部细节;躯干下方向左右两侧倾斜伸出两条长直线形腿,每条腿末端各有一段短横向平底结构作为足部,图中无任何文字标注。"
|
||||
},
|
||||
{
|
||||
"category": "foot_r",
|
||||
"category": "FOOT_R",
|
||||
"source": "inferred",
|
||||
"reason": "右侧腿末端的短横向结构对应右脚平底部件",
|
||||
"evidence": "简笔黑白线条绘制的人形结构:顶部为空心圆形轮廓,中部为竖直空心长方形躯干,躯干左右两侧各连接一条两段折线形的手臂,无手部细节;躯干下方向左右两侧倾斜伸出两条长直线形腿,每条腿末端各有一段短横向平底结构作为足部,图中无任何文字标注。"
|
||||
@@ -312,7 +312,7 @@
|
||||
"warnings": [
|
||||
"机器人类型含推断,仅用于兼容候选,不能视为用户确认或全部功能满足。"
|
||||
],
|
||||
"catalogVersion": "2026-10-13-draft",
|
||||
"catalogVersion": "2026-10-16-component-types",
|
||||
"status": "ready",
|
||||
"canSubmit": true,
|
||||
"observations": [
|
||||
@@ -380,7 +380,7 @@
|
||||
]
|
||||
}
|
||||
],
|
||||
"schemaVersion": "multimodal-v1.1"
|
||||
"schemaVersion": "multimodal-v1.4-component-types"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user