NimbRo ROS Soccer Package
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
behaviourcontrol::Behaviour Class Reference

Implements a single behaviour. More...

#include <behaviour.h>

Inherited by behaviourcontroltest::MyB1, behaviourcontroltest::MyB2, behaviourcontroltest::MyB3, and behaviourcontroltest::MyB4.

Public Member Functions

 Behaviour (BehaviourLayer *LBase, const std::string &name=nullString)
 Default constructor. More...
 
virtual ~Behaviour ()
 Behaviour object destructor.
 
level_t getA () const
 Returns the current true activation level of the behaviour. The return value is valid only when called from the execute(), inhibited() or BehaviourLayer::postExecuteCallback() function.
 
std::string getUniqueName (const BehaviourLayer *LBase) const
 Returns a unique behaviour name. More...
 
BehaviourgetBasePtr ()
 Return a pointer to the underlying Behaviour class object in the case of a derived behaviour class.
 

Public Attributes

BehaviourManager *const MBase
 Pointer to the parent behaviour manager.
 
BehaviourLayer *const LBase
 Pointer to the parent behaviour layer.
 
const std::string Mname
 Human-friendly string name of the parent behaviour manager.
 
const std::string Lname
 Human-friendly string name of the parent behaviour layer.
 
const std::string name
 Human-friendly string name of the behaviour.
 

Static Public Attributes

static const index_t DEF_ILIST_CAPACITY = 16
 Default capacity of the inhibition lists that are used to store which behaviours are inhibitors and inhibitees of this behaviour.
 
static const std::string DEF_BEHAVIOUR_NAME = "Behaviour"
 Default behaviour name used to generate a unique one, in the case that no name is provided by a derived behaviour class.
 

Protected Member Functions

virtual ret_t init ()
 Initialisation callback for the behaviour. This function is called from BehaviourLayer::initAll(), and is intended to be overridden for the purpose of initialising the derived behaviour object.
 
virtual void update ()
 Update callback for the behaviour object. This function is called from BehaviourLayer::updateAll(), which is used in BehaviourLayer::step().
 
virtual void execute ()
 Execute callback for the behaviour object. This function is called from BehaviourLayer::executeAll(), which is used in BehaviourLayer::step().
 
virtual void inhibited ()
 A callback for the behaviour object that is invoked instead of execute() when the behaviour is deactivated. This function is called from BehaviourLayer::executeAll(), which is used in BehaviourLayer::step().
 
bool wasJustActivated () const
 Returns true when called from the execute() callback, and the behaviour was just activated. The return value is always true when called from inhibited().
 
bool wasJustDeactivated () const
 Returns true when called from the inhibited() callback, and the behaviour was just inhibited. The return value is always true when called from execute().
 
virtual level_t computeActivationLevel ()
 Callback for the computation of the raw behaviour activation level. Valid return values are false, true, LVL_INACTIVE, LVL_ACTIVE and floating point numbers between 0 and 1 inclusive (values outside this range are coerced).
 

Friends

class BehaviourLayer
 

Detailed Description

Implements a single behaviour.

This class is the base class of all behaviours that are used in an architecture.

Constructor & Destructor Documentation

Behaviour::Behaviour ( BehaviourLayer LBase,
const std::string &  name = nullString 
)
explicit

Default constructor.

Note that although the default value for the name parameter is nullString, this will not actually become the behaviour's name if the parameter is omitted. This is just used to signal to the class's internals that it should generate a default name using the getUniqueName() function. LBase must never be null or a segmentation fault will result!

Parameters
LBaseA pointer to the behaviour layer that the behaviour belongs to.
nameThe human-friendly name to give the behaviour (null means auto-generate).

Member Function Documentation

std::string Behaviour::getUniqueName ( const BehaviourLayer LBase) const

Returns a unique behaviour name.

Automatically construct a unique name for the behaviour, for situations where none is provided by the derived class. The name that results of this function will be unique as long as the user does not explicitly use the same name somewhere else, either before or after the construction of this behaviour. If there are currently four behaviours in the LBase layer, the generated name will be the concatenation of DEF_BEHAVIOUR_NAME and "4".

Parameters
LBaseA non-null pointer to the parent behaviour layer.
Returns
The required behaviour name.

The documentation for this class was generated from the following files: