Skip to content

Actions

Victor Mataré edited this page May 22, 2023 · 10 revisions

Definition

An action definition describes something the agent can do, along with its preconditions, effects, domain restrictions and execution mapping (all optional). In golog++, all actions are implicitly durative.

Action Definition Example:

action grab(Thing t) {
precondition:
    !exists (Thing other) holding() = other
effect:
    holding() = t;
mapping:
    "execute_grab" {
         grab_thing = t
    }
}

The precondition is an arbitrary boolean formula that specifies when the action becomes executable.

The effect is an assignment to a fluent (or to an element of a fluent if it has a complex type) that specifies how the world will change after the action has been successfully executed.

The mapping specifies what (real) action should be triggered in the platform backend to execute an action, and how its arguments should be passed on. It can be used e.g. to hardcode or ignore certain parameters for a backend action.

Forward Declaration

For example to break dependency loops, an action can also be forward declared:

action grab(KnownThing thing);

After this, the action grab(_) can be referenced in procedural code, and can be defined anywhere later on.

Execution

An action is said to be impossible if its precondition is not satisfied in the given situation. If a program tries to execute an impossible action, it will be blocked until the next exogenous event(s). If it has become possible after the effects of the exogenous events have been applied, it will be executed.

An action can be called either synchronously or asynchronously. A synchronous call is simply the name of the action with arguments, e.g:

grab(banana);
say("Banana Grabbed.");

In this case, the action call will return only after the platform backend has notified golog++ that the execution has finished. An action can be executed asynchronously with the start(_) keyword:

start(grab(banana));
say("Grabbing banana.");

Here the say action will begin immediately after the execution of the grab action has been triggered, so the robot will talk while moving its arm.

It is also possible to specify concurrent tasks and error handling with the during construct:

during(grab(banana)) {
    say("Trying to grab banana.");
} on_fail {
    say("Failed to grab banana.");
} on_cancel {
    say("Grabbing attempt cancelled.");
}
Clone this wiki locally