This is an old revision of the document!


PyCRAM Plan Language

The PyCRAM plan language is a domain-specific language in Python designed to help with the creation of robot control plans. The plan language is implemented as macros which bring features like parallel execution, failure handling and sequential execution. All of these features will be explained in detail later on. All macros of the plan language can terminate in one of two states, either the succeed of they fail. The conditions if a macro succeeds or fails changes depending on the macro.

The plan language is implemented using a slightly modified version of MacroPy, which is included in the PyCRAM repo as a submodule. Macros using MacroPy work by transforming the Abstract Syntax Tree (AST), this way new code or data can be inserted.

Using the Plan Language

If you are using the plan language macros in your code you have to pay attention to the way the macro is imported to the file. Because of the way MacroPy works you always have to import the 'macros' object from the language.py file first before importing any macros like this:

from pycram.language import macros, par 

The next thing you should keep in mind is that you can't directly execute the file which imports the macro of the plan language. Instead you have to create another file which imports the activation method of MacroPy and then executes the code in the file which contains the macro. This can then look like this:

 
import macropy.active
import demo

In this case demo is the file which imports the 'par' macro of the plan language.

Plan Language Expressions

There are a total of five expressions available in the plan language adding to this is the error handling which adds more control over the handling of errors than the standard Python way.