VWED_server/docs/sc/机器人相关.md

701 lines
13 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 机器人相关模块文档 (Python版本)
## 机器人相关
### 校验机器人是否存在
* 方法说明
校验机器人是否存在。
```python
async def is_robot_exist(robot_name: str) -> bool
```
* 输入参数
`robot_name`: string 类型,机器人名称。
* 输出参数
* `True`: 存在。
* `False`: 不存在。
* 异常
本方法不抛出异常。
### 获取机器人基本信息
* 方法说明
获取机器人基本信息。
```python
async def get_lite_robots_status() -> str
```
* 输入参数
无。
* 输出参数
```json
[
{
"battery_level": 1,
"confidence": 1,
"currentGroup": "unnamed",
"current_map": "newCHACHECPD-15_1",
"current_map_invalid": false,
"dI": [],
"dO": [],
"disconnect": false,
"dispatchable": true,
"dispatchable_status": 0,
"errors": [],
"ip": "",
"low_battery": false,
"reloc_status": 1,
"task_status": 0,
"unconfirmed_reloc": false,
"unlock": 0,
"uuid": "sim_01"
},
{
"battery_level": 1,
"confidence": 1,
"currentGroup": "RobotGroup-01",
"current_map": "newCHACHECPD-15_1",
"current_map_invalid": false,
"dI": [],
"dO": [],
"disconnect": false,
"dispatchable": true,
"dispatchable_status": 0,
"errors": [],
"ip": "",
"low_battery": false,
"orderId": "ab913f4b-9a35-4cdf-a4e5-07928897e0d2",
"reloc_status": 1,
"state": "FINISHED",
"task_status": 4,
"unconfirmed_reloc": false,
"unlock": 0,
"uuid": "sim_02"
}
]
```
* 异常
本方法抛出异常。
### 根据ID获取机器人基本信息
* 方法说明
根据ID获取机器人基本信息。
```python
async def get_lite_robots_status_by_id(agv_id: str) -> str
```
* 输入参数
`agv_id`: string 类型机器人ID。
* 输出参数
```json
{
"battery_level": 1,
"confidence": 1,
"currentGroup": "unnamed",
"current_map": "newCHACHECPD-15_1",
"current_map_invalid": false,
"dI": [],
"dO": [],
"disconnect": false,
"dispatchable": true,
"dispatchable_status": 0,
"errors": [],
"ip": "",
"low_battery": false,
"reloc_status": 1,
"task_status": 0,
"unconfirmed_reloc": false,
"unlock": 0,
"uuid": "sim_01"
}
```
* 异常
本方法会抛出异常。
### 根据ID获取机器人位置
* 方法说明
根据机器人ID获取机器人的位置。
```python
async def get_vehicle_station(agv_id: str) -> str
```
* 输入参数
`agv_id`: string 类型机器人ID。
* 输出参数
```json
{
"lastStation": "LM32",
"station": "AP25"
}
```
如果与调度断连返回空对象 `{}`
* 异常
本方法不抛出异常。
### 获取Core报错信息
* 方法说明
获取Core报错信息。
```python
async def get_core_alarms() -> str
```
* 输入参数
无。
* 输出参数
```json
{
"errors": [
{
"code": 52106,
"desc": "(AMB-01: blocked by chengpin-02 in occupy path. blocked by chengpin-02 in block group's edge BlockGroup102)(AMB-02: blocked by AMB-05 in occupy path. blocked by AMB-05 in block group's edge BlockGroup94)(AMB-03: blocked by AMB-05 in block group's lm BlockGroup94)(AMB-05: blocked by AMB-03 in block group's lm BlockGroup105)(chengpin-02: blocked by AMB-01 in occupy path. blocked by AMB-01 in block group's edge BlockGroup102)",
"times": 5,
"timestamp": 1681110467
},
{
"code": 52201,
"desc": "(AMB-01,chengpin-02, in BlockGroup102, whose max number is 1 ), The number of robots in same block group is over max number.",
"times": 1,
"timestamp": 1681110452
}
],
"warnings": [
{
"code": 54000,
"desc": "AMB-02,AMB-05,chengpin-03,chengpin-08, unable to reach park point.",
"times": 1,
"timestamp": 1681110462
}
]
}
```
当与调度断连时,本方法会返回 `None`
* 异常
本方法不会抛出异常。
async ### 根据ID获取Core报错信息
* 方法说明
根据ID获取Core报错信息。
```python
async def get_core_alarms_by_id(code: int) -> str
```
* 输入参数
`code`: int类型错误码。
* 输出参数
```json
{
"errors": [
{
"code": 52201,
"desc": "(AMB-01,chengpin-02, in BlockGroup102, whose max number is 1 ), The number of robots in same block group is over max number.",
"times": 1,
"timestamp": 1681110452
}
]
}
```
当与调度断连时,本方法会返回 `None`
* 异常
本方法不会抛出异常。
### 获取Rbk报错信息
* 方法说明
获取Rbk报错信息。
```python
async def get_rbk_alarms() -> str
```
* 输入参数
无。
* 输出参数
```json
{
"errors": [
{
"code": 52200,
"desc": "Blocked by : chengpin-02",
"times": 1,
"timestamp": 1681116822857
},
{
"code": 52200,
"desc": "Blocked by : AMB-01",
"times": 1,
"timestamp": 1681116822858
}
]
}
```
当与调度断连时,本方法会返回 `None`
* 异常
本方法不会抛出异常。
### 根据ID获取Rbk报错信息
* 方法说明
根据ID获取Rbk报错信息。
```python
async def get_rbk_alarms_by_id(code: int) -> str
```
* 输入参数
`code`: int类型错误码。
* 输出参数
```json
{
"errors": [
{
"code": 52200,
"desc": "Blocked by : chengpin-02",
"times": 1,
"timestamp": 1681117052956
},
{
"code": 52200,
"desc": "Blocked by : AMB-01",
"times": 1,
"timestamp": 1681117052956
}
]
}
```
当与调度断连时,本方法会返回 `None`
* 异常
本方法不会抛出异常。
### 设置机器人软急停
* 方法说明
设置机器人软急停。
```python
async def set_soft_stop(vehicle_id: str, status: bool) -> bool
```
* 输入参数
`vehicle_id`: string 类型,机器人名称。
`status`: boolean类型`True`: 设置机器人软急停,`False`: 取消机器人软急停。
* 输出参数
* `True`: 成功。
* `False`: 失败。
* 异常
本方法不抛出异常。
### 获取机器人所有信息
* 方法说明
获取机器人所有信息。
```python
async def get_robots_status() -> str
```
* 输入参数
无。
* 输出参数
```json
{
"dynamic_obstacle": {},
"errors": [
{
"52101": 1634020173,
"desc": "hu-test-1,hu-test-3, have no charge point in map.",
"times": 1
},
{
"52103": 1634020173,
"desc": "hu-test-1,hu-test-3, have no park point in map.",
"times": 1
},
{
"53200": 1634020174,
"desc": "[{\"error_msg\":\"old: hu-test-1, now: AMB-01, please change back!\",\"ip\":\"106.14.198.1\"}]",
"times": 1
}
],
"fatals": [],
"notices": [],
"report": [
{
"area_resources_occupied": [
{
"area_name": "new",
"avoidObs_area_occupied": {
"radius": -1,
"x": 0,
"y": 0
},
"blocks_occupied": [],
"path_occupied": [
{
"end_id": "AP1",
"end_percentage": 0.7882161028093827,
"source_id": "AP61",
"start_percentage": 0.7882161028093827
}
]
}
],
"basic_info": {
"current_map": "20200529150233136",
"dsp_version": "simulation",
"ip": "106.14.198.1",
"model": "AMB-150",
"robot_note": "",
"version": "v3.3.4.51"
},
"changes": {
"maps": [
"20200529150233136.smap",
"default.smap",
"wwww(1).smap"
],
"model": true
},
"chassis": {
"goods_region": {
"name": "",
"point": []
},
"head": 0.42,
"radius": 0.0,
"shape": 1,
"tail": 0.38,
"width": 0.56
},
"connection_status": 1,
"current_order": {},
"dispatchable": false,
"is_error": false,
"lock_info": {
"desc": "",
"ip": "58.34.135.130",
"locked": true,
"nick_name": "DESKTOP-27FKEEM(0d50b)",
"port": 54733,
"time_t": "1634023715",
"type": 2
},
"network_delay": 100,
"rbk_report": {
"DI": [],
"DO": [],
"angle": -1.5626,
"battery_level": 1.0,
"blocked": false,
"brake": false,
"charging": false,
"confidence": 0.996,
"current": -1.0,
"current_map": "20200529150233136",
"current_map_md5": "72a91de898406e10b9cedfed51a3a5f9",
"current_station": "LM1",
"emergency": false,
"errors": [],
"fatals": [],
"fork": {
"fork_auto_flag": true,
"fork_height": -0.0,
"fork_height_in_place": false,
"forward_in_place": false,
"forward_val": 0.0
},
"info": {},
"jack": {
"jack_emc": false,
"jack_enable": false,
"jack_error_code": 0,
"jack_height": 0.0,
"jack_isFull": false,
"jack_load_times": 0,
"jack_mode": false,
"jack_speed": 0,
"jack_state": 0
},
"last_station": "CP2",
"lock_info": {
"desc": "",
"ip": "58.34.135.130",
"locked": true,
"nick_name": "DESKTOP-27FKEEM(0d50b)",
"port": 54733,
"time_t": "1634023715",
"type": 2
},
"notices": [],
"odo": 24.771,
"received_on": {
"data_nsec": "1110998989197957",
"frame_id": "",
"pub_nsec": "1110998989197957",
"seq": "0"
},
"reloc_status": 1,
"requestCurrent": -0.0,
"requestVoltage": -0.0,
"roller": {
"roller_emc": false,
"roller_enable": false,
"roller_error_code": 0,
"roller_isFull": false,
"roller_mode": false,
"roller_speed": 0,
"roller_state": 0
},
"soft_emc": false,
"steer": -0.0,
"time": 104303118,
"today_odo": 15.812,
"total_time": 444534615,
"voltage": 1.0,
"vx": -0.0,
"vy": -0.0,
"w": -0.0,
"warnings": [
{
"55001": 1634020734,
"desc": "The robot is in the dispatching state. If you need to control, please regain control and go offline during dispatching.",
"times": 1
}
],
"x": -0.3316,
"y": -1.4711
},
"undispatchable_reason": {
"current_map_invalid": false,
"disconnect": false,
"dispatchable_status": 0,
"low_battery": false,
"unconfirmed_reloc": false,
"unlock": 1
},
"uuid": "hu-test-1",
"vehicle_id": "AMB-01"
}
],
"scene_md5": "b481893504019cd71c03484f4b2419e1",
"warnings": []
}
```
当与调度断连时,本方法会返回 `None`
* 异常
本方法抛出异常。
### 查询所有机器人充电阈值
* 方法说明
获取所有机器人充电阈值信息。
```python
async def query_charge_param() -> str
```
* 输入参数
无。
* 输出参数
```json
[
{
"vehicle": "AMB-01",
"params": {
"chargeNeed": 40.0,
"chargeOnly": 30.0,
"chargedOK": 50.0,
"chargedFull": 90.0
}
},
{
"vehicle": "AMB-02",
"params": {
"chargeNeed": 50.0,
"chargeOnly": 20.0,
"chargedOK": 60.0,
"chargedFull": 80.0
}
}
]
```
当与调度断连时,本方法会返回 `None`
* 异常
本方法不抛出异常。
### 查询机器人充电阈值
* 方法说明
根据机器人名称获取机器人充电阈值信息。
```python
async def query_charge_param_by_vehicles(vehicles: str) -> str
```
* 输入参数
`vehicles`: JSON 格式的字符串(将数组转成字符串格式),查询指定数量的机器人充电阈值信息。
* 输出参数
```json
[
{
"vehicle": "AMB-01",
"params": {
"chargeNeed": 40.0,
"chargeOnly": 30.0,
"chargedOK": 50.0,
"chargedFull": 90.0
}
},
{
"vehicle": "AMB-02",
"params": {
"chargeNeed": 50.0,
"chargeOnly": 20.0,
"chargedOK": 60.0,
"chargedFull": 80.0
}
}
]
```
* 异常
本方法不抛出异常。
### 修改机器人充电阈值
* 方法说明
根据机器人名称修改机器人充电阈值信息。
```python
async def modify_charge_param(param: str) -> bool
```
* 输入参数
`param`: JSON 格式的字符串,包含要修改的机器人名称和对应的阈值。
* 输出参数
* `True`: 修改成功。
* `False`: 修改失败。
* 异常
本方法不抛出异常。
* 示例:
```python
def boot():
# 指定要修改的机器人名称,以及对应的阈值
req = {
"vehicles": ["sim_01"],
"params": {
"chargeNeed": 30
}
}
# 查询修改前的阈值信息
before = jj.query_charge_param_by_vehicles(json.dumps(["sim_01"]))
# 使用 modify_charge_param 修改阈值
data = jj.modify_charge_param(json.dumps(req))
# 查询修改后的阈值信息
after = jj.query_charge_param_by_vehicles(json.dumps(["sim_01"]))
# 打印结果
jj.script_log("info", "Charge", f"query = {before}")
jj.script_log("info", "Charge", f"modify = {data}")
jj.script_log("info", "Charge", f"query = {after}")
```
得到以下打印信息,表示修改 chargeNeed 参数成功:
![修改充电阈值](data:image/png;base64...)