StateTick Docs Home →
Tutorial · Series

The FSM Planner

Every tutorial so far has built a part: interfaces, equipment, conditions, states. The FSM Planner is where those parts become a machine — a drawing of which state runs when, and what has to be true to move on. And you do not have to build the parts first. Sketch the machine with placeholders, then press Construct Composite and StateTick creates every state and condition you named.

We will build a small line: two motors that run in turn, with an Idle state waiting for a start command. Three states, three conditions, one loop — and we will draw all of it before a single state exists.

The canvas

Open FSM Planner at the bottom of the project tree. You get a grid, and a toolbar of things you can drop onto it:

The StateTick Studio window with the FSM Planner open: an empty grid canvas, a toolbar with Save, undo, redo, State, Composite, H, V and Exp buttons, and the project tree on the left
Where you are: FSM Planner, with an empty canvas.
The FSM Planner toolbar close up: Save, undo and redo, then State, Composite, H, V and Exp buttons
The palette. Composite and State are the two you need today.
ButtonWhat it drops
CompositeA machine box. Everything else lives inside one.
StateA state node inside the selected composite.
ExpAn expander — fans one wire out to up to four branches.
H / VA horizontal or vertical combiner — merges several wires into one target.

Step 1 — Drop a composite

Drag Composite onto the canvas. Because nothing is assigned to it yet, it is a placeholder: its name shows in square brackets and its border is dashed. Name it MotorLine.

Notice the small Init circle in the corner. It is created with the composite, it cannot be deleted, and it is where the machine starts on the first scan.

The FSM Planner canvas with one placeholder composite named MotorLine in square brackets, drawn with a dashed border, containing a small circular Init node
A placeholder composite. Brackets and a dashed border mean “nothing real behind this yet”.

Step 2 — Drop the states

Now drop three State nodes inside the composite and name them. These are placeholders too — there is still nothing on the States page:

  • Idle — waiting for the start command
  • MotorA_Run — first motor turning
  • MotorB_Run — second motor turning
The MotorLine placeholder composite containing three placeholder state boxes named Idle, MotorA_Run and MotorB_Run, each in square brackets with a dashed border
Three placeholder states. Naming them here is the only place you will type these names.

Step 3 — Wire them up

Drag from a port on the bottom edge of one state to a port on the top edge of the next. Each wire carries a condition — the guard that has to be true before the machine moves. And the condition can be a placeholder as well: just type the name you wish existed.

  • InitIdle on true — run this the moment the machine starts
  • IdleMotorA_Run on StartPressed
  • MotorA_RunMotorB_Run on MotorA_Done
  • MotorB_RunIdle on MotorB_Done
Close up of the wired placeholder machine: Init drops into Idle on a wire labelled true, and Idle drops into MotorA_Run on a wire labelled StartPressed, each wire carrying a blue numbered badge showing priority 1
Wires read top to bottom. The label on each one is its guard; the numbered badge is its priority.

The numbered badge on each wire is its priority, and the planner assigns it for you as you draw — the first wire out of a state gets 1, the next gets 2, and so on. Priority decides evaluation order: when several wires leave the same state, the lowest number is checked first, and the first guard that is true wins. Every state here has one way out, so every wire is priority 1. Double-click a badge to renumber it — that is how you make a fault path beat a normal one.

That last wire is the interesting one. MotorB_Run goes back up to Idle, and a wire that runs backwards cannot just be drawn through the middle of the diagram. The planner routes it out to a free lane at the side and brings it back in at the top — so the loop stays readable no matter how many states it has to pass:

The whole placeholder machine: Init, Idle, MotorA_Run and MotorB_Run stacked top to bottom with the MotorB_Done wire looping around the right-hand side and back into the top of Idle
The complete sketch. The loop back to Idle takes the side lane rather than cutting through the states.

Step 4 — Construct Composite

Everything so far is a drawing. Nothing exists on the States page, nothing exists on the Conditions page, and there is no composite in the Composite Composer. One command changes that.

