RoboLang

RoboLang 2.5 language reference

RoboLang is a small, checked language for robot tasks. A program describes a desired final state and a plan for reaching it in a symbolic world. A program is correct only when it validates, names the right entities, states the operator’s requested outcome in goal, and reaches that goal.

RoboLang 2.5 has bounded branching (if/else, see “Branching”), step failure handlers (a step else { ... } that runs when that step fails, see “Failure handlers”), measured values (measure reads a temperature, a mass, a distance, a label, how full something is, how sure the detector is, a pressure or a count from a sensor, see “Measured values”), region limits (@safety no_go_region R;, @safety in_region R;: where the robots may be while they move, see “Region limits”), declared actions (do r open door; asks a robot for an action its profile declares, and in_state door "open" checks the result, see “Declared actions”), clock readings (measure r time as t; reads the time of day, 22:00 is a time, wait until clock_time >= 23:00 ... waits for one, see “Clock readings”) and missions (a mission runs tasks one after another, again and again, with a hard bound: a count, a duration or a time of day, see “Missions”), incoming messages (message_received "line" with "DOCKED" is true once a message has arrived on a channel, see “Incoming messages”) and choosing at run time (choose robot t from (a, b) nearest to spot else { ... } binds a name to one robot, object or location when the job runs, see “Choosing at run time”) and the robot’s own charge (measure r charge as c; reads a robot’s battery charge in percent, wait until robot_charge r >= 80 % ... waits for it, see “The robot’s own charge”) and mission triggers (repeat every 60 min from 09:00 { ... } starts each run at a time, repeat on message_received "ops" with "GO" { ... } starts one run for each message, see “Mission triggers”). A task itself never loops: it runs once. A fixed count is not a mission: “three round trips” is one task with the steps written out three times (a mission with at most 3 runs is also accepted), and “try the grasp once more” or “retry the step up to 3 times” is a failure handler, a program, not a decline. It has no repeat without a bound (“forever”, “until it works” with no count or time), interrupts (“the moment the battery drops, even mid-round”), triggers on the robot’s own state or on objects that arrive, schedules across days (“every morning”), loops inside loops, choosing by a reading of each candidate, acting on each member of a set chosen at run time, dates, arithmetic, string formatting, confirming that a message the robot sent was delivered, the content of a message as a value, patterns in a message text, readings of anything but the nine kinds, of a person, or of the robot itself beyond its charge (its self-test, its faults), time until its battery is empty, limits on one step only, limits on an arm or a person, or variables beyond typed parameters and the names that measure binds. Do not silently drop part of a request. If a request needs an unsupported construct, or the available world and robots cannot perform it, say that it cannot be represented or completed.

File and task structure

A file starts with robolang 2.5; and holds one or more tasks, and missions that run them (see “Missions”). A file of tasks only needs no mission. // starts a comment. The language is case-sensitive. Whitespace only separates tokens.

task NAME(type param, type param, ...) {
    @safety max_speed 0.5 m/s;     // zero or more annotations, first
    @safety no_go_region wet;      // region limits are annotations too (see "Region limits")
    pre  { condition; ... }        // optional
    goal { condition; ... }        // required unless every branch has its own goal
    plan { statement; ... }        // required, at least one statement
}

The order inside a task is fixed: annotations, pre, goal, plan. Every condition and statement ends with ;.

Parameter types are robot, object, location, region, and sensor. A parameter is a placeholder that a caller binds to a world entity of the same type. Names are ASCII letters, digits and _, starting with a letter. These words are reserved and cannot be names:

robolang task pre plan goal robot object location region sensor move grasp place inspect wait communicate
to at using with for until timeout robot_ready region_clear object_exists sensor_ok object_at robot_at holding
and or not in_region with_approach no_go_region require_guard message_received scalar duration
if else fail measure as do in_state clock_time clock_elapsed
mission repeat run runs stop continue retry

Numbers are unsigned decimals (2, 0.5); there is no sign or exponent. A duration is a number followed by ms, s, or min, and must be above zero. Write prose quantities numerically: half a second is 500 ms; a quarter minute is 15 s. There is no unit for hours: 90 minutes is 90 min and 2 hours are 120 min. A time of day is not a duration: it is written 22:00 (“Clock readings”).

Plan statements

move r to dst;
grasp r obj;
place r obj at dst;
inspect r obj using camera;
measure r temperature of obj using probe as t;
measure r time as now;
do r open door;
do r set fryer to 175 degC;
wait for 2 s;
wait until region_clear cell timeout 30 s else { fail "cell not clear"; }
wait until clock_time >= 23:00 timeout 90 min else { fail "23:00 did not come in time"; }
wait until message_received "line" with "TUGGER DOCKED" timeout 10 min else { fail "no dock signal"; }
communicate r to "channel" with "message";
communicate r to "channel" with t;

