04 / Examples

Examples

Task files and what the tools say about them. Every output on this page was produced by the real robolang command, distribution 0.11.0.

These examples show how tasks are written, checked and simulated. Simulation is symbolic and nothing here runs on a robot. A task that validates, or succeeds in simulation, is not thereby safe to run on a robot.

Pick and place

This is examples/pick_and_place.rob from the core repository, unchanged. It declares five typed parameters, one safety annotation, two preconditions and a five-step plan.

examples/pick_and_place.rob
// examples/pick_and_place.rob
// Minimal example executed by the simple runtime.

task demo_pick_and_place(robot r, object box, location src, location dst, region cell) {
    @safety max_speed 0.5;

    pre {
        robot_ready r;
        region_clear cell;
    }

    plan {
        move r to src;
        grasp r box;
        move r to dst;
        place r box at dst;
        communicate r to "fleet" with "TASK_COMPLETE";
    }
}

Validate

robolang validate examples/pick_and_place.rob
Output (exit status 0)
examples/pick_and_place.rob:5:23: warning[W401]: 'max_speed' has no unit; write 'm/s' or 'rad/s'. A unitless limit is deprecated and is never treated as an enforced limit
examples/pick_and_place.rob: valid RoboLang 1.1 (1 task, 1 warning)
Validation covers the text of the program only. It does not make a task safe to run on a robot.

The file is valid, with one warning. W401 points at line 5, column 23: the max_speed limit has no unit. A unitless limit is deprecated in language 1.1 to 2.4 and, as the message says, is never treated as an enforced limit. The example is kept as it is so that files written for the earlier version of RoboLang stay valid.

Inspect

robolang inspect examples/pick_and_place.rob
Output
examples/pick_and_place.rob:5:23: warning[W401]: 'max_speed' has no unit; write 'm/s' or 'rad/s'. A unitless limit is deprecated and is never treated as an enforced limit
examples/pick_and_place.rob
RoboLang 1.1 | IR schema 1.0 | 1 task

task demo_pick_and_place
  parameters:
    robot r
    object box
    location src
    location dst
    region cell
  safety:
    max_speed 0.5  (no unit: deprecated; declared only, never treated as an enforced limit)
  preconditions:
    robot_ready r
    region_clear cell
  plan:
    1. move r to src
    2. grasp r box
    3. move r to dst
    4. place r box at dst
    5. communicate r to "fleet" with "TASK_COMPLETE"

This is a description only. Nothing was executed.

Inspect as JSON IR

robolang inspect examples/pick_and_place.rob --json
Output (line breaks condensed for display)
{
  "ir_schema": "robolang.task-ir",
  "ir_schema_version": "1.0",
  "language_version": "1.1",
  "tasks": [
    {
      "name": "demo_pick_and_place",
      "parameters": [
        { "name": "r", "type": "robot" },
        { "name": "box", "type": "object" },
        { "name": "src", "type": "location" },
        { "name": "dst", "type": "location" },
        { "name": "cell", "type": "region" }
      ],
      "safety": [
        { "kind": "max_speed", "limit": { "value": "0.5", "unit": null } }
      ],
      "preconditions": [
        { "kind": "robot_ready", "robot": "r" },
        { "kind": "region_clear", "region": "cell" }
      ],
      "steps": [
        { "kind": "move", "robot": "r", "target": "src" },
        { "kind": "grasp", "robot": "r", "object": "box" },
        { "kind": "move", "robot": "r", "target": "dst" },
        { "kind": "place", "robot": "r", "object": "box", "target": "dst" },
        { "kind": "communicate", "robot": "r", "channel": "fleet", "message": "TASK_COMPLETE" }
      ]
    }
  ]
}

The intermediate representation names its schema and version, so a consuming program can check what it has been given. Notice that the unitless limit appears with "unit": null and that the number is kept as the text "0.5". The fields are defined in the IR schema specification.

Simulate

The same file, run against the world file base.json from the core repository. It binds r to a ready robot arm1 and declares the region cell clear.

robolang simulate examples/pick_and_place.rob --world tests/fixtures/simulation/worlds/base.json
Standard error (exit status 0)
examples/pick_and_place.rob:5:23: warning[W401]: 'max_speed' has no unit; write 'm/s' or 'rad/s'. A unitless limit is deprecated and is never treated as an enforced limit
simulation only: run sim-74e8880dc9812881e439341b29b04ee31e11ba6839023b4ac26431d42ed26b09: SUCCEEDED
Standard output: selected fields of the run record, line breaks condensed
{
  "run_record_schema": "robolang.sim.run",
  "run_record_schema_version": "1.0",
  "mode": "simulation",
  "run_id": "sim-74e8880dc9812881e439341b29b04ee31e11ba6839023b4ac26431d42ed26b09",
  "states": ["CREATED", "VALIDATED", "AUTHORIZED", "RUNNING", "SUCCEEDED"],
  "state": "SUCCEEDED",
  "failure": null,
  "safety_limits": [
    {
      "limit": {
        "kind": "max_speed",
        "limit": {
          "value": "0.5",
          "unit": null
        }
      },
      "status": "unit_unspecified_not_enforced"
    }
  ],
  "preconditions": [
    { "index": 1, "condition": { "kind": "robot_ready", "robot": "r" }, "result": "true" },
    { "index": 2, "condition": { "kind": "region_clear", "region": "cell" }, "result": "true" }
  ]
}

The record shows each executor state in order. The unitless speed limit is reported as unit_unspecified_not_enforced: checked, recorded and never enforced. The full record also lists every step and the final world; its fields are defined in the simulation specification.

A run that fails closed

With not_ready.json, the robot is not ready. The first precondition is false, so the run stops before any step.

