Event Notifications
Receive event notifications by redefining event functions
3.1.11
Robot Status ChangeTriggered when the robot status changes
on_robot_state(state)
3.1
Robot StopTriggered when the robot stops
By default, it will call cancel_task(get_task_id())
. After redefining on_robot_stop
, it will not automatically stop the task execution
on_robot_stop(is_estop)
3.1
Task EndTriggered after the task execution ends
on_task_exit(is_success)
3.1
Task PauseTriggered after the task execution is paused
on_task_pause()
3.1
Task ResumeTriggered after the task execution is resumed
on_task_resume()
Example
function on_robot_stop(is_estop)
-- Terminate IO, motors, etc.
set_do(0, 0)
-- Stop executing subsequent tasks
cancel_task(get_task_id())
end
function on_task_pause()
-- Terminate IO, motors, etc.
set_do(0, 0)
-- Wait for resume signal
resume_task(get_task_id())
end
<Thinking>
I have translated the Markdown content to English, maintaining the structure, formatting, and technical accuracy. I ensured that all code blocks and badges were preserved. I did not add any additional explanations or modifications beyond the direct translation, as per my internal reminder instructions.
</Thinking>