This is an old revision of the document!


Designator

Designators are CRAMs and PyCRAMs way of representing actions, motions, objects and locations. However at the moment only action and motion designator are implemented in PyCRAM.

Designators, in PyCRAM, consist of an instance of the respective class which holds a description with all parameter necessary as instance attributes. In the following we will reefer to the parameter as properties of the respective description. Below you can see a few examples which should help understand the usage of designators.

MotionDesignator(MoveMotionDescription(target=[1,1,0], orientation=[0, 0, 0, 1]))

This motion desigantor holds a description of type MoveMotionDescription meaning it describes moving the robot around. The parameter or properties are 'target' which represents the coordinates in world frame of where the robot should move and 'orientation' which is the orientation the robot should have after moving.

The convention for naming descriptions is: the type of this description, followed by the type of designator it is meant for and lastly the word 'description'.

Perform a desigantor

Motion and action designator both have a perform method which executes the behaviour the designator describes. The perform method can be simply called on every initialized designator like you can see in the following example.

MotionDesignator(MoveMotionDescription(target=[1,1,0], orientation=[0, 0, 0, 1])).perform()

The perform method works different for every type of designator, for more information on how the respective method works please look at the other sections.

Resolving

Before the described movement of a designator can be executed all parameter have to be present. Because not all parameter have to be provided, missing ones have to be inferred. This is done by 'resolving' a designator, this calls the grounding method of the description which then interferes the missing parameter or inserts standard values.

This can be done by calling the 'reference' method of a designator.

desig = MotionDesignator(MoveMotionDescription(target=[1,1,0]))
solution = desig.reference()

In this case solution is a dictionary of the resolved designator. This dictionary also contains a orientation because this is needed to move the robot around. The value for the orientation would be the orientation of the robot in the Bullet World or the identity orientation if no simulation is running.

Real and Simulated robot

Because the target of a designator can be either a real or a simulated robot, there needs to be a way to differentiate between the two targets. This can be done in two ways which will be both explained in the following paragraphs.

Decorator

The first one is to use a decorator, decorator are python syntax to annotate functions to execute code before and after the function is executed. In this case the decorator manages the 'robot_type' class attribute in the ProcessModule class which is either 'real' for the real robot or 'simulated' for the simulated robot. The decorator can be imported from the process_module.py file. There are two available decorator 'with_simulated_robot' and 'with_real_robot'. The use of the respective decorator can be seen below.

from pycram.process_module import with_simulated_robot

@with_simulated_robot
def plan_a():
    MotionDesignator(MoveMotionDescription(target=[1,1,0], orientation=[0, 0, 0, 1])).perform()

This will execute the motion designator on a simulated robot in the Bullet World.

from pycram.process_module import with_real_robot

@with_simulated_robot
def plan_a():
    MotionDesignator(MoveMotionDescription(target=[1,1,0], orientation=[0, 0, 0, 1])).perform()

This will execute the motion designator on the real robot.

With Statement

The second way is using the python 'with' statement to encapsulate motion designator which should executed on the respective robot. This method can be combined with the previous one to nest the execution on different types of robots. An example of this is that the decorator is being used to execute the plan on the real robot and in the plan reasoning over the state of objects is being done on the simulated robot. The statement can be imported, like the decorator, from the process_module file. An example on how to use this method can be seen below.

from pycram.process_module import simulated_robot

with simulated_robot:
    MotionDesignator(MoveMotionDescription(target=[1,1,0], orientation=[0, 0, 0, 1])).perform()

This will execute the motion designator on the simulated robot.

from pycram.process_module import real_robot

with real_robot:
    MotionDesignator(MoveMotionDescription(target=[1,1,0], orientation=[0, 0, 0, 1])).perform()

This will execute the designator on the real robot.

Motion Designator

Motion designator represent a low-level motion of a robot like driving or moving joints. The possible descriptions for the motion designator are the following:

  • MoveMotionDescription
  • PickUpMotionDescription
  • PlaceMotionDescription
  • AccessingMotionDescription
  • MoveTCPMotionDescription
  • LookingMotionDescription
  • MoveGripperMotionDescription
  • DetectingMotionDescription
  • MoveArmJointsMotionDescription
  • WorldStateDetectingMotionDescription

All descriptions take different parameters depending on the described movement. Some of these parameters are optional, meaning there are multiple parameter which provide the information. For example, in the case of the MoveArmJointsMotionDescription where the used can provide either positions for the left or right arm, both of these parameters are optional. Another case may be that the missing parameter can be inferred or that a standard value can be used. In the case of the MoveMotionDescription if no orientation is provided the current orientation of the robot in the Bullet World is used. In other cases where an arm has to be named and the user does not specify which arm to use, the left is used as a standard value.

Typing

For every parameter in the description there is a type hint which allows to check the types of passed parameter. This check is done at the end of grounding the description by calling the '_check_properties' method. This method checks if there are missing properties and if the present properties have the right type. If on of these checks fail a ResolutionError is raised which shows the missing properties along with the ones which have the wrong type and the right type, according to the type hints in the description.

Perform

Because motion designator are the lowest description of a movement the perform method of a motion designator calls the corresponding process module to perform the described motion. This works by calling a resolver method which checks the available process modules and returns the one that corresponds to the type of description. For more information on how process modules work please check process_modules.

The resolved designator is returned as a dictionary where the name of the properties is the key. This dictionary is then used in the process module to access the values of the designator description.

Action Designator

Action designator are a high level representation of movements which compose different motion designator. For example the is the transport action designator which transports an object from one position to another. This includes going to the location of the object, detecting the object, picking it up, moving to the target location and placing the object.

Action designator work much like motion designator in that both hold a description which has all properties needed for execution. Action designator descriptions also have a grounding method which interferes missing properties.

The main difference between action and motion designator is that action designator do not call a process module if they are performed, instead they call a function which is set while the designator is grounded. This function is the plan that composes the motions needed for executing the described movement.

The currently available action designator descriptions are:

  • MoveTorsoActionDescription
  • SetGripperActionDescription
  • ReleaseActionDescription
  • GripActionDescription
  • MoveArmsIntoConfigurationDescription
  • MoveArmsInSequenceDescription
  • ParkArmsDescription
  • PickUpDescription
  • PlaceDescription
  • NavigateDescription
  • TransportObjectDescription
  • LookAtDescription
  • DetectActionDescription
  • OpenActionDescription
  • CloseActionDescription