Building a Subflow
A Subflow is edited exactly like a Flow — the same canvas, the same Add Item menu, the same concepts. What differs is how it starts, how it ends, and that it always runs on behalf of a caller.
Create a Subflow
- In the main Flow, add a Subflow Node.
- In its configuration, open the Subflow list and choose New Subflow at the top. The Subflow Editor opens over the Flow on a new Subflow with a Subflow Start Node. Or pick an existing Subflow and press the pencil.
- Name it in Subflow Name and save. Until then the Flow can't be saved ("Flow contains new and unsaved Subflow. Save it or choose an existing Subflow.").
You can also create a new Subflow from the View Selector: Subflow Editor → New Subflow.
To turn part of a Flow into a Subflow, select the Nodes and choose Move or copy to Subflow in the selection action menu, then Move to Subflow or Copy to Subflow. The Flow changes only once you save the new Subflow.
Entry point
A Subflow begins at its Subflow Start Node, which replaces the Start Node a Flow uses. There is one entry point, and it fires when the calling Subflow Node is reached.
Outputs
Every Subflow declares how many outputs it has, set with the Outputs selector in the run controls over the Subflow Editor's canvas. That number decides how many output connectors appear on the Subflow Node in the calling Flow.
Inside the Subflow, a Subflow Output Node decides which of those outputs the caller continues from. This is how a Subflow reports what happened, not just that it finished:
- A "pick part" Subflow might have output 1 for a successful pick and output 2 for an empty bin, letting the calling Flow branch without inspecting any Variable.
- A Subflow with a single output is the common case, and needs no Subflow Output Node at all.
If a Subflow ends without reaching a Subflow Output Node, Output 1 is triggered by default.
The caller waits
The Subflow Node does not trigger its output until the Subflow has finished. From the calling Flow's point of view, a Subflow is one blocking step — which is exactly what makes it readable as a single block.
No concurrency inside
A Flow can execute branches in parallel. A Subflow cannot: there is no concurrency inside a Subflow, and branches do not run at the same time.
If you need parallel execution, it has to live in the main Flow. Keep the parallel structure outside and call Subflows from each branch, rather than trying to fan out inside one.
Passing data in and out
A Subflow has no parameter list. Data crosses the boundary through Variables, which are global to the Robot and therefore visible to both the caller and the Subflow.
The consequence is worth being deliberate about: a Subflow used from several places writes to the same Variables every time. Two patterns keep that manageable:
- Agree on named slots. Give the Subflow dedicated input and output Variables —
pickSubflow_targetPose,pickSubflow_result— and have the caller set the inputs immediately before the Subflow Node. - Tag them. Put the Subflow's Variables under a shared tag so it is obvious which Variables belong to which Subflow.
Because Variables are global, a Subflow called from two branches of a parallel structure in the main Flow will have both callers writing the same Variables. Either serialize the calls, or give each branch its own set of Variables.