Skip to content

cram_beliefstate creating contexts

Jan Winkler edited this page Feb 12, 2015 · 1 revision

cram_beliefstate: Creating custom Contexts

Prominent functions within CRAM open so-called "contexts" within which other tasks and actions can be executed. This is the foundation for building up hierarchical semantic trees in plan logs produced by the CRAM logging system. An example is the with-designators environment, which initialized designators, and executed body code supplied as parameters:

(with-designators ((obj-1 (object `((type cup) (color red)))))
  (perform-body-code ...))

From a logging perspective, this translates to:

  • Open the context with-designators
  • Set the context type to "WithDesignators" (being done by the logging framework)
  • Annotate the context with its start time
  • Annotate the context with a variable obj-1 of type object-designator with content ((type cup) (color red))
  • Perform the given body code
  • Annotate the context with its end time
  • Close the context

If one would like to introduce a new context type, the cram_beliefstate package offers functionality for that. Lets assume, the context my-context should be opened. In lisp, one would call:

(beliefstate:start-node "MY-CONTEXT" nil 2)

The signature is simple:

  • "MY-CONTEXT" refers to the context name
  • nil is an internal specifier that doesn't require clarification in this context
  • 2 is the detail level of the node; 2 is a fairly good value for almost all cases

The call also has a return value: The internal logging ID. You will need this ID in case you

  • Want to add designator instances to this particular context
  • Close the context

To add a designator and close the context again, do

(with-designators ((obj-1 (object `((type cup) (color red)))))
  (let ((id (beliefstate:start-node "MY-CONTEXT" nil 2)))
    (beliefstate:add-designator-to-node obj-1)
    (beliefstate:stop-node id :success t)))

Whether the success flag in stop-node is t or nil is up to the semantics of your custom context.

Clone this wiki locally