Author a preset template

Write a parameterised preset other users can wizard

This how-to walks through writing a custom preset template — the kind of thing the From template wizard offers. The result is a fixo.json other users can pick from the wizard to spin up a preset for their own hardware. Good for shipping reusable patterns inside a personality, or sharing common rigs (a quadruped, a tank chassis, a six-axis arm) across robots.

Read the reference first

Preset Templates reference covers what the substitution language can and can't do. This how-to assumes you've skimmed it.


Plan before you write

  1. What's parameterised, what's fixed? The board, robot name, and a count parameter (legs, arms, axes) are typical. Pin numbers usually aren't — leave them unassigned and let the editor / pin allocator handle it.
  2. What stanza pattern? Pick or author a stanza template that matches the kinematics. Your preset template will reference it by name.
  3. Tag conventions? Decide upfront how you'll tag the actuators so the stanza template's auto-connect can find them.

Step 1: Duplicate-to-edit the closest built-in

In Fixo Studio → Preset Template Manager:

  1. Pick the built-in nearest to your goal — rc-car for two-wheeled, tracked-vehicle for tracked, hexapod for legged.
  2. Click Duplicate, rename to your kebab-case id (e.g. quadruped-walker).
  3. Open in the editor (currently inline JSON edit; the inline editor is fine for a first pass).

This gives you a known-good starting point that already has working parameter typing and a stanza-template reference.


Step 2: Edit the metadata

Top-level fields — same as any fixo.json:

{
  "fixoType": "preset-template",
  "name": "quadruped-walker",
  "title": "Quadruped walker",
  "description": "Four-legged walker with three joints per leg",
  "icon": "quadruped.svg",
  "builtin": false
}

Step 3: Declare your parameters

"parameters": {
  "board":    {"type": "board-type", "default": "arduino-mega2560"},
  "name":     {"type": "string"},
  "legCount": {"type": "int", "default": 4}
}

Type choices:

type Wizard widget Notes
"board-type" Board dropdown from FixoBoardTypeBook The wizard validates against known board types
"int" QSpinBox Defaults applied if missing; non-integer rejected
"string" QLineEdit No validation beyond non-empty

You can have any number of parameters. Keep the list short — every additional parameter is one more thing the user has to fill in.


Step 4: Write the base preset with placeholders

"preset": {
  "name":  "{{name}}",
  "board": "{{board}}",
  "actuators": [],
  "sensors":   [],
  "stanzas": [
    {"id": "walk", "lobeType": "template:hexapod-walk"}
  ]
}

{{paramName}} is substituted in any string field. lobeType: "template:..." references a FixoStanzaTemplate by name; the consumer expands it to a concrete FixoStanza with auto-connect.

If a placeholder is unresolved (no matching parameter), it's left intact — useful if you intend the consumer to fill it in. Don't over-use this; usually a typo is the cause.


Step 5: Add forEachActuators rules

For per-leg / per-joint patterns, write one rule per joint, all driven by the same countParameter:

"forEachActuators": [
  {
    "countParameter": "legCount",
    "pattern": {
      "type": "rc-servo",
      "name":         "leg_{{index}}_coxa",
      "semanticTags": ["leg_{{index}}", "coxa"]
    }
  },
  {
    "countParameter": "legCount",
    "pattern": {
      "type": "rc-servo",
      "name":         "leg_{{index}}_femur",
      "semanticTags": ["leg_{{index}}", "femur"]
    }
  },
  {
    "countParameter": "legCount",
    "pattern": {
      "type": "rc-servo",
      "name":         "leg_{{index}}_tibia",
      "semanticTags": ["leg_{{index}}", "tibia"]
    }
  }
]

With legCount = 4 you get 4 × 3 = 12 actuators. With legCount = 6 you get 18.

{{index}} substitutes 0…N-1 inside each rule; {{paramName}} from the parent parameters also works inside the pattern.

Arithmetic is not supported

If your robot's actuator count depends on multiple parameters, use a single int parameter for the total and let the user enter the right number. Don't try to write {{a * b}} — it'll be left as a literal string.


Step 6: Save and test

  1. Save in the editor. The Studio writes the JSON to <personality>/fixo/preset-templates/<id>/fixo.json and reloads FixoLibrary.
  2. Open Preset Manager → From template. Your new template should appear on Page 1.
  3. Pick it, fill in parameters with realistic values, Accept.
  4. Open the resulting preset in the editor. Verify:
    • Actuator count matches what you'd expect
    • Tags on each actuator match what your stanza template's auto-connect needs
    • The stanza references your stanza template
    • The board is set correctly
  5. Try Build to make sure the generated preset actually compiles. Fix any clang errors and iterate.

Step 7: Match against your stanza template's tags

If auto-connect fails (the stanza shows up with empty mapping), the most common cause is tag mismatch. Cross-check:

  • Your forEachActuators patterns produce semanticTags: ["leg_<i>", "joint_name"]
  • The referenced stanza template's expectedOutputs use the same tag conventions

If they disagree, fix one side. The stanza template's tags are the spec; your preset template should match them.


Step 8: Share the template (optional)

The whole <personality>/fixo/preset-templates/<id>/ folder is portable. Use Export in the manager to write a single JSON file (or zip the directory if there are extra resources). The destination's user Imports it; their wizard now lists your template alongside the built-ins.

See Share a preset between nodes.


See also

Topics
howto hardware fixo preset template author
See also