Skip to content
Martin Molina edited this page Jul 26, 2020 · 2 revisions

It is possible to specify a robot mission in Aerostack using Python language using certain predefined functions. The specification must follow certain conventions that are explained below.

Simple example

A mission that simply takes off and lands the robot is specified as follows:

import mission_execution_control as mxc

def mission():
  mxc.executeTask('TAKE_OFF')
  mxc.executeTask('LAND')

The function mission() is a special function that is executed when the mission is started. As you can see, for this example it is necessary to import the mission_execution_control package in order to use the executeTask() function. This function executes any task and waits for it to complete. It returns a string with the termination status. The available tasks performed by behaviors can be found here:

Recurrent tasks

Recurrent tasks don't terminate until they are stopped, so they mustn't be executed with the function executeTask(), or they will block the program with and endless loop. In order to activate a task without waiting for its termination, the function startTask() is provided. To deactivate a recurrent task, use the function stopTask(). Example:

import mission_execution_control as mxc
def mission():
  mxc.executeTask('TAKE_OFF')

  mxc.startTask('PAY_ATTENTION_TO_QR_CODES')

  mxc.executeTask('FOLLOW_PATH', path = [ [0, 2, 1], [2, 2, 1] ])

  mxc.executeTask('ROTATE', relative_angle = 270)
	
  mxc.executeTask('FOLLOW_PATH', path = [ [3, 3, 1], [3, 0, 1] ])

  mxc.stopTask('PAY_ATTENTION_TO_QR_CODES')

  mxc.executeTask('LAND')

Accessing the belief memory

In order to add and remove beliefs from the belief memory the functions addBelief() and removeBelief() are provided. To consult the belief memory, two functions are provided: queryBelief() and trueBelief(). The latter simply returns true or false, while the first returns a boolean and a dictionary with the variables unified if it was successful. Example:

import mission_execution_control as mxc

def mission():
  mxc.addBelief('color(9, red)')

  mxc.addBelief('empty(9)’)

  result = mxc.trueBelief('color(?X, ?Y)') # This will return true

  success, unification = mxc.queryBelief('color(?X, ?), empty(?X)')

  if success: # Always check if query was successful before trying to access the unification variables
    my_string = unification['X']

    mxc.removeBelief('color(%s, red)' % my_string)

    mxc.removeBelief('empty(%s)' % my_string)
Clone this wiki locally