NimbRo ROS Soccer Package
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
State Controller Library

Namespaces

 statecontroller
 This namespace defines everything that is required for the State Controller Library.
 

Detailed Description

Author
Philipp Allgeuer (pallg.nosp@m.euer.nosp@m.@ais..nosp@m.uni-.nosp@m.bonn..nosp@m.de)
Date
November 21, 2014
Version
1.2.2

Overview

The State Controller Library is a generic platform-independent C++ namespace that allows finite state machines and multi-action planning generalisations thereof to be realised. The structure and implementation of this library focuses on applications of finite state machines in control loops, but can reasonably be adapted for virtually any other application. An emphasis has been placed on having very low overhead so as not to hurt overall system performance no matter where this library is used.

Aside from implementing standard finite state machines and multi-action planning state machines, this library can also be used to implement hierarchical state controllers or any hybrid of the three. The hierarchical case can be achieved by creating a state controller within the state of another state controller, and stepping the child state controller within the execute() callback of the parent state controller. Minor variations of this approach are also possible to adjust the visibility of certain state variables and shared variables. An overview of the State Controller Library architecture is shown in the following diagram.

scl_architecture.png
Figure 1: A block diagram of the State Controller Library architecture showing the states, state instances, state queue and state controller objects.

The State Controller Library was developed as a simple and state-based alternative to the more complex but powerful Behaviour Control Framework.

Academic Sources

The State Controller Library and the Behaviour Control Framework are detailed in the following paper.

P. Allgeuer and S. Behnke, "Hierarchical and State-based Architectures for Robot Behavior Planning and Control," in Proceedings of the 8th Workshop on Humanoid Soccer Robots, IEEE-RAS Int. Conference on Humanoid Robots, Atlanta, USA, 2013.

You are kindly asked to cite this paper if you use this framework for academic work.

@INPROCEEDINGS{Allgeuer2013,
  author = {Philipp Allgeuer and Sven Behnke},
  title = {Hierarchical and State-based Architectures for Robot Behavior Planning and Control},
  booktitle = {Proceedings of the 8th Workshop on Humanoid Soccer Robots, IEEE-RAS Int. Conference on Humanoid Robots},
  year = {2013},
  address = {Atlanta, USA}
}

Dependencies

This library depends on the following external libraries (to avoid requiring C++11):

For more information, or to download the Boost Libraries, please refer to http://www.boost.org/.

Library Implementation Notes

The following notes describe how to use the library, and outline some of the finer points.

Code Example

A (relatively) minimal example of how to use this library is shown below.

//
// File: MyCode.h
//
// Includes
// Using directives
using namespace statecontroller;
// State IDs
enum MySCStateID
{
MY_STATE,
...
};
// State controller
class MySC : public StateController
{
public:
// Constructors
MySC() : StateController("MySC") {}
// Shared variables
...
};
// Sample state
class MyState : public GenState<MySC>
{
public:
// Constructors
MyState(MySC *sc, int param) : GenState(sc, MY_STATE, "MY_STATE"), param(param) {}
protected:
// State callbacks
action_t execute(cycle_t cyc)
{
// Execute ten times then terminate state controller
if(execCycleNum(cyc) >= 10)
return sc->terminate();
// Stay in this state until the above condition is satisfied
}
// State parameters
int param;
// State variables
...
};
//
// File: MyCode.cpp
//
// Includes
#include "MyCode.h"
// Main function
int main(int argc, char **argv)
{
// Run the state controller
MySC sc;
sc.init(NewStateInstance<MyState>(&sc, 4));
sc.loop();
// Return value
return 0;
}

See test/test_state_controller.h and test/test_state_controller.cpp for more examples of how to define states and state controllers and how to run them.

See state_controller.h and state_controller.cpp for the library source code.

See Also
statecontroller Namespace
StateController Class
StateQueue Class
State Class