robolang simulate examples/pick_and_place.rob --world tests/fixtures/simulation/worlds/not_ready.json
Standard error (exit status 4)
examples/pick_and_place.rob:5:23: warning[W401]: 'max_speed' has no unit; write 'm/s' or 'rad/s'. A unitless limit is deprecated and is never treated as an enforced limit
simulation only: run sim-78c53744434b0be82fc1836b772eab433cb1f0b1aafe2d8ff7f49a67eb7deabe: FAILED (S101): a pre condition is false
Standard output: selected fields of the run record, line breaks condensed
{
  "states": ["CREATED", "VALIDATED", "AUTHORIZED", "RUNNING", "FAILED"],
  "state": "FAILED",
  "failure": {
    "code": "S101",
    "phase": "precondition",
    "step": null,
    "precondition": 1,
    "safety_limit": null,
    "robot": null
  },
  "preconditions": [
    { "index": 1, "condition": { "kind": "robot_ready", "robot": "r" }, "result": "false" },
    { "index": 2, "condition": { "kind": "region_clear", "region": "cell" }, "result": "true" }
  ]
}

Inspection with a wait

This example was written for this page. It starts with the optional version marker, gives the speed limit a unit, and uses the remaining statement and condition forms: inspect, both kinds of wait, object_exists and sensor_ok.

inspect_part.rob
robolang 1.1;

task inspect_part(robot r, object part, location station, region cell) {
    @safety max_speed 0.25 m/s;

    pre {
        robot_ready r;
        object_exists part;
        sensor_ok "wrist_camera";
    }

    plan {
        move r to station;
        wait until region_clear cell timeout 10 s;
        inspect r part using "wrist_camera";
        wait for 500 ms;
        communicate r to "fleet" with "INSPECTION_DONE";
    }
}
robolang validate inspect_part.rob
Output (exit status 0)
inspect_part.rob: valid RoboLang 1.1 (1 task)
Validation covers the text of the program only. It does not make a task safe to run on a robot.

With a unit on the limit there is no warning.

robolang inspect inspect_part.rob
Output
inspect_part.rob
RoboLang 1.1 | IR schema 1.0 | 1 task

task inspect_part
  parameters:
    robot r
    object part
    location station
    region cell
  safety:
    max_speed 0.25 m/s  (declared only; not enforced by this tool)
  preconditions:
    robot_ready r
    object_exists part
    sensor_ok "wrist_camera"
  plan:
    1. move r to station
    2. wait until region_clear cell timeout 10 s
    3. inspect r part using "wrist_camera"
    4. wait for 500 ms
    5. communicate r to "fleet" with "INSPECTION_DONE"

This is a description only. Nothing was executed.

The tool states that the limit is "declared only; not enforced by this tool". That is the accurate reading of every @safety annotation today.

Combined conditions (language 1.2)

This is pre_or.rob from the core repository's tests, unchanged. The marker robolang 1.2; makes it a 1.2 file, and its precondition holds if either region is clear.

tests/fixtures/v1.2/simulation/sources/pre_or.rob
// LANG-1 simulation fixture (spec/robolang-v1.2.md section 8)
robolang 1.2;

task pre_or(robot r, location dst, region left, region right) {
    pre {
        region_clear left or region_clear right;
    }
    plan {
        move r to dst;
    }
}
robolang validate tests/fixtures/v1.2/simulation/sources/pre_or.rob
Output (exit status 0)
tests/fixtures/v1.2/simulation/sources/pre_or.rob: valid RoboLang 1.2 (1 task)
Validation covers the text of the program only. It does not make a task safe to run on a robot.
robolang inspect tests/fixtures/v1.2/simulation/sources/pre_or.rob
Output (exit status 0)
tests/fixtures/v1.2/simulation/sources/pre_or.rob
RoboLang 1.2 | IR schema 1.1 | 1 task

task pre_or
  parameters:
    robot r
    location dst
    region left
    region right
  safety: (none)
  preconditions:
    region_clear left or region_clear right
  plan:
    1. move r to dst

This is a description only. Nothing was executed.

inspect shows a combined condition in source form. A group inside another operator is shown in parentheses, because and and or are never mixed without them.

robolang inspect tests/fixtures/v1.2/simulation/sources/pre_or.rob --json
Output (line breaks condensed for display)
{
  "ir_schema": "robolang.task-ir",
  "ir_schema_version": "1.1",
  "language_version": "1.2",
  "tasks": [
    {
      "name": "pre_or",
      "parameters": [
        { "name": "r", "type": "robot" },
        { "name": "dst", "type": "location" },
        { "name": "left", "type": "region" },
        { "name": "right", "type": "region" }
      ],
      "safety": [],
      "preconditions": [
        {
          "kind": "or",
          "conditions": [
            { "kind": "region_clear", "region": "left" },
            { "kind": "region_clear", "region": "right" }
          ]
        }
      ],
      "steps": [
        { "kind": "move", "robot": "r", "target": "dst" }
      ]
    }
  ]
}

A 1.2 source produces IR schema 1.1, where a combined condition is a node with a kind of and, or or not. The fields are defined in the IR schema 1.1 specification.

robolang simulate tests/fixtures/v1.2/simulation/sources/pre_or.rob --world tests/fixtures/v1.2/simulation/worlds/base.json
Standard error (exit status 0)
simulation only: run sim-467161b758ec973f543a2289fd0cd8b9cd1d9ba55de29a7b8bb27616fd6fd227: SUCCEEDED
Standard output: selected fields of the run record, line breaks condensed
{
  "run_record_schema_version": "1.1",
  "state": "SUCCEEDED",
  "preconditions": [
    {
      "index": 1,
      "condition": {
        "kind": "or",
        "conditions": [
          { "kind": "region_clear", "region": "left" },
          { "kind": "region_clear", "region": "right" }
        ]
      },
      "result": "true"
    }
  ]
}

