Files
frontend/Client/docs/backend-direct-matching.md

2.5 KiB
Raw Permalink Blame History

直接获取零件:会话生成与自动装配

用户输入文字或图片后,前端创建会话、上传图片(如有)、发送消息并接收 SSE。后端在同一任务中完成需求理解、选件和装配校验,完成事件直接返回 data.match。前台按 instanceId 加载全部组件;连接只使用 parentFrameIndex、childFrameIndex、interfaceChild 和双方实际 URDF Link 矩阵。

当前接口流程

  • 文字消息调用 POST /api/robot-conversations/{conversationId}/messages,前端消费 analysis.progress、analysis.completed 和 analysis.failed。
  • analysis.completed 只有在 status=ready 时才同时包含 result 和 match;match.assembly.status=ready 时直接加载已有组合,partial 也直接展示可用组件。
  • assembly.connections[] 不包含装配矩阵。后端负责接口兼容性和配对;前端仅依据两个 frame 下标从实际加载的 URDF Link 矩阵计算 parentInterface × inverse(childInterface),不以 interfaceChild 或 Link 名否决后端批准的连接。
  • analysis.failed 的错误码从 SSE envelope 外层 code 读取,data 可以为 null。

浏览器请求保留 credentials: "include"。用户调整需求时在同一会话发送新的 messageId,后端生成新版本;retry 仅用于失败或已停止的当前任务。前端不调用 confirm、rematch、按 matchId 查询或接受降级接口。

所有分类键使用大写,例如 TORSO_0、ARM_R、LEG_L。Link 名允许 LINK#id_...,前端分类时过滤 #id,但保留实际 Link 名用于 URDF 定位;解析 Link 名继续使用 trim()。同一组件的多个同类接口可以使用不同的 #id,实例之间仍使用后端返回的 instanceId 区分。

连接处理

parentFrameIndex、childFrameIndex 是双方各自原始 urdfInfo.frames 数组的零起始下标。前端读取对应 frame,要求双方 child 都严格等于 interfaceChild;名称字段只用于显示。加载 URDF 后,前端从实际 Link 的累计矩阵计算:

child component transform = parent interface transform × inverse(child interface transform)

后端不返回 matrixLayout、parentRootToInterface、childRootToInterface 或 childRootRelativeToParentRoot;前端不兼容读取这些旧字段。位姿、资源或活动关节问题通过 assembly.issues 和 resourceIssues 展示,已有可连接组合仍可显示。