Here r is a robot, obj an object, dst a location, camera and probe sensor parameters, t a name bound by measure (“Measured values”; now is a time of day, “Clock readings”), and door an object or fryer a location that a do acts on (“Declared actions”). A sensor is never a quoted string. wait until always needs a timeout and a failure handler (E316). Strings cannot contain a literal line break; the only escapes are \", \\, \n, and \t.

Branching

if region_clear cell {
    goal { object_at box a; }       // optional: adds to the goal on this path
    move r to a;
    place r box at a;
} else if robot_ready r2 {          // `else if` is shorthand for an `else` holding an `if`
    goal { object_at box b; }
    move r2 to b;
    place r2 box at b;
} else {
    communicate r to "alerts" with "no route";
    fail "no route";                // ends the run as failed; last statement of a branch only
}

A condition about the moment the job runs is decided by the program, with if. When the request says “if arm1 is ready when the job starts”, “if the cell is clear at that moment”, “if the box is still there”, or “whichever robot is ready” (two or three named robots: an if; a list or a set: choose, see “Choosing at run time”), the answer is not in the world description you were given: it is whatever is true when the program runs. Never settle it by reading the description and writing only the branch that is true there, and never write only one branch (with or without pre). Write the if with both branches, and with a goal for each path. A program with one branch passes in the world shown and fails in the other worlds the request was about.

Failure handlers

move r to src else { communicate r to "ops" with "cannot reach src"; fail "cannot reach src"; }
grasp r box else { grasp r box; }               // one more attempt
wait until region_clear aisle timeout 10 s else {
    place r box at src;                         // clean up
    fail "the aisle did not clear";             // then stop
}

Measured values

measure r temperature of pan using probe as t;
measure r mass of tray using scale as m else { fail "no weight"; }
measure r label of vial using scanner as lot;
if t < 60 degC { ... }
wait until temperature of pan using probe < 60 degC timeout 10 min else { fail "still hot"; }
communicate r to "pass" with t;

inspect never reads a value. It records whether an object is present and where it is, nothing else. Weighing, taking a temperature, reading a batch number or a barcode is measure, even when the request only says “weigh it, then move it”: writing inspect for it does less than was asked. Choose measure whenever a request asks for a weight, a temperature, a distance, a batch number or a label, whether or not the program uses the value afterwards.

More kinds: fill, confidence, pressure, count

robolang 2.5;

task shelf_check(robot r, location shelf, location aisle, object gauge, sensor cam, sensor tag, sensor pcam) {
    goal { robot_at r aisle; }
    plan {
        move r to aisle;
        measure r fill of shelf using cam as level;       // how full: %
        measure r count of shelf using tag as n;          // how many items: a whole number, no unit
        measure r pressure of gauge using pcam as p;      // Pa, kPa or bar
        if level < 25 % { communicate r to "lead" with "restock the shelf"; }
        if n == 0 { communicate r to "lead" with "out of stock"; }
        if p > 6 bar { communicate r to "maintenance" with "over pressure"; }
    }
}

Choosing at run time

choose TYPE NAME from CANDIDATES [where CONDITION] [nearest to X | farthest from X] else { ... fail "..."; }
robolang 2.5;

task send_tugger(robot a, robot b, location handoff) {
    goal { robot_at t handoff; }
    plan {
        choose robot t from (a, b) nearest to handoff else { fail "no tugger has a position"; }
        move t to handoff;
        communicate t to "ops" with "tugger sent";
    }
}

choose binds a new name (t above) to one entity of TYPE (robot, object or location) when the job reaches the statement. Use it when the request leaves the entity to the world: “whichever tugger is nearest”, “a part from the conveyor”, “the robot that is ready”, “the dock farthest from the gate”.

Not in 2.5 (decline as inexpressible): choosing by a reading of each candidate (“the fullest bin”, “any pan above 80 degC”); acting on each candidate in turn, with a memory of which are done (“every pan”, “as many crates as there are bins”); detecting objects the world does not list (“if the camera sees something the stock list does not know”: objects at L yields only what the world lists); choosing a person (“the robot nearest the person who called”: a person is not an entity of the world, and a stand-in place for them is another request); several choices that depend on each other. Do not replace a choice by one fixed candidate, by the first of a list with the order dropped, or by a stand-in: write the choose with the criteria the request states, or decline.