Goals decide success (language 1.3)

This is examples/handover.rob from the core repository, unchanged. The goal block says what must be true when the task is done; the plan is only the way there.

examples/handover.rob
// examples/handover.rob
// An arm places a box at a handoff point; a mobile robot picks it up once the zone is clear.
robolang 1.3;

task handover(robot arm, robot mobile, object box, location src, location handoff, location dst, region zone) {
    @safety max_speed 0.5 m/s;

    pre {
        robot_ready arm;
        robot_ready mobile;
        object_exists box;
    }

    goal {
        object_at box dst;
    }

    plan {
        move arm to src;
        grasp arm box;
        move arm to handoff;
        place arm box at handoff;
        communicate arm to "fleet" with "BOX_AT_HANDOFF";
        wait until region_clear zone timeout 30s;
        move mobile to handoff;
        grasp mobile box;
        move mobile to dst;
        place mobile box at dst;
    }
}
robolang validate examples/handover.rob
Output (exit status 0)
examples/handover.rob: valid RoboLang 1.3 (1 task)
Validation covers the text of the program only. It does not make a task safe to run on a robot.

Its parameters are bound in examples/world.json, where the handoff zone becomes clear after 5 seconds.

robolang simulate examples/handover.rob --world examples/world.json
Standard error (exit status 0)
simulation only: run sim-70f08163c77bb0d98b645068d07b66f7c501d3d30d82ab2b7ba8b2ed059f4fd0: SUCCEEDED
Standard output: selected fields of the run record
{
  "run_record_schema_version": "1.2",
  "state": "SUCCEEDED",
  "goal": [
    {
      "index": 1,
      "condition": {
        "kind": "object_at",
        "object": "box",
        "location": "dst"
      },
      "result": "true"
    }
  ]
}

Every 1.3 run record ends with core_outcome: the same verdict as a Core 0.1 outcome (Core 0.2 with --core 0.2), citing signed observations of the final world as its evidence.

Standard output: the outcome in core_outcome, evidence list omitted
{
  "core_outcome": {
    "outcome": {
      "kind": "outcome",
      "goal": "rl:goal:handover",
      "status": "succeeded",
      "verification": {
        "verified_by": "rl:sim:world",
        "method": "criteria_evaluated",
        "evaluated_at": "2000-01-01T00:00:05.000Z",
        "criteria_results": [
          {
            "criterion": 0,
            "met": true,
            "evidence": [
              "rl:obs:70f08163c77bb0d9-0"
            ]
          }
        ]
      },
      "reasons": [],
      "reported_by": "rl:sim:world",
      "reported_at": "2000-01-01T00:00:05.000Z"
    }
  }
}

Every step succeeds, the goal does not

This example was written for this page. The goal asks for the box at dst and the robot back at src, but the plan never returns.

deliver_and_return.rob
robolang 1.3;

task deliver_and_return(robot r, object box, location src, location dst) {
    goal {
        object_at box dst;
        robot_at r src;
    }

    plan {
        move r to src;
        grasp r box;
        move r to dst;
        place r box at dst;
    }
}
robolang simulate deliver_and_return.rob --world examples/world.json --bind r=arm1 box=box1 src=shelf dst=table
Standard error (exit status 4)
simulation only: run sim-79d4afd717627f5e80666bd171fb0795211f59bf47b5dc6a0f021c9173839342: FAILED (S301): a goal condition is false after the last step
Standard output: selected fields of the run record, each step cut down to its index and status
{
  "state": "FAILED",
  "failure": {
    "code": "S301",
    "phase": "goal",
    "step": null,
    "precondition": null,
    "safety_limit": null,
    "robot": null
  },
  "steps": [
    {
      "index": 1,
      "status": "succeeded"
    },
    {
      "index": 2,
      "status": "succeeded"
    },
    {
      "index": 3,
      "status": "succeeded"
    },
    {
      "index": 4,
      "status": "succeeded"
    }
  ],
  "goal": [
    {
      "index": 1,
      "condition": {
        "kind": "object_at",
        "object": "box",
        "location": "dst"
      },
      "result": "true"
    },
    {
      "index": 2,
      "condition": {
        "kind": "robot_at",
        "robot": "r",
        "location": "src"
      },
      "result": "false"
    }
  ]
}

All four steps succeeded, yet the run is FAILED with S301: a goal condition is false in the final world. An unknown goal condition fails the run too, with S302.

Branching (language 1.4)

This is branch_route.rob from the core repository's tests, unchanged. Each branch carries its own goal, the task goal applies to every path, and the last branch reports and stops with fail.

tests/fixtures/v1.4/valid/branch_route.rob
// RoboLang v1.4 fixture: valid
// expect: ok
// why: an if with branch goals, an else if, and a common task goal

robolang 1.4;

task route(robot r, object box, location src, location a, location b, region cell) {
    goal { not holding r box; }
    plan {
        move r to src;
        grasp r box;
        if region_clear cell {
            goal { object_at box a; }
            move r to a;
            place r box at a;
        } else if robot_ready r {
            goal { object_at box b; }
            move r to b;
            place r box at b;
        } else {
            communicate r to "ops" with "no route";
            fail "no route";
        }
    }
}
robolang inspect tests/fixtures/v1.4/valid/branch_route.rob
Output (exit status 0)
tests/fixtures/v1.4/valid/branch_route.rob
RoboLang 1.4 | IR schema 1.3 | 1 task

