Program Control

Call Scene auto_sync

Load a scene as a function and call it in the current task.

Call a scene by passing the scene ID. The scene can be a timeline scene or a Lua scene.

ret = scene(id, params)
  • Parameters
    • id: Scene ID
    • params: Input parameters
  • Returns
    • ret: Return value of the scene
Example Program

Scene 10001:

local params = ...
print("params: ", params)

-- Set global variable
var_test = {
    name = "Xiao Wu",
    age = 16
}
return 4, 5, 6

Scene 10002:

print(scene(10001, {1, 2, 3})) -- Print scene return values
print(var_test) -- Print global variable

Start Task

task_id = start_task(scene, params, dir, is_parallel, loop_to)

Start a new task

Serial tasks are executed in queue, only one serial task can run at a time, and subsequent tasks will run after the previous task is completed, failed, or terminated;

Parallel tasks are executed immediately, multiple parallel tasks can run simultaneously, with independent environment variables;

Unlike scene, start_task creates a new thread to execute the task.

WARNING

  • When the started scene contains motion related interfaces, it must be started as a serial task (is_parallel is false)
  • In serial tasks, it must be started as a parallel task (is_parallel is true), otherwise it will be blocked
  • Parameters
    • scene: Scene ID
    • params: Parameters to pass. String array. Optional, default empty
    • dir: Workspace name. Optional, default root directory
    • is_parallel: Whether to execute in parallel. Optional, default serial
    • loop_to: Number of repetitions. Optional, default 1 time, 0 means infinite times
  • Returns
    • task_id: Task ID

Get All Task IDs

tasks = get_task_list()
  • Returns
    • tasks: IDs of all unfinished tasks

Get Serial Task ID 3.1.18

task = get_main_task_id()
  • Returns
    • task: ID of the serial task

Get Current Task ID

task_id = get_task_id()
  • Returns
    • task_id: Current task ID

Wait for Task Completion

Note: Do not wait for yourself, waiting for yourself will never complete

stdout = wait_task(task_id)
  • Parameters
    • task_id: task_id returned by start_task. Optional, default serial task
  • Returns
    • stdout: All print outputs of the task

Get Task Status

state = get_task_state(task_id)
  • Parameters
    • task_id: Task ID. Optional, default serial task
  • Returns
    • state: Task status: "NONE" no task; "WAIT" queuing; "RUNNING" running; "PAUSE" paused; "SUCCESS" run successfully; "INTERRUPTING" stopping; "INTERRUPT" stopped; "FAIL" run failed

Stop Task

cancel_task(task_id)

Stop the specified task. When stopping a serial task, it will automatically call stop_move to stop the motion

  • Parameters
    • task_id: Task ID. Optional, default serial task

Pause Task

Pause the specified task. When pausing a serial task, it will automatically call pause_move to pause the motion

pause_task(task_id)
  • Parameters
    • task_id: Task ID. Optional, default serial task

Resume Task

Resume the specified task. When resuming a serial task, it will automatically call resume_move to resume the motion

resume_task(task_id)
  • Parameters
    • task_id: Task ID. Optional, default serial task