The robot’s own charge

measure r charge as c;
if c < 25 % { ... } else { ... }
wait until robot_charge r >= 80 % timeout 40 min else { fail "the battery is not at 80 percent in time"; }
repeat at most 6 runs { run round(r, a, b); } until robot_charge r < 30 %;
choose robot t from (a, b) where robot_charge t >= 50 % else { fail "..."; }

A request such as “if your battery is below 25 percent, go to dock_2 and tell channel “lead” “spot1 is docked”; otherwise go on to stop_c” reads the robot’s own charge. It is a program, not a decline:

robolang 2.5;

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;
        }
    }
}
robolang 2.5;

task relief(robot a, robot b, location dest) {
    goal { robot_at t dest; }
    plan {
        choose robot t from (a, b) where robot_charge t >= 50 % else { fail "neither robot has 50 percent charge"; }
        move t to dest;
    }
}

Not in 2.5 (decline as inexpressible): the robot’s health beyond robot_ready and sensor_ok: a self-test and its result, its faults, a request for service; a prediction from the charge: how many minutes the robot can still run, whether it will make it back to the dock, how much charge a route costs (a charge cannot be predicted: there is no drain model, and a threshold the request does not give is a number you would invent); arithmetic on a charge; and an interrupt: “the moment your battery drops below 20 percent, even in the middle of a round” (a trigger starts a run and never pre-empts one, and a check at the start of each run is a different request).

Clock readings

measure r time as now;                     // the time of day when this step runs, in the world's zone
measure r elapsed as took;                 // the time since the task started
if now < 22:00 { ... } else { ... }        // a time is HH:MM or HH:MM:SS, 24-hour
if took >= 2 min { ... }                   // an elapsed time compares with a duration
wait until clock_time >= 23:00 timeout 90 min else { fail "23:00 did not come in time"; }
communicate r to "lead" with now;          // a time is sent as HH:MM:SS; an elapsed time as seconds, `37 s`
robolang 2.5;

task tote_if_open(robot r, object tote, location inb, location outb) {
    plan {
        measure r time as now;
        if now < 22:00 {
            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 "the shift is over";
            fail "the shift has ended";
        }
    }
}

The world list says when the task starts and in which zone: clock: the task starts at 2026-11-17 21:30:00 (Europe/Prague), or clock: none (this world has no clock). The clock runs with the task: a wait for 90 s moves it 90 seconds on.

Declared actions

do r open door;                     // the robot r does the action `open`, which its profile declares, on `door`
do r set fryer to 175 degC;         // an action that takes a value (a quantity with a unit, or a text)
do r open door else { fail "door stuck"; }
goal { in_state door "open"; }      // the result is checked, never assumed
robolang 2.5;

task restock(robot r, object closet, object kit, location ward, location store) {
    goal { in_state closet "open"; object_at kit ward; }
    plan {
        move r to store;
        do r open closet;
        grasp r kit;
        move r to ward;
        place r kit at ward;
    }
}

A robot can do more than the seven statements: open a door, set a temperature, print, lock, charge, dock. It can do exactly the actions its profile declares, and the world list shows them for each robot, for example moxi1 (... can do: open (on an object, leaves it open); set (on a location, leaves it heating, takes a temperature)). An action is a name, not a keyword: write it exactly as the world lists it (open_door is not open).

Conditions

Atom True when
robot_ready r robot r is ready for physical actions
region_clear c region c is clear
object_exists o object o is present
sensor_ok s sensor parameter s is available
object_at o l object o is present, not held, and at location l
robot_at r l robot r is at location l
holding r o robot r holds object o
in_state x "open" the state of object or location x is that label (see “Declared actions”; unknown when the world gives x no state)
t < 60 degC, lot == "A" a measured value compares as stated (only in if and wait until; see “Measured values”)
now < 22:00, clock_time >= 23:00 a time of day compares as stated (only in if and wait until; see “Clock readings”)
message_received "line" with "DOCKED", message_received "nurse" a message with exactly that text (any message, with no with) has arrived on that channel from a sender the world allows (see “Incoming messages”); never in a goal

Combine conditions with not, and, or, and parentheses:

region_clear a or region_clear b;
not region_clear z;
(robot_ready r and region_clear c) or object_exists o;

and and or cannot be mixed at one level without parentheses. A condition is at most eight levels deep. A fact the world does not state is unknown, and unknown is never treated as true.

Preconditions, goals, and annotations

Region limits

@safety no_go_region wet;    // every robot of the task stays out of region `wet`
@safety in_region lane;      // every robot of the task stays inside region `lane`