task route
  parameters:
    robot r
    object box
    location src
    location a
    location b
    region cell
  safety: (none)
  preconditions: (none)
  goal:
    not holding r box
  plan:
    1. move r to src
    2. grasp r box
    3. if region_clear cell
      then:
        goal: object_at box a
        3.1. move r to a
        3.2. place r box at a
      else:
        3.1. if robot_ready r
          then:
            goal: object_at box b
            3.1.1. move r to b
            3.1.2. place r box at b
          else:
            3.1.1. communicate r to "ops" with "no route"
            3.1.2. fail "no route"

This is a description only. Nothing was executed.

Run against examples/world.json with the region bound on the command line. With cell, which is clear, the first branch runs:

robolang simulate tests/fixtures/v1.4/valid/branch_route.rob --world examples/world.json --bind r=arm1 box=box1 src=shelf a=table b=handoff cell=cell
Standard error (exit status 0)
simulation only: run sim-6f87ff2ca0beb961a47c6de6dff6014299ed0825e9ddbe9b05155cd555a5d66a: SUCCEEDED
Standard output: selected fields of the run record
{
  "run_record_schema_version": "1.3",
  "state": "SUCCEEDED",
  "decisions": [
    {
      "step": "3",
      "condition_result": "true",
      "branch": "then",
      "t_ms": "0"
    }
  ],
  "goal": [
    {
      "index": 1,
      "from": "task",
      "condition": {
        "kind": "not",
        "condition": {
          "kind": "holding",
          "robot": "r",
          "object": "box"
        }
      },
      "result": "true"
    },
    {
      "index": 2,
      "from": "3.then",
      "condition": {
        "kind": "object_at",
        "object": "box",
        "location": "a"
      },
      "result": "true"
    }
  ]
}

With handoff_zone, which is not clear at the start, the run takes the else if branch and checks that branch's goal instead:

robolang simulate tests/fixtures/v1.4/valid/branch_route.rob --world examples/world.json --bind r=arm1 box=box1 src=shelf a=table b=handoff cell=handoff_zone
Standard error (exit status 0)
simulation only: run sim-fa2103f352cfdd010a6b7f27fda6b47c920e5cacaf5d98f5923394cf08bbda76: SUCCEEDED
Standard output: selected fields of the run record
{
  "run_record_schema_version": "1.3",
  "state": "SUCCEEDED",
  "decisions": [
    {
      "step": "3",
      "condition_result": "false",
      "branch": "else",
      "t_ms": "0"
    },
    {
      "step": "3.else.1",
      "condition_result": "true",
      "branch": "then",
      "t_ms": "0"
    }
  ],
  "goal": [
    {
      "index": 1,
      "from": "task",
      "condition": {
        "kind": "not",
        "condition": {
          "kind": "holding",
          "robot": "r",
          "object": "box"
        }
      },
      "result": "true"
    },
    {
      "index": 2,
      "from": "3.else.1.then",
      "condition": {
        "kind": "object_at",
        "object": "box",
        "location": "b"
      },
      "result": "true"
    }
  ]
}

The record lists every decision with the condition's result. A condition that is unknown fails the run with S261, and fail ends it with S262. The rules are in the language 1.4 specification.

Failure handlers (language 1.5)

This is retry_grasp.rob from the core repository's tests, unchanged. A step can carry its own else block, which runs only when that step fails.

tests/fixtures/v1.5/valid/retry_grasp.rob
// RoboLang v1.5 fixture: valid
// expect: ok
// why: a failed grasp is retried once by its handler (decision 0033 F5)

robolang 1.5;

task pick(robot r, object box, location src, location dst) {
    goal { object_at box dst; }
    plan {
        move r to src;
        grasp r box else {
            grasp r box;
        }
        move r to dst;
        place r box at dst;
    }
}

To see the handler run, this world file, written for this page, makes step 2 (the first grasp) fail once with a scripted fault:

retry_world.json
{
  "world_schema": "robolang.sim.world",
  "world_schema_version": "1.1",
  "locations": ["shelf", "table"],
  "robots": {
    "arm1": { "ready": true, "location": "shelf", "gripper": true, "max_speed": [{ "value": "1", "unit": "m/s" }] }
  },
  "objects": {
    "box1": { "present": true, "location": "shelf" }
  },
  "tasks": {
    "pick": {
      "bindings": { "r": "arm1", "box": "box1", "src": "shelf", "dst": "table" },
      "faults": [{ "step": 2 }]
    }
  }
}
robolang simulate tests/fixtures/v1.5/valid/retry_grasp.rob --world retry_world.json
Standard error (exit status 0)
simulation only: run sim-391b3bf811058aaadc2058dd3744d8853e4da57005eb1e00e3af526eddb9ec81: SUCCEEDED
Standard output: selected fields of the run record, each step cut down to its index, path, status and handled
{
  "run_record_schema_version": "1.4",
  "state": "SUCCEEDED",
  "steps": [
    {
      "index": 1,
      "path": "1",
      "status": "succeeded",
      "handled": null
    },
    {
      "index": 2,
      "path": "2",
      "status": "failed",
      "handled": "S251"
    },
    {
      "index": 3,
      "path": "2.else.1",
      "status": "succeeded",
      "handled": null
    },
    {
      "index": 4,
      "path": "3",
      "status": "succeeded",
      "handled": null
    },
    {
      "index": 5,
      "path": "4",
      "status": "succeeded",
      "handled": null
    }
  ]
}

The first grasp failed with S251 and was handled, the retry at path 2.else.1 succeeded, and the run still succeeds only because the goal holds. The rules are in the language 1.5 specification.

What 1.6 to 1.9 add

Each of these files is from the core repository's tests, unchanged, and validates as shown. A file uses a newer feature only with that version's marker; older files keep their meaning.

