470 lines
8.7 KiB
Markdown
470 lines
8.7 KiB
Markdown
# 页面路由
|
||
|
||
路由统一前缀 web-amr
|
||
|
||
1. 场景编辑
|
||
/scene-editor/:id [id为场景id]
|
||
2. 组编辑
|
||
/group-editor/:sid/:id [sid为场景id,id为机器人组id]
|
||
3. 运行监控
|
||
/movement-supervision/:sid [sid为场景id]
|
||
|
||
# 场景接口
|
||
|
||
## 获取场景
|
||
|
||
POST /scene/getById
|
||
|
||
请求体:
|
||
{ id: string }
|
||
|
||
响应体:
|
||
SceneDetail
|
||
|
||
示例:
|
||
|
||
```json
|
||
{
|
||
"code": 200,
|
||
"success": true,
|
||
"data": {
|
||
"id": "mock-scene-1",
|
||
"label": "模拟场景A",
|
||
"json": "同.scene文件"
|
||
},
|
||
"message": "模拟提示"
|
||
}
|
||
```
|
||
|
||
## 保存场景
|
||
|
||
POST /scene/saveById
|
||
|
||
请求体:
|
||
{ id: string; json: string; png?: string }
|
||
|
||
响应体:
|
||
无
|
||
|
||
## 推送场景
|
||
|
||
POST /scene/pushById
|
||
|
||
请求体:
|
||
{ id: string }
|
||
|
||
响应体:
|
||
无
|
||
|
||
## 获取组场景
|
||
|
||
POST /scene/getByGroupId
|
||
|
||
请求体:
|
||
{ id: string; sid: string }
|
||
|
||
响应体:
|
||
GroupSceneDetail
|
||
|
||
示例:
|
||
|
||
```json
|
||
{
|
||
"code": 200,
|
||
"success": true,
|
||
"data": {
|
||
"id": "mock-group-scene-1",
|
||
"label": "模拟组场景A",
|
||
"group": {
|
||
"sid": "mock-scene-1",
|
||
"id": "mock-robot-group",
|
||
"label": "模拟机器人组",
|
||
"robots": ["mock-robot-1", "mock-robot-2"]
|
||
},
|
||
"robots": [
|
||
{
|
||
"id": "mock-robot-1",
|
||
"label": "模拟机器人A",
|
||
"brand": 1,
|
||
"type": 1,
|
||
"ip": "127.0.1.1",
|
||
"isConnected": true,
|
||
"state": 4,
|
||
"canOrder": true,
|
||
"canStop": true,
|
||
"canControl": true
|
||
},
|
||
{
|
||
"id": "mock-robot-2",
|
||
"label": "模拟机器人B",
|
||
"brand": 1,
|
||
"type": 2,
|
||
"ip": "127.0.1.2"
|
||
}
|
||
]
|
||
},
|
||
"message": "模拟提示"
|
||
}
|
||
```
|
||
|
||
## 保存组场景
|
||
|
||
POST /scene/saveByGroupId
|
||
|
||
请求体:
|
||
{ id: string; sid: string; json: string }
|
||
|
||
响应体:
|
||
无
|
||
|
||
## 实时监控场景
|
||
|
||
WebSocket /scene/monitor/:id [id为场景id]
|
||
|
||
实时数据:
|
||
RobotRealtimeInfo [JSON]
|
||
|
||
示例:
|
||
|
||
```json
|
||
{
|
||
"id": "mock-robot-1",
|
||
"label": "模拟机器人A",
|
||
"brand": 1,
|
||
"type": 1,
|
||
"ip": "127.0.1.1",
|
||
"isConnected": true,
|
||
"state": 4,
|
||
"canOrder": true,
|
||
"canStop": true,
|
||
"canControl": true,
|
||
"x": 800,
|
||
"y": 500,
|
||
"active": true,
|
||
"angle": -90,
|
||
"path": []
|
||
}
|
||
```
|
||
|
||
# 机器人接口
|
||
|
||
## 获取所有机器人
|
||
|
||
POST /robot/getAll
|
||
|
||
请求体:
|
||
无
|
||
|
||
响应体:
|
||
Array<RobotInfo>
|
||
|
||
示例:
|
||
|
||
```json
|
||
{
|
||
"code": 200,
|
||
"success": true,
|
||
"data": [
|
||
{
|
||
"id": "mock-robot-1",
|
||
"label": "模拟机器人A",
|
||
"brand": 1,
|
||
"type": 1,
|
||
"ip": "127.0.1.1"
|
||
},
|
||
{
|
||
"id": "mock-robot-2",
|
||
"label": "模拟机器人B",
|
||
"brand": 1,
|
||
"type": 2,
|
||
"ip": "127.0.1.2"
|
||
},
|
||
{
|
||
"id": "mock-robot-3",
|
||
"label": "模拟机器人C",
|
||
"brand": 1,
|
||
"type": 3,
|
||
"ip": "127.0.1.3"
|
||
},
|
||
{
|
||
"id": "mock-robot-4",
|
||
"label": "模拟机器人D",
|
||
"brand": 1,
|
||
"type": 1,
|
||
"ip": "127.0.2.1"
|
||
},
|
||
{
|
||
"id": "mock-robot-5",
|
||
"label": "模拟机器人E",
|
||
"brand": 1,
|
||
"type": 2,
|
||
"ip": "127.0.2.2"
|
||
},
|
||
{
|
||
"id": "mock-robot-6",
|
||
"label": "模拟机器人F",
|
||
"brand": 1,
|
||
"type": 3,
|
||
"ip": "127.0.2.3"
|
||
}
|
||
],
|
||
"message": "模拟提示"
|
||
}
|
||
```
|
||
|
||
## 注册机器人
|
||
|
||
POST /robot/register
|
||
|
||
请求体:
|
||
RobotDetail
|
||
|
||
示例
|
||
|
||
```json
|
||
{
|
||
"isSimulative": 1,
|
||
"gid": "26b26411",
|
||
"label": "测试机器人",
|
||
"brand": 1,
|
||
"type": 2,
|
||
"ip": "127.0.0.1",
|
||
"minBattery": 0,
|
||
"chargeBattery": 40,
|
||
"taskBattery": 60,
|
||
"swapBattery": 20,
|
||
"maxBattery": 100
|
||
}
|
||
```
|
||
|
||
响应体:
|
||
RobotInfo
|
||
|
||
示例
|
||
|
||
```json
|
||
{
|
||
"code": 200,
|
||
"success": true,
|
||
"data": {
|
||
"id": "mock-robot-0",
|
||
"label": "模拟机器人-注册",
|
||
"brand": 1,
|
||
"type": 1,
|
||
"ip": "127.0.0.0"
|
||
},
|
||
"message": "模拟提示"
|
||
}
|
||
```
|
||
|
||
## 批量抢占控制权
|
||
|
||
POST /robot/seizeByIds
|
||
|
||
请求体:
|
||
{ ids: string[] }
|
||
|
||
响应体:
|
||
string[]
|
||
|
||
示例
|
||
|
||
```json
|
||
{
|
||
"code": 200,
|
||
"success": true,
|
||
"data": ["mock-robot-1", "mock-robot-2"],
|
||
"message": "模拟提示"
|
||
}
|
||
```
|
||
|
||
## 同步组文件
|
||
|
||
POST /robot/syncByGroupId
|
||
|
||
请求体:
|
||
{ id: string; sid: string }
|
||
|
||
响应体:
|
||
无
|
||
|
||
# 数据结构
|
||
|
||
1. 场景相关
|
||
|
||
```typescript
|
||
interface SceneDetail {
|
||
id: string; // 场景id
|
||
label: string; // 场景名称
|
||
json?: string; // 场景JSON
|
||
}
|
||
|
||
interface GroupSceneDetail {
|
||
id: string; // 组场景id
|
||
label: string; // 组场景名称
|
||
json?: string; // 组场景JSON
|
||
group: RobotGroup; // 机器人组
|
||
robots?: Array<RobotInfo>; // 组场景机器人
|
||
}
|
||
|
||
interface StandardScene {
|
||
robotGroups?: Array<RobotGroup>; // 机器人组信息
|
||
robots?: Array<RobotInfo>; // 机器人信息
|
||
points?: Array<StandardScenePoint>; // 标准点位信息
|
||
routes?: Array<StandardSceneRoute>; // 标准线路信息
|
||
areas?: Array<StandardSceneArea>; // 标准区域信息
|
||
blocks?: Array<[number, number]>; // 障碍点集合
|
||
}
|
||
interface StandardScenePoint {
|
||
id: string;
|
||
name: string;
|
||
desc?: string; // 描述
|
||
x: number;
|
||
y: number;
|
||
type: number; // 点位类型
|
||
extensionType?: number; // 扩展类型
|
||
robots?: Array<string>; // 绑定机器人id集合
|
||
actions?: Array<string>; // 绑定动作点id集合
|
||
associatedStorageLocations?: string[]; // 库位名称
|
||
config?: object; // 其它属性配置(可按需增加)
|
||
properties?: unknown; // 附加数据(前端不做任何处理)
|
||
}
|
||
interface StandardSceneRoute {
|
||
id: string;
|
||
desc?: string; // 描述
|
||
from: string; // 起点点位id
|
||
to: string; // 终点点位id
|
||
type: 'line' | 'bezier2' | 'bezier3'; // 线路类型
|
||
pass?: number; // 可通行类型
|
||
c1?: { x?: number; y?: number }; // 控制点1
|
||
c2?: { x?: number; y?: number }; // 控制点2
|
||
config?: object; // 其它属性配置(可按需增加)
|
||
properties?: unknown; // 附加数据(前端不做任何处理)
|
||
}
|
||
interface StandardSceneArea {
|
||
id: string;
|
||
name: string;
|
||
desc?: string; // 描述
|
||
x: number;
|
||
y: number;
|
||
w: number;
|
||
h: number;
|
||
type: number; // 区域类型
|
||
points?: Array<string>; // 绑定点位id集合
|
||
routes?: Array<string>; // 绑定线路id集合
|
||
maxAmr?: number; // 最大可容纳AMR数
|
||
inoutflag?: 1 | 2; // 库区规则
|
||
storageLocations?: Array<Record<string, string[]>>; // 动作点对应的库位信息,格式为 [{动作点名称: [库位列表]}]
|
||
config?: object; // 其它属性配置(可按需增加)
|
||
properties?: unknown; // 附加数据(前端不做任何处理)
|
||
}
|
||
```
|
||
|
||
2. 机器人相关
|
||
|
||
```typescript
|
||
interface RobotGroup {
|
||
sid?: string; // 场景id
|
||
id: string; // 机器人组id
|
||
label: string; // 机器人组名称
|
||
robots?: Array<string>; // 机器人列表
|
||
}
|
||
|
||
interface RobotInfo {
|
||
gid?: string; // 机器人组id
|
||
id: string; // 机器人id
|
||
label: string; // 机器人名称
|
||
brand: RobotBrand; // 机器人品牌
|
||
type: RobotType; // 机器人类型
|
||
ip?: string; // 机器人ip(仅真实机器人)
|
||
battery?: number; // 机器人电量
|
||
isConnected?: boolean; // 机器人连接状态
|
||
state?: RobotState; // 机器人状态
|
||
canOrder?: boolean; // 接单状态
|
||
canStop?: boolean; // 急停状态
|
||
canControl?: boolean; // 控制状态
|
||
targetPoint?: string; // 目标点位(名称)
|
||
}
|
||
export interface RobotDetail extends RobotInfo {
|
||
isSimulative?: 0 | 1; // 是否仿真机器人
|
||
minBattery?: number; // 最小电量
|
||
maxBattery?: number; // 最大电量
|
||
chargeBattery?: number; // 充电电量
|
||
taskBattery?: number; // 任务电量
|
||
swapBattery?: number; // 交换电量
|
||
length?: number; // 空载长(仅仿真机器人)
|
||
width?: number; // 空载宽(仅仿真机器人)
|
||
}
|
||
export interface RobotRealtimeInfo extends RobotInfo {
|
||
x: number; // 坐标x
|
||
y: number; // 坐标y
|
||
active?: boolean; // 是否运行
|
||
angle?: number; // 旋转角度
|
||
path?: Array<{ x: number; y: number }>; // 规划路径
|
||
}
|
||
|
||
enum RobotBrand {
|
||
仙工 = 1,
|
||
}
|
||
enum RobotType {
|
||
叉车机器人 = 1,
|
||
AMR机器人,
|
||
料箱机器人,
|
||
}
|
||
enum RobotState {
|
||
任务执行中 = 1,
|
||
充电中,
|
||
停靠中,
|
||
空闲中,
|
||
}
|
||
```
|
||
|
||
3. 地图相关
|
||
|
||
```typescript
|
||
enum MapPointType {
|
||
普通点 = 1,
|
||
等待点,
|
||
避让点,
|
||
临时避让点,
|
||
|
||
电梯点 = 11,
|
||
自动门点,
|
||
充电点,
|
||
停靠点,
|
||
动作点,
|
||
禁行点,
|
||
}
|
||
|
||
enum MapRouteType {
|
||
直线 = 'line',
|
||
二阶贝塞尔曲线 = 'bezier2',
|
||
三阶贝塞尔曲线 = 'bezier3',
|
||
}
|
||
enum MapRoutePassType {
|
||
无,
|
||
|
||
仅空载可通行,
|
||
仅载货可通行,
|
||
|
||
禁行 = 10,
|
||
}
|
||
|
||
enum MapAreaType {
|
||
库区 = 1,
|
||
|
||
互斥区 = 11,
|
||
非互斥区,
|
||
}
|
||
```
|
||
|
||
# 场景文件格式
|
||
|
||
1. 场景文件格式为json格式,包含以下字段:
|
||
robotGroups?: Array<RobotGroup>; // 机器人组信息
|
||
robots?: Array<RobotInfo>; // 机器人信息
|
||
points?: Array<StandardScenePoint>; // 标准点位信息
|
||
routes?: Array<StandardSceneRoute>; // 标准线路信息
|
||
areas?: Array<StandardSceneArea>; // 标准区域信息
|
||
blocks?: Array<[number, number]>; // 障碍点集合
|