Both words go after @safety, name a region parameter, and are written before pre, goal and plan, in any order with max_speed. Bind the parameter to the region of the world that the request names, by its exact ID.

robolang 2.5;

task to_lobby(robot r, location lobby, region wet) {
    @safety no_go_region wet;
    goal { robot_at r lobby; }
    plan { move r to lobby; }
}

Missions

A mission runs tasks one after another. Every task run is a complete run with its own pre, limits, steps and goal; the mission only decides whether to start the next one. It is written next to the tasks it runs, in the same file.

mission NAME(type param, ...) {
    repeat at most 30 runs, for at most 90 min {     // a hard bound: a count, a duration, or both
        run TASK(param, param, ...);                 // one or more run lines, each a run of a task of the file
    } until region_clear cell;                       // `until` is optional; the repeat always ends with `;`
    on failure { stop; }                             // optional: stop (default), continue, or retry 3
}
robolang 2.5;

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, region quay) {
    repeat at most 12 runs, for at most 480 min {
        run round(r, home, far);
    } until region_clear quay;
    on failure { continue; }
}
robolang 2.5;

task three_round_trips(robot r, location a, location b) {
    goal { robot_at r a; }
    plan { move r to b; move r to a; move r to b; move r to a; move r to b; move r to a; }
}

Mission triggers