Measured values (1.6)

measure reads a typed value with a unit, binds it to a name and compares it in a condition. A reading near a threshold is unknown and fails closed.

tests/fixtures/v1.6/valid/weigh_and_compare.rob
// RoboLang v1.6 fixture: valid
// expect: ok
// why: units convert within a kind; a binding is compared with a literal and with another binding (V5, V6, V7)

robolang 1.6;

task weigh_and_compare(robot r, object a, object b, sensor scale, location bench) {
    goal { robot_at r bench; }
    plan {
        move r to bench;
        measure r mass of a using scale as ma;
        measure r mass of b using scale as mb;
        if ma > 1.2 kg and ma < 2000 g and not mb >= ma {
            communicate r to "ops" with ma;
        } else {
            fail "unexpected weights";
        }
    }
}
Output of robolang validate (exit status 0)
tests/fixtures/v1.6/valid/weigh_and_compare.rob: valid RoboLang 1.6 (1 task)
Validation covers the text of the program only. It does not make a task safe to run on a robot.

Region limits (1.7)

@safety no_go_region and in_region are requests: checked against the world and recorded, never enforced by RoboLang. Keeping a robot out of a region is the job of its motion planner and safety controller.

tests/fixtures/v1.7/valid/keep_out_of_wet_floor.rob
// RoboLang v1.7 fixture: valid
// expect: ok
// why: a no_go_region on a region parameter, for the whole task (P1, P2)

robolang 1.7;

task to_lobby(robot r, location lobby, region wet) {
    @safety no_go_region wet;
    goal { robot_at r lobby; }
    plan { move r to lobby; }
}
Output of robolang validate (exit status 0)
tests/fixtures/v1.7/valid/keep_out_of_wet_floor.rob: valid RoboLang 1.7 (1 task)
Validation covers the text of the program only. It does not make a task safe to run on a robot.

Declared actions (1.8)

do asks for an action that the robot's profile declares, beyond the built-in steps. A new action needs a profile entry, never a new keyword. The goal verifies the result with in_state.

tests/fixtures/v1.8/valid/open_then_fetch.rob
// RoboLang v1.8 fixture: valid
// expect: ok
// why: a do on an object, then plain steps; the goal verifies the state with in_state

robolang 1.8;

task restock(robot r, object closet, object kit, location ward) {
    goal { in_state closet "open"; object_at kit ward; }
    plan {
        do r open closet;
        grasp r kit;
        move r to ward;
        place r kit at ward;
    }
}
Output of robolang validate (exit status 0)
tests/fixtures/v1.8/valid/open_then_fetch.rob: valid RoboLang 1.8 (1 task)
Validation covers the text of the program only. It does not make a task safe to run on a robot.

Clock readings (1.9)

measure r time reads the local time of day, like any other value, and a time such as 21:30 can be compared in a condition.

tests/fixtures/v1.9/valid/shift_cutoff.rob
// RoboLang v1.9 fixture: valid
// expect: ok
// why: a cutoff with if: a time binding against a time literal (T3)

robolang 1.9;

task shift_cutoff(robot r, object tote, location inb, location outb) {
    plan {
        measure r time as now;
        if now < 21:30 {
            goal { object_at tote outb; }
            move r to inb;
            grasp r tote;
            move r to outb;
            place r tote at outb;
        } else {
            communicate r to "lead" with "after cutoff";
            fail "the shift has ended";
        }
    }
}
Output of robolang validate (exit status 0)
tests/fixtures/v1.9/valid/shift_cutoff.rob: valid RoboLang 1.9 (1 task)
Validation covers the text of the program only. It does not make a task safe to run on a robot.

The specifications: 1.6, 1.7, 1.8 and 1.9.

Missions (language 2.0)

A mission repeats bounded, verified task runs. It always has a hard bound, here 30 runs, and every run is a complete task run with its own goal check. This is shuttle_rounds.rob, unchanged.

tests/fixtures/v2.0/valid/shuttle_rounds.rob
// RoboLang v2.0 fixture: valid
// expect: ok
// why: a count bound, the default policy (stop)

robolang 2.0;

task round(robot r, location home, location far) {
    goal { robot_at r home; }
    plan { move r to far; wait for 5 s; move r to home; }
}

mission shuttle(robot r, location home, location far) {
    repeat at most 30 runs {
        run round(r, home, far);
    };
}
robolang simulate tests/fixtures/v2.0/valid/shuttle_rounds.rob --mission shuttle --world examples/world.json --bind r=arm1 home=shelf far=table
Standard error (exit status 0)
simulation only: mission run sim-49a3f4235401b3c35e03d314ad8be1e933f523bd97a240a019518d14d0c4ab51: bounded (run_bound; 30 task runs, 30 verified)
Standard output: selected fields of the mission record
{
  "mission_record_schema_version": "1.0",
  "outcome": "bounded",
  "ended_by": "run_bound",
  "failure": null,
  "runs_started": 30,
  "runs_verified": 30,
  "runs_failed": 0,
  "end_t_ms": "150000"
}

The mission ended bounded: it reached its bound of 30 runs, and all 30 verified their goal. A failed run stops the mission unless it says continue or retry N. The rules are in the language 2.0 specification and the Mission IR.

Incoming messages (language 2.1)

message_received waits for, or checks, a message on a channel. Here it ends a mission. This is mission_until_a_message.rob, unchanged.

tests/fixtures/v2.1/valid/mission_until_a_message.rob
// RoboLang v2.1 fixture: valid
// expect: ok
// why: a mission's until takes a message condition (S1, S2)

robolang 2.1;

