Demo task orchestrator๏
Dispatch demo print and named-state motion tasks in sequence.
src.demos.hello_orchestrator_py.scripts.orchestrator_server ยท Source
Examples and demos ยท Guide ยท Symbol index
How it is used๏
The teaching orchestrator receives one demo JSON sequence, dispatches print or named-state move actions, and publishes progress between steps. Follow _execute() for sequencing and _dispatch_print() / _dispatch_move() for the child requests. ROS invokes the admission, cancellation, and execution callbacks.
Cancellation is checked between tasks. A child timeout fails the sequence without canceling that child. The implementation retains the default callback group and executor configuration; it is not the production EROBS orchestrator.
Start here๏
Callable |
Purpose |
|---|---|
Initialize ROS and the demo orchestrator, spin until interrupted and clean up in finally. |
|
Run demo print and move tasks in order, publish step feedback, and count completed tasks. Check cancellation between tasks; abort for a missing or unknown type or a failed child action. |
|
Require message, populate a PrintMessage goal and invoke the print client with a ten-second result deadline. |
|
Require target_pose, populate a MoveToNamedState goal and invoke the move client with a 60-second result deadline. |
Functions๏
main()๏
Initialize ROS and the demo orchestrator, spin until interrupted and clean up in finally.
Entry point ยท Source
main(args=None)
Parameter |
Meaning |
|---|---|
|
Optional ROS initialization arguments. |
Returns: None after spin ends.
Errors: KeyboardInterrupt during spin is swallowed; construction errors precede the cleanup try and can bypass it.
Side effects: Starts/spins/destroys the orchestrator node and ROS context.
OrchestratorServer๏
A ROS action node that interprets the demo task schema and sequences its print and motion child actions.
Inherits from: Node.
OrchestratorServer._execute()๏
Run demo print and move tasks in order, publish step feedback, and count completed tasks. Check cancellation between tasks; abort for a missing or unknown type or a failed child action.
Method ยท Source
_execute(self, goal_handle: ServerGoalHandle) -> OrchestratorTask.Result
Parameter |
Meaning |
|---|---|
|
Handle carrying request.task_json with tasks list of mappings. |
Returns: Result {success,completed_steps,error_message}; empty task list succeeds; cancellation/failure preserves completed count.
Errors: JSONDecodeError/missing tasks KeyError become aborted invalid-JSON result. Wrong JSON/task types, dispatch exceptions and callback failures are not caught. Cancellation after the final task can be missed because no final check runs.
Side effects: Executes child print/move actions, publishes feedback, logs and sets parent action terminal state.
Referenced in source (1)
OrchestratorServer._execute_callbackโ src.demos.hello_orchestrator_py.scripts.orchestrator_server
OrchestratorServer._dispatch_print()๏
Require message, populate a PrintMessage goal and invoke the print client with a ten-second result deadline.
Internal helper ยท Source
_dispatch_print(self, task: dict) -> bool
Parameter |
Meaning |
|---|---|
|
Mapping with message string; other keys are ignored. |
Returns: False for missing message, otherwise child action Boolean.
Errors: Message type/send/future errors propagate; missing field logs.
Side effects: Sends a logging task through print_message_py.
Referenced in source (1)
OrchestratorServer._executeโ src.demos.hello_orchestrator_py.scripts.orchestrator_server
OrchestratorServer._dispatch_move()๏
Require target_pose, populate a MoveToNamedState goal and invoke the move client with a 60-second result deadline.
Internal helper ยท Source
_dispatch_move(self, task: dict) -> bool
Parameter |
Meaning |
|---|---|
|
Mapping with target_pose SRDF named-state string. |
Returns: False for missing target_pose, otherwise child action Boolean.
Errors: Malformed goal/send/future errors propagate; missing field logs.
Side effects: May command robot movement through move_to_named_state_py.
Referenced in source (1)
OrchestratorServer._executeโ src.demos.hello_orchestrator_py.scripts.orchestrator_server
OrchestratorServer.__init__()๏
Create print/move clients and the orchestrator_task_py action server with busy-goal and cancellation callbacks.
Lifecycle ยท Source
__init__(self)
Errors: ROS initialization/client/server errors propagate.
Side effects: Creates orchestrator_server_py node and three action interfaces, then logs startup.
Referenced in source (1)
mainโ src.demos.hello_orchestrator_py.scripts.orchestrator_server
Internal callbacks and helpers๏
OrchestratorServer._goal_callback()๏
Accept goals only while _executing is false, without inspecting their JSON.
Callback ยท Source
_goal_callback(self, goal_request) -> GoalResponse
Parameter |
Meaning |
|---|---|
|
Incoming OrchestratorTask goal; unused. |
Returns: ACCEPT when idle, REJECT when busy.
Errors: No JSON validation at acceptance; flag is set later in execute callback.
Side effects: Logs busy rejection.
Referenced in source (1)
OrchestratorServer.__init__โ src.demos.hello_orchestrator_py.scripts.orchestrator_server
OrchestratorServer._cancel_callback()๏
Accept cancellation; execution will inspect it before dispatching the next task.
Callback ยท Source
_cancel_callback(self, goal_handle: ServerGoalHandle) -> CancelResponse
Parameter |
Meaning |
|---|---|
|
Current action goal handle; unused by this callback. |
Returns: CancelResponse.ACCEPT.
Errors: No local failure handling.
Side effects: No direct child cancellation or motion stop; returns acceptance only.
Referenced in source (1)
OrchestratorServer.__init__โ src.demos.hello_orchestrator_py.scripts.orchestrator_server
OrchestratorServer._execute_callback()๏
Wrap _execute with the busy flag and clear it in finally.
Callback ยท Source
_execute_callback(self, goal_handle: ServerGoalHandle)
Parameter |
Meaning |
|---|---|
|
Accepted OrchestratorTask server handle. |
Returns: OrchestratorTask.Result returned by _execute.
Errors: Exceptions propagate while _executing is still reset.
Side effects: Updates busy state and dispatches execution.
Referenced in source (1)
OrchestratorServer.__init__โ src.demos.hello_orchestrator_py.scripts.orchestrator_server
OrchestratorServer._call_action()๏
Wait five seconds for a child server, up to ten seconds for acceptance and timeout_sec for completion; expose the child payload success.
Internal helper ยท Source
_call_action(self, client, goal, timeout_sec: float=60.0) -> bool
Parameter |
Meaning |
|---|---|
|
ROS ActionClient for PrintMessage or MoveToNamedState. |
|
Matching generated child goal. |
|
Seconds to wait for child result, additional to discovery/acceptance waits. |
Returns: False for unavailable server, acceptance timeout/rejection or result timeout; otherwise child result.success.
Errors: Future/malformed-result errors propagate. A timed-out or late-accepted goal is not canceled, so child work may continue after False.
Side effects: Sends child action, synchronously spins ROS within the parent callback and logs failures.
Referenced in source (2)
OrchestratorServer._dispatch_moveโ src.demos.hello_orchestrator_py.scripts.orchestrator_serverOrchestratorServer._dispatch_printโ src.demos.hello_orchestrator_py.scripts.orchestrator_server