A mission starts its next run when the last one is done. A request that says when each run starts, at a time or on a message, gives the repeat one trigger, written after its bounds and before the {.

repeat every 60 min from 09:00 { run round(r, a, b); } until clock_time >= 13:00;                 // times
repeat at most 3 runs, on message_received "ops" with "GO" { run round(r, a, b); };               // messages

“Every hour from 09:00 until 13:00, send moxi1 on its round” is a program, not a decline:

robolang 2.5;

task round(robot r, location base, location ward, location lab) {
    goal { robot_at r base; }
    plan { move r to ward; move r to lab; move r to base; }
}

mission hourly_rounds(robot r, location base, location ward, location lab) {
    repeat every 60 min from 09:00 {
        run round(r, base, ward, lab);
    } until clock_time >= 13:00;
}

“Each time channel “ops” sends “GO”, send moxi1 on its round. Do this 3 times.” is the other form:

robolang 2.5;

task round(robot r, location base, location ward, location lab) {
    goal { robot_at r base; }
    plan { move r to ward; move r to lab; move r to base; }
}

mission on_go(robot r, location base, location ward, location lab) {
    repeat at most 3 runs, on message_received "ops" with "GO" {
        run round(r, base, ward, lab);
    };
}

Incoming messages

A message is something another party sends to a robot’s channel: a line controller saying TUGGER DOCKED, a nurse saying CONFIRMED, a site saying WIND CLEAR. message_received is a condition, true once such a message has arrived.

message_received "line" with "TUGGER DOCKED"     // a message with exactly that text
message_received "nurse"                         // any message at all on that channel
robolang 2.5;

task feed(robot r, object tote, location src, location handoff, location line) {
    goal { object_at tote line; }
    plan {
        move r to src; grasp r tote; move r to handoff;
        wait until message_received "line" with "TUGGER DOCKED" timeout 10 min else { fail "no dock signal"; }
        move r to line; place r tote at line;
    }
}

What symbolic simulation requires

Validation checks source structure, names, and types. World-specific capability and state failures appear when the task is checked against a world or simulated. A run fails with S261 when the condition of an if is unknown, and with S262 when it reaches a fail. Common source diagnostics are:

Code Meaning
E105 a time of day that is not HH:MM or HH:MM:SS in 24-hour form (24:00, 9:30, 21:60)
E201 a handler after wait for, communicate or fail
E202 missing ;
E206 missing or unknown unit, or a number in a comparison with no unit
E208 task blocks in the wrong order, an empty branch or handler, a goal block that is not first in a branch, or a goal block in a handler
E212 reserved word used as a name
E214 and and or mixed without parentheses
E217 a kind that is not temperature, mass, distance, label, time, elapsed or charge
E216 if statements and handlers nested more than 4 deep
E303 name is not a task parameter
E304 parameter used with the wrong type
E307 empty string (for example fail "", or message_received "ch" with "")
E309 a path has no goal condition and does not end in fail
E313 fail that is not the last statement of a branch or handler
E315 grasp of an object a robot still holds, or by a robot that still holds one: place it first
E310 quoted sensor name used instead of a sensor parameter
E316 wait until without a failure handler
E317 a name used as a value that is not a visible binding (before its measure, outside its branch or handler, a parameter)
E318 a binding named like a parameter or another binding (except a retry in the handler of its own measure)
E319 kinds that do not match: a charge against a unit that is not % or against another kind, a unit of another kind, a string against a quantity, a time against a duration or an elapsed value, a retry of another kind
E320 == or != on a quantity, a time or an elapsed value, or ordering on a label
E321 a comparison in pre or goal
E327 a message_received in a goal (a message is not an end state: wait for it in the plan)
S011 a message_received names a channel that the world does not list (a world that lists channels): fails before anything moves
E325 a repeat with no hard bound (no count, duration or time of day to end at), or a count over its cap (1000 runs, 100 retries)
E326 a run of something that is not a task of the file (a mission, an unknown name), or with the wrong number of arguments
S401 a mission’s task cannot fit its duration bound even once: its waits alone are longer
S402 a mission’s until is unknown after a run: the mission stops
E322 a live reading, clock_time / clock_elapsed or robot_charge anywhere but the condition of a wait until (and a mission’s until for robot_charge)
S010 wait until clock_time >= T where T has already passed when the task starts
S012 a charge that is never known (the robot has none and no event gives it one), and the step has no fallback: fails before anything moves
S013 wait until robot_charge r >= T that no charge the world gives the robot can meet, and no fallback: fails before anything moves
S239 a charge reading of a robot the world gives no charge: unknown, fails closed
S237 a time reading and the world has no clock
S238 a time reading after the clock has reached the end of the day the task started on
S006 a do names an action the robot does not list in the world
S007 the target of a do is an object where the action acts on a location, or the reverse
S008 a do gives a value the action does not take, no value where it takes one, or a value of the wrong kind
S009 the goal needs an in_state that no action of the task’s robots leaves, and the world does not already hold
S271 do: the robot is not at the target location, or at the target object’s location
E323 a region named by more than one region limit, or as both no_go_region and in_region
E324 more than 8 region limits in a task
S003 a robot that moves does not honour the kind of region limit (its honours in the world)
S004 a target (a move or place location, or a robot_at goal) is inside a no_go_region, or outside an in_region whose locations the world lists
S005 a robot that moves starts inside a no_go_region, or outside an in_region whose locations the world lists
S234 measure: the sensor does not measure that kind
S235 measure with a contact sensor: the robot is not at the object
S236 measure: the object has no value of that kind

Complete example

This task waits for a cell (and stops if it does not clear in time), inspects a box, moves it, and records completion. Its parameters still need bindings to concrete world entities before simulation.

robolang 2.5;

task deliver(robot r, object box, location src, location dst, region cell, sensor camera) {
    @safety max_speed 0.5 m/s;
    pre { sensor_ok camera; }
    goal { object_at box dst; }
    plan {
        wait until region_clear cell timeout 20 s else {
            fail "the cell did not clear";
        }
        move r to src;
        inspect r box using camera;
        grasp r box;
        move r to dst;
        place r box at dst;
        communicate r to "fleet" with "DONE";
    }
}

This task chooses at run time. If the cell is clear when the job reaches the if, the box goes to a; otherwise it goes to b. Each path has its own goal.

robolang 2.5;

task route(robot r, object box, location src, location a, location b, region cell) {
    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 {
            goal { object_at box b; }
            move r to b;
            place r box at b;
        }
    }
}

This task retries a failed grasp once. If the second grasp also fails, it reports and stops.

robolang 2.5;

task fetch(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 else {
                communicate r to "ops" with "grasp failed";
                fail "grasp failed twice";
            }
        }
        move r to dst;
        place r box at dst;
    }
}

This task measures, compares and reports. The probe is a contact sensor, so the arm moves to the pan first. It sends the reading to the “pass” channel, and moves the pan only if the reading is clearly below 60 degC. A borderline reading (for example 59.8 degC with an uncertainty of 0.5) is unknown and fails the run (S261) instead of moving a pan that may be too hot.

robolang 2.5;

task check_pan(robot r, object pan, sensor probe, location src, location dst) {
    goal { object_at pan dst; }
    plan {
        move r to src;
        measure r temperature of pan using probe as t else {
            communicate r to "pass" with "no reading";
            fail "no reading";
        }
        communicate r to "pass" with t;
        if t < 60 degC {
            grasp r pan;
            move r to dst;
            place r pan at dst;
        } else {
            fail "pan too hot";
        }
    }
}

robolang validate checks this source but does not execute it or establish that it is safe on a physical robot. Hardware execution requires a separate robot-specific authorization and safety case.