task round(robot r, location home, location far) {
    goal { robot_at r home; }
    plan { move r to far; wait for 5 s; move r to home; }
}

mission shift(robot r, location home, location far) {
    repeat at most 12 runs {
        run round(r, home, far);
    } until message_received "ops" with "SHIFT END";
}

Which senders a channel trusts is the world's configuration, never the task's. This world file, written for this page, declares one channel and delivers SHIFT END at 32 seconds:

shift_world.json
{
  "world_schema": "robolang.sim.world",
  "world_schema_version": "1.6",
  "locations": [
    "home",
    "far"
  ],
  "robots": {
    "amr1": {
      "ready": true,
      "location": "home",
      "gripper": false,
      "max_speed": [
        {
          "value": "1",
          "unit": "m/s"
        }
      ]
    }
  },
  "channels": {
    "ops": {
      "from": [
        "rl:agent:ops"
      ]
    }
  },
  "messages": [
    {
      "at": {
        "value": "32",
        "unit": "s"
      },
      "channel": "ops",
      "text": "SHIFT END",
      "from": "rl:agent:ops"
    }
  ],
  "tasks": {}
}
robolang simulate tests/fixtures/v2.1/valid/mission_until_a_message.rob --mission shift --world shift_world.json --bind r=amr1 home=home far=far
Standard error (exit status 0)
simulation only: mission run sim-b5a6bd55c5797926d6eb582e98a1a300e7e20023d0d78b52bdc209056c0118bc: completed (until; 7 task runs, 7 verified)
Standard output: selected fields of the mission record, each run cut down to its index, times, state and until
{
  "mission_record_schema_version": "1.1",
  "outcome": "completed",
  "ended_by": "until",
  "failure": null,
  "runs_started": 7,
  "runs_verified": 7,
  "end_t_ms": "35000",
  "messages": [
    {
      "t_ms": "32000",
      "channel": "ops",
      "text": "SHIFT END",
      "from": "rl:agent:ops",
      "status": "accepted"
    }
  ],
  "runs": [
    {
      "index": 1,
      "t_start_ms": "0",
      "t_end_ms": "5000",
      "state": "SUCCEEDED",
      "until": "false"
    },
    {
      "index": 2,
      "t_start_ms": "5000",
      "t_end_ms": "10000",
      "state": "SUCCEEDED",
      "until": "false"
    },
    {
      "index": 3,
      "t_start_ms": "10000",
      "t_end_ms": "15000",
      "state": "SUCCEEDED",
      "until": "false"
    },
    {
      "index": 4,
      "t_start_ms": "15000",
      "t_end_ms": "20000",
      "state": "SUCCEEDED",
      "until": "false"
    },
    {
      "index": 5,
      "t_start_ms": "20000",
      "t_end_ms": "25000",
      "state": "SUCCEEDED",
      "until": "false"
    },
    {
      "index": 6,
      "t_start_ms": "25000",
      "t_end_ms": "30000",
      "state": "SUCCEEDED",
      "until": "false"
    },
    {
      "index": 7,
      "t_start_ms": "30000",
      "t_end_ms": "35000",
      "state": "SUCCEEDED",
      "until": "true"
    }
  ]
}

The message arrived during run 7, so until became true after that run and the mission ended completed, well before its bound of 12. A world with no channels has no message service: there, message_received is unknown and fails closed. The rules are in the language 2.1 specification.

More kinds, choosing and the robot's own charge (2.2 to 2.4)

One file for each version, from the core repository's tests, unchanged. Each validates as shown and runs in the symbolic simulator against a world file written for this page. The run records are cut down to the fields that show the new feature.

More measured kinds (2.2)

measure also reads fill and confidence in %, pressure and count. A reading near a threshold is unknown and fails closed, as in 1.6.

tests/fixtures/v2.2/valid/fill_below_a_quarter.rob
// RoboLang v2.2 fixture: valid
// expect: ok
// why: a fill is compared in % (K1, K2)

robolang 2.2;

task t(robot r, object shelf, location aisle, sensor cam, sensor tag) {
    goal { robot_at r aisle; }
    plan {
        move r to aisle;
        measure r fill of shelf using cam as level;
        if level < 25 % { communicate r to "lead" with "restock shelf_a"; }
    }
}
Output of robolang validate (exit status 0)
tests/fixtures/v2.2/valid/fill_below_a_quarter.rob: valid RoboLang 2.2 (1 task)
Validation covers the text of the program only. It does not make a task safe to run on a robot.

This world file, written for this page, has a shelf that is 20 % full and a camera that measures fill with an uncertainty of 2 %:

fill_world.json
{
  "world_schema": "robolang.sim.world",
  "world_schema_version": "1.7",
  "locations": [
    "dock",
    "aisle"
  ],
  "robots": {
    "amr1": {
      "ready": true,
      "location": "dock",
      "gripper": false,
      "max_speed": [
        {
          "value": "1",
          "unit": "m/s"
        }
      ]
    }
  },
  "objects": {
    "shelf_a": {
      "present": true,
      "location": "aisle",
      "properties": {
        "fill": {
          "value": "20",
          "unit": "%"
        }
      }
    }
  },
  "sensors": {
    "cam1": {
      "robot": "amr1",
      "available": true,
      "measures": {
        "fill": {
          "unit": "%",
          "uncertainty": "2",
          "contact": false
        }
      }
    },
    "tag1": {
      "robot": "amr1",
      "available": true
    }
  },
  "tasks": {}
}
robolang simulate tests/fixtures/v2.2/valid/fill_below_a_quarter.rob --world fill_world.json --bind r=amr1 shelf=shelf_a aisle=aisle cam=cam1 tag=tag1
Standard error (exit status 0)
simulation only: run sim-1d72342d02d720244a1a701427783888979381da57e614549676893cea707ade: SUCCEEDED
Standard output: selected fields of the run record, each step cut down to its index, status and reading
{
  "run_record_schema_version": "1.10",
  "state": "SUCCEEDED",
  "steps": [
    {
      "index": 1,
      "status": "succeeded",
      "reading": null
    },
    {
      "index": 2,
      "status": "succeeded",
      "reading": {
        "subject": "shelf_a",
        "kind": "fill",
        "value": "20",
        "unit": "%",
        "uncertainty": "2",
        "sensor": "cam1",
        "t_ms": "0"
      }
    },
    {
      "index": 3,
      "status": "succeeded",
      "reading": null
    },
    {
      "index": 4,
      "status": "succeeded",
      "reading": null
    }
  ]
}

