web-map/README.md

470 lines
8.7 KiB
Markdown
Raw Permalink Normal View History

2025-05-20 17:55:56 +08:00
# 页面路由
2025-06-06 22:36:16 +08:00
路由统一前缀 web-amr
2025-05-20 17:55:56 +08:00
1. 场景编辑
2025-05-25 16:45:45 +08:00
/scene-editor/:id [id为场景id]
2025-05-20 17:55:56 +08:00
2. 组编辑
2025-05-25 16:45:45 +08:00
/group-editor/:sid/:id [sid为场景idid为机器人组id]
3. 运行监控
/movement-supervision/:sid [sid为场景id]
2025-05-20 17:55:56 +08:00
2025-05-06 17:29:20 +08:00
# 场景接口
2025-04-20 00:49:14 +08:00
2025-05-06 17:29:20 +08:00
## 获取场景
2025-04-20 00:49:14 +08:00
2025-05-06 17:29:20 +08:00
POST /scene/getById
请求体:
{ id: string }
响应体:
SceneDetail
示例:
```json
{
"code": 200,
"success": true,
"data": {
"id": "mock-scene-1",
"label": "模拟场景A",
2025-05-20 17:55:56 +08:00
"json": "同.scene文件"
2025-05-06 17:29:20 +08:00
},
"message": "模拟提示"
}
```
2025-05-11 18:46:59 +08:00
## 保存场景
POST /scene/saveById
请求体:
2025-05-20 17:55:56 +08:00
{ id: string; json: string; png?: string }
响应体:
## 推送场景
POST /scene/pushById
请求体:
{ id: string }
2025-05-11 18:46:59 +08:00
响应体:
## 获取组场景
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",
2025-06-04 18:43:50 +08:00
"brand": 1,
2025-05-11 18:46:59 +08:00
"type": 1,
"ip": "127.0.1.1",
"isConnected": true,
"state": 4,
"canOrder": true,
"canStop": true,
"canControl": true
},
{
"id": "mock-robot-2",
"label": "模拟机器人B",
2025-06-04 18:43:50 +08:00
"brand": 1,
2025-05-11 18:46:59 +08:00
"type": 2,
"ip": "127.0.1.2"
}
]
},
"message": "模拟提示"
}
```
## 保存组场景
POST /scene/saveByGroupId
请求体:
{ id: string; sid: string; json: string }
响应体:
2025-05-25 16:45:45 +08:00
## 实时监控场景
WebSocket /scene/monitor/:id [id为场景id]
实时数据:
RobotRealtimeInfo [JSON]
示例:
```json
{
"id": "mock-robot-1",
"label": "模拟机器人A",
2025-06-04 18:43:50 +08:00
"brand": 1,
2025-05-25 16:45:45 +08:00
"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": []
2025-05-25 16:45:45 +08:00
}
```
2025-05-11 18:46:59 +08:00
# 机器人接口
## 获取所有机器人
POST /robot/getAll
请求体:
响应体:
Array<RobotInfo>
示例:
```json
{
"code": 200,
"success": true,
"data": [
{
"id": "mock-robot-1",
"label": "模拟机器人A",
2025-06-04 18:43:50 +08:00
"brand": 1,
2025-05-11 18:46:59 +08:00
"type": 1,
"ip": "127.0.1.1"
},
{
"id": "mock-robot-2",
"label": "模拟机器人B",
2025-06-04 18:43:50 +08:00
"brand": 1,
2025-05-11 18:46:59 +08:00
"type": 2,
"ip": "127.0.1.2"
},
{
"id": "mock-robot-3",
"label": "模拟机器人C",
2025-06-04 18:43:50 +08:00
"brand": 1,
2025-05-11 18:46:59 +08:00
"type": 3,
"ip": "127.0.1.3"
},
{
"id": "mock-robot-4",
"label": "模拟机器人D",
2025-06-04 18:43:50 +08:00
"brand": 1,
2025-05-11 18:46:59 +08:00
"type": 1,
"ip": "127.0.2.1"
},
{
"id": "mock-robot-5",
"label": "模拟机器人E",
2025-06-04 18:43:50 +08:00
"brand": 1,
2025-05-11 18:46:59 +08:00
"type": 2,
"ip": "127.0.2.2"
},
{
"id": "mock-robot-6",
"label": "模拟机器人F",
2025-06-04 18:43:50 +08:00
"brand": 1,
2025-05-11 18:46:59 +08:00
"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": "模拟机器人-注册",
2025-06-04 18:43:50 +08:00
"brand": 1,
2025-05-11 18:46:59 +08:00
"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 }
响应体:
2025-05-06 17:29:20 +08:00
# 数据结构
1. 场景相关
```typescript
interface SceneDetail {
id: string; // 场景id
label: string; // 场景名称
json?: string; // 场景JSON
}
2025-05-11 18:46:59 +08:00
interface GroupSceneDetail {
id: string; // 组场景id
label: string; // 组场景名称
json?: string; // 组场景JSON
group: RobotGroup; // 机器人组
robots?: Array<RobotInfo>; // 组场景机器人
}
2025-05-20 17:55:56 +08:00
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; // 扩展类型
2025-05-20 17:55:56 +08:00
robots?: Array<string>; // 绑定机器人id集合
actions?: Array<string>; // 绑定动作点id集合
associatedStorageLocations?: string[]; // 库位名称
2025-05-20 17:55:56 +08:00
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[]>>; // 动作点对应的库位信息,格式为 [{动作点名称: [库位列表]}]
2025-05-20 17:55:56 +08:00
config?: object; // 其它属性配置(可按需增加)
properties?: unknown; // 附加数据(前端不做任何处理)
}
2025-05-06 17:29:20 +08:00
```
2. 机器人相关
```typescript
interface RobotGroup {
2025-05-11 18:46:59 +08:00
sid?: string; // 场景id
2025-05-06 17:29:20 +08:00
id: string; // 机器人组id
label: string; // 机器人组名称
robots?: Array<string>; // 机器人列表
}
interface RobotInfo {
gid?: string; // 机器人组id
id: string; // 机器人id
label: string; // 机器人名称
brand: RobotBrand; // 机器人品牌
type: RobotType; // 机器人类型
2025-06-04 18:43:50 +08:00
ip?: string; // 机器人ip仅真实机器人
2025-05-06 17:29:20 +08:00
battery?: number; // 机器人电量
isConnected?: boolean; // 机器人连接状态
state?: RobotState; // 机器人状态
canOrder?: boolean; // 接单状态
canStop?: boolean; // 急停状态
canControl?: boolean; // 控制状态
2025-06-17 22:28:12 +08:00
targetPoint?: string; // 目标点位(名称)
2025-05-06 17:29:20 +08:00
}
2025-05-11 18:46:59 +08:00
export interface RobotDetail extends RobotInfo {
isSimulative?: 0 | 1; // 是否仿真机器人
minBattery?: number; // 最小电量
maxBattery?: number; // 最大电量
chargeBattery?: number; // 充电电量
taskBattery?: number; // 任务电量
swapBattery?: number; // 交换电量
2025-06-04 18:43:50 +08:00
length?: number; // 空载长(仅仿真机器人)
width?: number; // 空载宽(仅仿真机器人)
2025-05-11 18:46:59 +08:00
}
2025-05-25 16:45:45 +08:00
export interface RobotRealtimeInfo extends RobotInfo {
x: number; // 坐标x
y: number; // 坐标y
active?: boolean; // 是否运行
angle?: number; // 旋转角度
path?: Array<{ x: number; y: number }>; // 规划路径
2025-05-25 16:45:45 +08:00
}
2025-05-06 17:29:20 +08:00
enum RobotBrand {
2025-06-04 18:43:50 +08:00
仙工 = 1,
2025-05-06 17:29:20 +08:00
}
enum RobotType {
叉车机器人 = 1,
AMR机器人,
料箱机器人,
}
enum RobotState {
任务执行中 = 1,
充电中,
停靠中,
空闲中,
}
```
3. 地图相关
```typescript
enum MapPointType {
普通点 = 1,
等待点,
避让点,
临时避让点,
电梯点 = 11,
自动门点,
充电点,
停靠点,
动作点,
禁行点,
}
2025-05-06 23:48:21 +08:00
2025-05-06 17:29:20 +08:00
enum MapRouteType {
直线 = 'line',
2025-05-20 17:55:56 +08:00
二阶贝塞尔曲线 = 'bezier2',
2025-05-06 17:29:20 +08:00
三阶贝塞尔曲线 = 'bezier3',
}
2025-05-06 23:48:21 +08:00
enum MapRoutePassType {
无,
仅空载可通行,
仅载货可通行,
禁行 = 10,
}
2025-05-06 17:29:20 +08:00
enum MapAreaType {
库区 = 1,
互斥区 = 11,
非互斥区,
}
```
# 场景文件格式
1. 场景文件格式为json格式包含以下字段
2025-05-20 17:55:56 +08:00
robotGroups?: Array<RobotGroup>; // 机器人组信息
robots?: Array<RobotInfo>; // 机器人信息
points?: Array<StandardScenePoint>; // 标准点位信息
routes?: Array<StandardSceneRoute>; // 标准线路信息
areas?: Array<StandardSceneArea>; // 标准区域信息
blocks?: Array<[number, number]>; // 障碍点集合