Right-click the composite header and choose Construct Composite:

The right-click menu on the MotorLine composite header showing four items: Assign Composite, Construct Composite, Rename and Delete Composite
Right-click the header → Construct Composite.

StateTick reads every placeholder name off the canvas and builds the real thing:

  1. Creates generic states Idle, MotorA_Run, MotorB_Run.
  2. Creates generic conditions StartPressed, MotorA_Done, MotorB_Done.
  3. Creates the composite MotorLine.
  4. Adds an instance of each state and condition to that composite, already mapped to its template.
  5. Re-points every node and wire on the canvas at the real thing it just made.

None of this is mandatory — it is the automatic route. You can build the same machine by hand: create each state on Generic Composer → States and each condition on Conditions, then go to the Composite Composer, make the composite, and add an instance of every state and every condition mapped to its template. Only then do you open the planner, drop the composite in, drop the states in and pick a condition on each wire.

Same end result. The difference is when you have to decide. The manual route asks for every part before you can draw the machine; Construct Composite lets you design the logic first — names on a canvas, arrows between them — and fill in the details once the shape is settled.

The drawing barely changes — which is the point. The brackets disappear, the borders go solid, and the wire labels resolve to real condition instances:

The same machine after Construct Composite: the composite is named MotorLine without brackets, the states are Idle and MotorA_Run with solid borders, and the wire label now reads MotorLine_StartPressed
After constructing. [StartPressed] became the condition instance MotorLine_StartPressed.

Anything that already exists is reused, not duplicated. If a state called Idle is already on the States page, Construct Composite maps to it instead of making a second one. That is what makes it safe to run again later — on an assigned composite the same menu item becomes Add New Items, and it picks up only the placeholders you have added since.

Step 5 — See what it made

Go to Generic Composer → States. All three states are there, ready for you to fill in On Entry, Steps and On Exit actions:

The Generic Composer States page listing three new states Idle, MotorA_Run and MotorB_Run, each showing No actions, with the project tree on the left listing the same three states and three conditions
Three states created from the drawing — empty, and waiting for actions.

And on Conditions, the three guards you typed on the wires:

The Generic Composer Conditions page listing three new conditions MotorA_Done, MotorB_Done and StartPressed, each collapsed to just its name
Three conditions created from the wire labels, each holding a placeholder expression.

In the Composite Composer, MotorLine exists with every instance already mapped to its template:

The Composite Composer showing the MotorLine composite with counts of 3 Conditions and 3 States, and each instance listed mapped to the template of the same name
The composite, with 3 conditions and 3 states mapped instance → template.

Expand one and you will find a single placeholder term rather than a real test — enough to keep the project valid, and a marker for what you still owe it. Replacing that with an actual term is your job.

What is not filled in is deliberate: the states have no actions and the conditions have no real logic. Construct Composite builds the skeleton — the shape of the machine. Putting a motor behind MotorA_Run and a sensor behind MotorA_Done is the next job, and it is the same work the States and Conditions tutorials cover.

Step 6 — Save the plan

Press Save in the planner toolbar. That writes the transitions into the composite's FSM — the part the runtime actually executes. Until you save, the drawing is just a drawing.

The finished MotorLine machine in the FSM Planner after saving, showing the whole state machine with solid borders and real condition names on every wire
Saved. This is now a machine the runtime can run.

Why draw first

Both routes end in the same project, so the choice is about order. Building the parts first — every state, every condition, then the wiring — makes you commit to a structure before you can see it, and name each thing twice. Drawing first inverts that: you argue about the shape of the machine while it is still cheap to change, in front of people who do not use StateTick, and only then does anything get created.

It also means the drawing and the project cannot drift apart. The canvas is not documentation of the machine; it is the machine.

Try it in StateTick

Sketch your line on the canvas, press Construct Composite, and start filling in the parts.

Get Started →

See also