Step 2 read 20 % with an uncertainty of 2 %, which is below the 25 % threshold, so step 4 sent the message. The rules are in the language 2.2 specification.

Choosing at run time (2.3)

choose binds a name to one robot, object or location when the job runs: from a list (or objects at a place, or robots), with an optional condition on world facts and an optional order, nearest or farthest by straight-line distance. Its else must end in fail, and the name can be used in the goal.

tests/fixtures/v2.3/valid/nearest_of_a_list_and_a_goal_that_names_it.rob
// RoboLang v2.3 fixture: valid
// expect: ok
// why: the statement, a goal that names the chosen robot (C1, C7)

robolang 2.3;

task send_tugger(robot a, robot b, location handoff) {
    goal { robot_at t handoff; }
    plan {
        choose robot t from (a, b) where robot_ready t nearest to handoff else { fail "no tugger is free"; }
        move t to handoff;
        communicate t to "ops" with "tugger sent";
    }
}
Output of robolang validate (exit status 0)
tests/fixtures/v2.3/valid/nearest_of_a_list_and_a_goal_that_names_it.rob: valid RoboLang 2.3 (1 task)
Validation covers the text of the program only. It does not make a task safe to run on a robot.

This world file, written for this page, gives each location a position: two ready robots, one 30 and one 10 away from handoff.

choose_world.json
{
  "world_schema": "robolang.sim.world",
  "world_schema_version": "1.8",
  "locations": [
    {
      "id": "handoff",
      "position": [
        0,
        0
      ]
    },
    {
      "id": "bay_a",
      "position": [
        30,
        0
      ]
    },
    {
      "id": "bay_b",
      "position": [
        10,
        0
      ]
    }
  ],
  "robots": {
    "tug1": {
      "ready": true,
      "location": "bay_a",
      "gripper": false,
      "max_speed": [
        {
          "value": "1",
          "unit": "m/s"
        }
      ]
    },
    "tug2": {
      "ready": true,
      "location": "bay_b",
      "gripper": false,
      "max_speed": [
        {
          "value": "1",
          "unit": "m/s"
        }
      ]
    }
  },
  "tasks": {}
}
robolang simulate tests/fixtures/v2.3/valid/nearest_of_a_list_and_a_goal_that_names_it.rob --world choose_world.json --bind a=tug1 b=tug2 handoff=handoff
Standard error (exit status 0)
simulation only: run sim-b6cff610ec577649647f6206c81074308715ab8f0045d2b8baff64793607683b: SUCCEEDED
Standard output: selected fields of the run record, each step cut down to its index and status
{
  "run_record_schema_version": "1.11",
  "state": "SUCCEEDED",
  "choices": [
    {
      "step": "1",
      "type": "robot",
      "name": "t",
      "candidates": [
        "tug1",
        "tug2"
      ],
      "excluded": [],
      "order": {
        "mode": "nearest",
        "reference": "handoff",
        "distances_squared": [
          {
            "entity": "tug1",
            "m2": "900"
          },
          {
            "entity": "tug2",
            "m2": "100"
          }
        ]
      },
      "kept": [
        "tug2",
        "tug1"
      ],
      "chosen": "tug2",
      "t_ms": "0"
    }
  ],
  "steps": [
    {
      "index": 1,
      "status": "succeeded"
    },
    {
      "index": 2,
      "status": "not_run"
    },
    {
      "index": 3,
      "status": "succeeded"
    },
    {
      "index": 4,
      "status": "succeeded"
    }
  ]
}

The run record keeps each choice: the candidates, those excluded, the order and the robot chosen, here tug2, the nearer one. Step 2, the fail of the else, did not run. The rules are in the language 2.3 specification.

The robot's own charge (2.4)

measure r charge as c; reads a robot's battery charge in % and binds it. It is compared with <, <=, > or >= against a literal in %; an unknown charge, or an uncertainty interval that holds the threshold, makes the comparison unknown and fails closed. RoboLang does not replace the robot's own low-battery protection, which always takes precedence.

tests/fixtures/v2.4/valid/charge_below_a_threshold_then_dock.rob
// RoboLang v2.4 fixture: valid
// expect: ok
// why: A charge read once, compared in an if; both branches have their own goal.

robolang 2.4;

task round_or_dock(robot r, location dock, location stop_c) {
    plan {
        measure r charge as c;
        if c < 25 % {
            goal { robot_at r dock; }
            move r to dock;
            communicate r to "lead" with "spot1 is docked";
        } else {
            goal { robot_at r stop_c; }
            move r to stop_c;
        }
    }
}
Output of robolang validate (exit status 0)
tests/fixtures/v2.4/valid/charge_below_a_threshold_then_dock.rob: valid RoboLang 2.4 (1 task)
Validation covers the text of the program only. It does not make a task safe to run on a robot.

In this world file, written for this page, the robot's charge is declared as 18 % with an uncertainty of 1 %. A charge changes only by scheduled events, and this world has none.

