HTTP Services
WARNING
This feature will be deprecated
HTTP service requests and responses use the application/json
format with utf-8
encoding.
Response Parameter | Type | Description |
---|---|---|
code | int | Error code. 0 indicates success, where data format varies by request (see documentation below). Other values indicate failure (see Error Codes). |
params | string[] | Error parameters, returns different results based on error code. Generally no handling required. |
data | any | Returns interface-defined object on success. Check code before parsing data . |
Response example:
{
"code": 0,
"params": [],
"data": null
}
Run Scene or Task
- Request Method:
POST
- Request URL:
/public/task
Request Parameter | Type | Description |
---|---|---|
scene_id | int | Scene ID. Found in "Expert Mode" scene list card or browser URL after entering scene editor. |
execute_count | int | Loop count. 0 means infinite loop until explicitly stopped. |
clear | int | Whether to stop other running tasks and run new task. 0 means ignore if other tasks exist, 1 means force stop other tasks and run. Will run regardless of value if no other tasks are running. |
task_id | int | Default 0 means normal scene execution. If set to a task ID, re-executes that historical task record (scene_id is ignored). Task ID can be obtained from task list. |
Response Parameter | Type | Description |
---|---|---|
id | int | Task ID. Can be used to query task execution status. |
Request example: Execute scene 10001, infinite loop, force stop other running tasks.
curl --location --request POST 'http://10.20.17.1/public/task' \
--header 'Content-Type: application/json' \
--data-raw '{
"scene_id": 10001,
"execute_count": 0,
"clear": 1
}'
Response example: Scene added to task queue and started running, task ID is 10104.
{
"data": {
"id": 10104
},
"code": 0
}
Execute Lua Script
- Request Method:
POST
- Request URL:
/public/executor/lua
This interface executes raw Lua programs. Request body is Lua code instead of JSON format, set HTTP header Content-Type: text/plain
.
The interface call is asynchronous; completion status must be checked in Lua code, see Lua Socket service interface.
Using this interface doesn't require adding program_begin/program_end
at start/end, and supports querying execution status via task ID.
Request Parameter | Type | Description |
---|---|---|
name | string | Task name. Requires URLEncode() encoding. |
execute_count | int | Task execution count, 0 : loop execution, non-zero like 3 means execute 3 times |
clear | int | Whether to stop running task and run new task. 0 : no 1 : yes |
Response Parameter | Type | Description |
---|---|---|
id | int | Task ID. |
Request example: Execute Lua program named test_name
, loop once, don't execute if other tasks running.
curl --location --request POST 'http://10.20.17.1/public/executor/lua?name=test_name&execute_count=1&clear=0' \
--header 'Content-Type: text/plain' \
--data-raw 'local p = kinematics_inverse({12,12,1,2,1,1})
for k,v in ipairs(p) do
print(k,v)
end
print(p["ok"])
'
Response example: Task started executing, task ID is 10113.
{
"data": {
"id": 10113
},
"code": 0
}
Response example: Other tasks running, please stop current task in task history before retrying.
{
"data": null,
"code": 2036
}
Task Status and Details
- Request Method:
GET
- Request URL:
/public/task
Request Parameter | Type | Description |
---|---|---|
id | int | Task ID |
Response Parameter | Type | Description |
---|---|---|
id | int | Task ID |
scene_id | int | Scene ID |
execute_count | int | Execution count |
executed_count | int | Times executed |
name | int | Task name |
status | int | Task status. 0 : Idle 1 : Running 2 : Paused 3 : Success 4 : User stopped 5 : Error stopped 6 : Robot shutdown or DS stopped |
comment | string | Comment |
start_time | string | Task start time |
end_time | string | Task end time |
consume_time | int | Task duration excluding pause time, in seconds |
create_time | string | Creation time |
update_time | string | Update time |
Request example: Get task status and details for task ID 10104.
curl --location --request GET 'http://10.20.17.1/public/task?id=10104'
Response example:
{
"data": {
"id": 10104,
"scene_id": 10001,
"execute_count": 0,
"executed_count": 3777,
"name": "Home position",
"status": 6,
"comment": "",
"start_time": "2021-03-31T16:19:04.073161049+08:00",
"end_time": null,
"consume_time": 0
},
"code": 0
}
Task List
- Request Method:
GET
- Request URL:
/public/tasks
Request Parameter | Type | Description |
---|---|---|
pi | int | Page number. |
ps | int | Items per page. |
Request example: Get latest 10 executed tasks.
curl --location --request GET 'http://10.20.17.1/public/tasks?pi=1&ps=10'
Response example: Scene added to task queue and started running, task ID is 10104.
{
"data": {
"pi": 1,
"ps": 10,
"total": 112,
"records": [
{
"id": 10106,
"scene_id": 10001,
"execute_count": 0,
"executed_count": 1,
"name": "Home position",
"end_lua": null,
"lua_data": null,
"status": 5,
"comment": null,
"start_time": "2021-04-01T14:56:44.674861588+08:00",
"end_time": "2021-04-01T14:56:44.836186966+08:00",
"consume_time": 0,
"first_pose_json": null,
"mode": 0,
"trigger_way": null,
"is_deleted": null,
"create_time": "2021-04-01T14:56:44.675868104+08:00",
"update_time": "2021-04-01T14:56:44.880620629+08:00",
"scene_type": 3,
"first_pose": null
},
...
],
"task_status": 0,
"task_id": null
},
"code": 0
}
Execute Command
POST /public/robot/action
When calling motion commands, this interface won't wait for command completion before returning. Developers need to handle completion logic themselves. When calling get commands, it returns results in a specific format. See Command Documentation for details.
Request Parameter | Type | Description |
---|---|---|
cmd | string | Robot command |
data | object | Robot command parameters |
Request example:
curl --location --request POST 'http://10.20.17.1/public/robot/action' \
--header 'Content-Type: application/json' \
--data-raw '{
"cmd": "movej",
"data": {
"pose_to": [
0,
0,
0,
0,
0,
0
],
"is_joint_angle": true,
"acceleration": 1,
"velocity": 2
}
}'
Response example:
{
"data": {
"task_id": 1
},
"code": 0
}
get_task_status
Get current task
Response Result
Return Value | Type | Description |
---|---|---|
task_id | int | Task ID |
data.task_status | int | Task status 0: Idle 1: Running 2: Paused 3: Success 4: Failed |
{"cmd":"get_task_status"}
{"data":{"task_status":0,"task_id":null},"code":0}