A dispatch function signature takes one parameter, a python dictionary called *context* as input and returns another dictionary called *reply*.
The *context* contains the data from the statemachine comma-separated action string as key-value pairs. An important key is *xml_file* which if present contains the absolute path to a keyframe xml file. If the *xml_file* is present, the dispatcher has automatically loaded the contents of the file into a XML DOM object available as key *xml_dom*. The DOM object can be queried using xpath as shown below. Another important keys are *result_name* and *result_values* which contains the name of the expected (from a statemachine perspective) return value and the allowed return values as a semicolon-separated list of values. In the example below the reply dictionary is populated with one entry containing the result variable as key and the first of the allowed return values as value.
Before the function can be called it need to be registered in the *fmap* structure. It maps a name to a function. The name is what will be called from the statemachine action string, i.e. `call=name`.
Below is an example of how to call a ROS service from within a function. In order for the dispatchservice to recognize srv-files from other services it will be needed to change the CMakeLists.txt, package.xml and/or update the srv folder of the grafchart_utils package, followed by a catkin_make.