Skip to content

SCXML Wiki

Gianluca Prato edited this page Apr 8, 2020 · 4 revisions

This wiki is not meant to be fully explanatory of the SCXML standard (for a complete description of the format, please, refer to this page). The main purpose of the guide is to clarify how to use the SCXML format to describe Hierarchical State Machines accepted as input by the CPSwarm Code Generator.

Introduction

The most basic state machine concepts are and . Each state contains a set of transitions that define hows it reacts to events. In the following example, the system will transition to askForNewTask when event completed occurs, but will transition to errorRoutine if event failed occurs.

<state id="doTask">
   <transition event="completed" target="askForNewTask"/>
   <transition event="failed" target="errorRoutine"/>
</state>

Linking a state with a implemented software functionality

In the CPSwarm context, each state of the state machine can be associated with a high-level functionality that can be selected from 3 different sources:

  • the Abstraction Library
  • an optimized algorithm coming from the Optimization Tool
  • the Swarm Library which contains different types of swarm algorithms (simple functions or complex behaviours), generally handwritten taking inspiration from the biology

So, how can we model this link using the SCXML format?

We decided to realize it adapting 2 already existing tag used by the standard: and The former is used to identify the type interface that the associated functionality is exposing. This information is used by the Code Generator to correctly parse the content of the tag.

<state id="Takeoff">
   <datamodel>
      <data id="invoke">
        <rosaction>
           <name>cmd/takeoff</name>
           <action>uav_mavros_takeoff/TakeOff</action>
           <goal type="object">
              <param>1.5</param>
           </goal>
           <result type="empty"/>
        </rosaction>
      </data>
   </datamodel>
   <invoke type="ROS_ACTION" />

   <transition event="succeeded" target="Coverage" />
</state>

In the example above the Takeoff state is linked with a takeoff function exposing a ROS action as interface.

More details on how to describe ROS functionalities are presented here.

Clone this wiki locally