charge_world.json
{
  "world_schema": "robolang.sim.world",
  "world_schema_version": "1.9",
  "locations": [
    "dock",
    "stop_c"
  ],
  "robots": {
    "spot1": {
      "ready": true,
      "location": "stop_c",
      "gripper": false,
      "max_speed": [
        {
          "value": "1",
          "unit": "m/s"
        }
      ],
      "charge": {
        "value": "18",
        "unit": "%",
        "uncertainty": "1"
      }
    }
  },
  "tasks": {}
}
robolang simulate tests/fixtures/v2.4/valid/charge_below_a_threshold_then_dock.rob --world charge_world.json --bind r=spot1 dock=dock stop_c=stop_c
Standard error (exit status 0)
simulation only: run sim-573928dc83e9c26ff145a1827ab7545207182fc334d0eeb02d9ae356465df22d: SUCCEEDED
Standard output: selected fields of the run record, each step cut down to its index, status and reading
{
  "run_record_schema_version": "1.12",
  "state": "SUCCEEDED",
  "decisions": [
    {
      "step": "2",
      "condition_result": "true",
      "branch": "then",
      "t_ms": "0"
    }
  ],
  "steps": [
    {
      "index": 1,
      "status": "succeeded",
      "reading": {
        "subject": "spot1",
        "kind": "charge",
        "value": "18",
        "unit": "%",
        "uncertainty": "1",
        "sensor": "robot",
        "t_ms": "0"
      }
    },
    {
      "index": 2,
      "status": "succeeded",
      "reading": null
    },
    {
      "index": 3,
      "status": "succeeded",
      "reading": null
    },
    {
      "index": 4,
      "status": "succeeded",
      "reading": null
    },
    {
      "index": 5,
      "status": "not_run",
      "reading": null
    }
  ]
}

The reading is 18 %, below 25 %, so the decision took the then branch: the simulated robot moved to the dock and sent its message, and the second move did not run. The rules are in the language 2.4 specification.

Delegating a goal (experimental)

robolang delegate sends the goal of handover.rob, not its plan, to the arm as a signed Core 0.1 propose_goal. The arm looks in its own plan library, examples/plans, finds relocate_box with the same goal, runs it and reports an outcome. The planner accepts succeeded only after re-checking the signed evidence itself.

robolang delegate examples/handover.rob --world examples/world.json --from rl:agent:planner-1 --to rl:robot:arm1 --plans examples/plans
Standard error (exit status 0)
simulation only: delegate rl:goal:handover → rl:robot:arm1: succeeded (verified)
Standard output: selected fields of the delegate record, each message cut down to its time, type and sender
{
  "messages": [
    {
      "t_ms": 50,
      "document": {
        "type": "propose_goal",
        "sender": "rl:agent:planner-1"
      }
    },
    {
      "t_ms": 100,
      "document": {
        "type": "assessment",
        "sender": "rl:robot:arm1"
      }
    },
    {
      "t_ms": 150,
      "document": {
        "type": "accept",
        "sender": "rl:robot:arm1"
      }
    },
    {
      "t_ms": 200,
      "document": {
        "type": "outcome",
        "sender": "rl:robot:arm1"
      }
    }
  ],
  "planner_verdict": {
    "status": "succeeded",
    "criteria": [
      {
        "criterion": 0,
        "met": true,
        "evidence": [
          "rl:obs:a06897e6b4850f7a-0"
        ],
        "reason": null
      }
    ],
    "reasons": []
  }
}

A plan that needs a second robot brings it in as a peer, with a commitment, a lease and a custody transfer. This is simulation only: one process and simulation-only signatures. The rules are in the delegate specification.

Reference simulation (experimental)

robolang arch02 runs one case of the RFC-001 reference scenario with Core 0.1 messages between an AI planner stub, a fixed arm and a mobile robot, in one process. The scenario and cases are in tests/fixtures/arch02.

robolang arch02 --scenario tests/fixtures/arch02/scenario.json --cases tests/fixtures/arch02/cases.json --case happy_path
Standard error (exit status 0)
simulation only: run arch02-b15d8830279932950822877f5de7252f6f3aef2b2623f385369f736a9207cb82: planner-1 recorded succeeded

In the happy path the planner records the goal as succeeded, which Core 0.1 allows only with a verification that cites observations. Case v06_partition_before_release cuts the link between the two robots during the custody handover:

robolang arch02 --scenario tests/fixtures/arch02/scenario.json --cases tests/fixtures/arch02/cases.json --case v06_partition_before_release
Standard error (exit status 0)
simulation only: run arch02-0be8e15746df1ee215e2d51e3366accad768c5f4ffae61448d4efcaab063717e: planner-1 recorded unknown

The planner records unknown, not success: custody of the container could not be confirmed. The full run record of each case, printed to standard output, lists every message and event. The rules are in the reference simulation specification.

Invalid files

When a file is not valid, validate prints a diagnostic with a position and a code and returns exit status 1.

An undeclared name

The plan moves to bench, which is not a parameter of the task.

undeclared.rob
task fetch(robot r, object box, location shelf) {
    plan {
        move r to shelf;
        grasp r box;
        move r to bench;
    }
}
Output (exit status 1)
undeclared.rob:5:19: error[E303]: undeclared name 'bench': it is not a parameter of this task

A missing semicolon

missing_semicolon.rob
task fetch(robot r, location shelf) {
    plan {
        move r to shelf
    }
}
Output (exit status 1)
missing_semicolon.rob:3:24: error[E202]: missing ';' after the move statement

The core repository has a larger set of valid and invalid files used by its own tests, in tests/fixtures. The meaning of each code is listed in the language specification.