Table of Contents

Skill Description

This page will refer to example skills from this repository written by Pontus Rosqvist.

A skill description extends SkillDescription and is an object which keeps track of which parameters a skill has, what type the parameters are and if they are required, can be inferred or optional. In the skill description one also specifies any conditions which need to be met, these can be pre-conditions (before the skill is executed), hold-conditions (while the skill is executing) and post-conditions (after the skill has been executed). These conditions only need to be specified, SkiROS then takes care of checking that they hold. An example of a skill description can be seen in basic_primitive, skill_phases and infer_parameters among others.

Parameters

The parameters a skill has is specified in the skill description. A parameter can be a python object or an object from the world model. A float could be specified as a parameter in the following way:

class DescriptionName(SkillDescription):
  def createDescription(self):
    self.addParam('NameOfParameter', 0.0, ParamTypes.Required)

Here the value “0.0” becomes the default value for that parameter, one can also specify that the parameter has to be a float without specifying a default parameters:

class DescriptionName(SkillDescription):
  def createDescription(self):
    self.addParam('NameOfParameter', Float, ParamTypes.Required)

A parameter has a name which is a string which determines the key that the parameter is saved with in the dict self.params in the skill. One also needs to specify if the parameter is required optional or similar. The types of parameters are

Required parameters need to be specified, optional parameters do not :). Inferred parameters are parameters which are required but the skill description can infer them with the help of the world model. Parameters can be inferred if they are the only parameter which satisifes that condition, these conditions might be that the object is the only object of that type in the world model or if the pre-conditions uniquely determine the object in the world model. An example of how one can infer a parameter can be seen in infer_parameters.

The type of a parameter can also be a type which exists in the world model, these are specified in the following way

class DescriptionName(SkillDescription):
  def createDescription(self):
    self.addParam('NameOfParameter', Element('PREFIX:TYPE'), ParamTypes.Required)

Concrete examples of how this can be done can be seen in update_world_model, infer_parameters and world_model_interface.

Pre-conditions

The purpose of pre conditions are two-fold. Firstly pre conditions specify if a skill can be run or not, if the pre conditions cannot be satisfied the skill will not execute. Secondly pre conditions help SkiROS infer parameter, these do not need to be specified in the SkiROS gui, instead they are inferred when the skill is run.

Pre-conditions can be specified in the skill description in the following way

def createDescription(self):
      self.addParam('param1', Element('skiros:TransformationPose'), ParamTypes.Required)
      self.addParam('param2', Element('skiros:TransformationPose'), ParamTypes.Required)
      
      self.addPreCondition(self.getRelationCond('1_has_2', 'skiros:hasA', 'param1', 'param2', True))

A precondition for a skill with this skill description will then be that param1 is related to param2 with a hasA relation. This can be used to infer parameters from the world model, an example of this can be seen in infer_parameters. If the preconditions are not satisfied the skill will not even start. Sometimes SkiROS tells you why and which preconditions failed, sometimes it does not tell you.

The relationship between parameters specified can't be overly complicated because then SkiROS will not be able to infer them correctly. Exactly when SkiROS fails to infer parameters is unknown at the moment. A normal relationship as above and chained relationships are however fine. When several elements are related to several other elements it gets more hairy.

Hold-conditions

A hold condition is a condition which SkiROS either checks while the skill is running or your responsible for checking it continuously. Only SkiROS knows. They are specified similarly to the other conditions, i.e.:

      self.addHoldCondition(""" condition """)

Post-conditions

A post condition is a condition which needs to be true when the skill has concluded. These are primarily used for skill planning. A post condition is specified similarly to the other conditions, i.e.

      self.addPostCondition(""" condition """)