|
#include <ArmarXCore/statechart/StateBase.h>
Classes | |
struct | eUnexpectedEvent |
struct | Impl |
Public Types | |
enum | StatePhase { ePreDefined, eStatechartDefinitions, eSubstatesDefinitions, eParametersDefinitions, eDefined, eEntering, eEntered, eBreaking, eExiting, eExited } |
enum that specifies the phase in which the state is currently in used to control the usage of state-functions in the correct context More... | |
Public Member Functions | |
void | __checkPhase (const std::vector< StatePhase > &allowedTypes, const char *functionName) const |
void | __checkPhase (StatePhase allowedType, const char *functionName) const |
Helper function for checking if a function was called in valid position of the statechart. More... | |
void | __checkPhaseMin (StatePhase allowedType, const char *functionName) const |
void | __copyDefaultValuesToInput () |
StringVariantContainerBaseMap | __getSetInputAndLocalParameters () const |
Combines both maps to one map and returns a new map of only the set parameters. More... | |
virtual bool | __hasActiveSubstate () |
Virtual function to indicate wheter a state has an active substate or not. To be overridden by RemoteState to deligate the call to the real state. More... | |
virtual bool | __hasSubstates () |
Virtual function to indicate wheter a state has substates or not. To be overridden by RemoteState to deligate the call to the real state. More... | |
void | __setParentState (StateBase *parentState) |
void | __throwUnknownParameter (const StateParameterMap ¶mMap, const std::string &key) const |
void | __updateGlobalStateId () |
virtual void | __updateGlobalStateIdRecursive () |
bool | addParameter (StateParameterMap ¶mMap, const std::string &key, VariantTypeId type, bool optional, VariantPtr defaultValue=VariantPtr()) const |
bool | addParameterContainer (StateParameterMap ¶mMap, const std::string &key, const ContainerType &containerType, bool optional, VariantContainerBasePtr defaultValue=VariantContainerBasePtr()) const |
void | clearSelfPointer () |
virtual StateBasePtr | clone () const =0 |
Pure virtual function to clone of the derived class type. More... | |
virtual StateBasePtr | createEmptyCopy () const =0 |
virtual void | deepCopy (const StateBase &sourceState, bool reset=true) |
Function to copy the states with all it substates and transitions. More... | |
virtual void | defineParameters () |
Virtual function, in which input/local/output parameters can be specified. More... | |
virtual void | defineState () |
Virtual function, in which this state can be configured. More... | |
virtual void | defineSubstates () |
Virtual function, in which substates, transition and mappings can be added. More... | |
StateBasePtr | findSubstateByName (const std::string &substateName) |
Utility function to find a substate of this state by the name. More... | |
template<typename ContextType > | |
ContextType * | getContext () const |
StatechartContextInterface * | getContext (bool checkNULL=true) const |
std::string | getGlobalHierarchyString () const |
virtual StateParameterMap | getInputParameters ()=0 |
Not const because RemoteState implementation gets the current parameters via Ice and sets them. More... | |
std::string | getLocalHierarchyString () const |
Function to get a string that contains als parent states and this state. (e.g. "Robot->Functional->Idling") More... | |
Ice::Int | getLocalUniqueId () const |
virtual StateParameterMap & | getOutputParameters () |
void | getParameter (const StateParameterMap ¶mMap, const std::string &key, VariantPtr &value) const |
void | getParameterContainer (const StateParameterMap ¶mMap, const std::string &key, VariantContainerBasePtr &valueContainer) const |
const std::string & | getStateClassName () const |
std::string | getStateName () const |
getStateName More... | |
StatePhase | getStatePhase () const |
EventPtr | getTriggeredEndstateEvent () const |
This function returns the event that was triggered by entering an endstate. More... | |
void | inheritInputParameters () |
bool | init (StatechartContextInterface *context, StatechartManager *manager) |
Function to initialize this state. Must be called in the highest level of the hierarchy - and only there. More... | |
virtual bool | isInitialized () const |
Returns the status of this state. Only if a state is initialized, it can be used. More... | |
bool | isParameterSet (const StateParameterMap ¶mMap, const std::string &key) const |
virtual void | onBreak () |
Virtual function, in which the behaviour of state is defined, when it is abnormally exited. Can be overridden, but it is optional. An abnormal exit only occurs in hierarchy-levels greater 1. When a parent state is left before the substates are finished, the OnBreak()-function is called in the active substate and in all it's active substates. If this function is not implemented, the normal OnExit()-function is called. More... | |
virtual void | onEnter () |
Virtual function, in which the behaviour of state is defined, when it is entered. Can be overridden, but it is optional. More... | |
virtual void | onExit () |
Virtual function, in which the behaviour of state is defined, when it is exited. Can be overridden, but it is optional. More... | |
StateBase & | operator= (const StateBase &source) |
virtual void | refetchSubstates () |
This functions updates the substates. More... | |
void | reset () |
Function to reset the state: clear name, clear substatesList, clear transition etc. More... | |
virtual void | run () |
Virtual function, that can be reimplemented to calculate complex operations. More... | |
void | setContext (StatechartContextInterface *context) |
void | setInitialized (bool enable) |
void | setParameter (StateParameterMap ¶mMap, const std::string &key, const Variant &variant) |
void | setParameterContainer (StateParameterMap ¶mMap, const std::string &key, const VariantContainerBase &valueContainer) |
void | setParameterContainer (StateParameterMap ¶mMap, const std::string &key, const VariantContainerBasePtr &valueContainer) |
void | setStateClassName (std::string className) |
setStateClassName() sets the string, that contains a stringrepresentation of this class. Should not be called usually. The classname gets automatically set in the constructor of the derived class StateTemplate<T>. More... | |
void | setStatePhase (StatePhase newPhase) |
StateBase () | |
StateBase (const StateBase &source) | |
virtual bool | waitForInitialization (int timeoutMS=-1) const |
~StateBase () override | |
Public Member Functions inherited from Logging | |
SpamFilterDataPtr | deactivateSpam (float deactivationDurationSec=10.0f, const std::string &identifier="", bool deactivate=true) const |
disables the logging for the current line for the given amount of seconds. More... | |
MessageTypeT | getEffectiveLoggingLevel () const |
Logging () | |
void | setLocalMinimumLoggingLevel (MessageTypeT level) |
With setLocalMinimumLoggingLevel the minimum verbosity-level of log-messages can be set. More... | |
void | setTag (const LogTag &tag) |
void | setTag (const std::string &tagName) |
virtual | ~Logging () |
Static Public Member Functions | |
static std::vector< StateBasePtr > | GetActiveStateLeafs (StateBasePtr toplevelState) |
Public Attributes | |
std::unique_ptr< Impl > | impl |
Additional Inherited Members | |
Protected Member Functions inherited from Logging | |
bool | checkLogLevel (MessageTypeT level) const |
const LogSenderPtr & | getLogSender () const |
Retrieve log sender. More... | |
LogSenderPtr | loghelper (const char *file, int line, const char *function) const |
Protected Attributes inherited from Logging | |
MessageTypeT | minimumLoggingLevel |
SpamFilterDataPtr | spamFilter |
LogTag | tag |
This class is the implementation of the Slice Definition of a state. It is the baseclass for most statechart related classes. Basic functionality like data member handling is implemented here.
Definition at line 61 of file StateBase.h.
enum StatePhase |
enum that specifies the phase in which the state is currently in used to control the usage of state-functions in the correct context
Enumerator | |
---|---|
ePreDefined | |
eStatechartDefinitions | |
eSubstatesDefinitions | |
eParametersDefinitions | |
eDefined | |
eEntering | |
eEntered | |
eBreaking | |
eExiting | |
eExited |
Definition at line 265 of file StateBase.h.
StateBase | ( | ) |
|
override |
Definition at line 106 of file StateBase.cpp.
void __checkPhase | ( | const std::vector< StatePhase > & | allowedTypes, |
const char * | functionName | ||
) | const |
void __checkPhase | ( | StateBase::StatePhase | allowedType, |
const char * | functionName | ||
) | const |
Helper function for checking if a function was called in valid position of the statechart.
LocalException | if allowedType does not match the current phase type |
Definition at line 134 of file StateBase.cpp.
void __checkPhaseMin | ( | StateBase::StatePhase | allowedType, |
const char * | functionName | ||
) | const |
Definition at line 225 of file StateBase.cpp.
void __copyDefaultValuesToInput | ( | ) |
StringVariantContainerBaseMap __getSetInputAndLocalParameters | ( | ) | const |
Combines both maps to one map and returns a new map of only the set parameters.
Definition at line 856 of file StateBase.cpp.
|
virtual |
Virtual function to indicate wheter a state has an active substate or not. To be overridden by RemoteState to deligate the call to the real state.
Reimplemented in RemoteState.
Definition at line 300 of file StateBase.cpp.
|
virtual |
Virtual function to indicate wheter a state has substates or not. To be overridden by RemoteState to deligate the call to the real state.
Reimplemented in RemoteState.
Definition at line 290 of file StateBase.cpp.
void __setParentState | ( | StateBase * | parentState | ) |
void __throwUnknownParameter | ( | const StateParameterMap & | paramMap, |
const std::string & | key | ||
) | const |
Definition at line 743 of file StateBase.cpp.
void __updateGlobalStateId | ( | ) |
Definition at line 254 of file StateBase.cpp.
|
virtual |
Reimplemented in RemoteState.
Definition at line 273 of file StateBase.cpp.
bool addParameter | ( | StateParameterMap & | paramMap, |
const std::string & | key, | ||
VariantTypeId | type, | ||
bool | optional, | ||
VariantPtr | defaultValue = VariantPtr() |
||
) | const |
Definition at line 585 of file StateBase.cpp.
bool addParameterContainer | ( | StateParameterMap & | paramMap, |
const std::string & | key, | ||
const ContainerType & | containerType, | ||
bool | optional, | ||
VariantContainerBasePtr | defaultValue = VariantContainerBasePtr() |
||
) | const |
Definition at line 602 of file StateBase.cpp.
void clearSelfPointer | ( | ) |
|
pure virtual |
Pure virtual function to clone of the derived class type.
Implemented function should create a new instance with new and return the StateBasePtr. The new instance should contain a reseted, but initialized version of the original.
Implemented in State, NoUserCodeState, RemoteState, DynamicRemoteState, and RemoteStateWrapper.
|
pure virtual |
Implemented in State, RemoteState, DynamicRemoteState, and RemoteStateWrapper.
|
virtual |
Function to copy the states with all it substates and transitions.
Creates new copies of all substates and copies them as well.
Definition at line 316 of file StateBase.cpp.
|
inlinevirtual |
Virtual function, in which input/local/output parameters can be specified.
Reimplemented in XMLState, and DynamicRemoteState.
Definition at line 174 of file StateBase.h.
|
inlinevirtual |
Virtual function, in which this state can be configured.
Function gets automatically called in init();
Definition at line 162 of file StateBase.h.
|
inlinevirtual |
Virtual function, in which substates, transition and mappings can be added.
Reimplemented in XMLState.
Definition at line 168 of file StateBase.h.
StateBasePtr findSubstateByName | ( | const std::string & | substateName | ) |
Utility function to find a substate of this state by the name.
If somehow multiple state with the same name exist, the first state is returned.
substateName |
Definition at line 788 of file StateBase.cpp.
|
static |
Definition at line 864 of file StateBase.cpp.
|
inline |
Definition at line 74 of file StateBase.h.
StatechartContextInterface * getContext | ( | bool | checkNULL = true | ) | const |
std::string getGlobalHierarchyString | ( | ) | const |
|
pure virtual |
Not const because RemoteState implementation gets the current parameters via Ice and sets them.
Implemented in State, and RemoteState.
std::string getLocalHierarchyString | ( | ) | const |
Function to get a string that contains als parent states and this state. (e.g. "Robot->Functional->Idling")
Definition at line 538 of file StateBase.cpp.
Ice::Int getLocalUniqueId | ( | ) | const |
|
virtual |
Reimplemented in RemoteState, and State.
Definition at line 518 of file StateBase.cpp.
void getParameter | ( | const StateParameterMap & | paramMap, |
const std::string & | key, | ||
VariantPtr & | value | ||
) | const |
Definition at line 801 of file StateBase.cpp.
void getParameterContainer | ( | const StateParameterMap & | paramMap, |
const std::string & | key, | ||
VariantContainerBasePtr & | valueContainer | ||
) | const |
Definition at line 714 of file StateBase.cpp.
const std::string & getStateClassName | ( | ) | const |
std::string getStateName | ( | ) | const |
getStateName
Definition at line 523 of file StateBase.cpp.
StateBase::StatePhase getStatePhase | ( | ) | const |
EventPtr getTriggeredEndstateEvent | ( | ) | const |
This function returns the event that was triggered by entering an endstate.
This is useful in the onExit() function to determine which endstate of the substates was triggered.
Definition at line 839 of file StateBase.cpp.
void inheritInputParameters | ( | ) |
Definition at line 755 of file StateBase.cpp.
bool init | ( | StatechartContextInterface * | context, |
StatechartManager * | manager | ||
) |
Function to initialize this state. Must be called in the highest level of the hierarchy - and only there.
Definition at line 420 of file StateBase.cpp.
|
virtual |
Returns the status of this state. Only if a state is initialized, it can be used.
Reimplemented in RemoteState.
Definition at line 579 of file StateBase.cpp.
bool isParameterSet | ( | const StateParameterMap & | paramMap, |
const std::string & | key | ||
) | const |
|
virtual |
Virtual function, in which the behaviour of state is defined, when it is abnormally exited. Can be overridden, but it is optional.
An abnormal exit only occurs in hierarchy-levels greater 1.
When a parent state is left before the substates are finished, the OnBreak()-function is called in the active substate and in all it's active substates.
If this function is not implemented, the normal OnExit()-function is called.
Reimplemented in CheckObjectInHand, MoveJointsVelControl, MoveJointsPosControl, MoveJointsPosVelControl, LookBetweenHandAndObject, CheckForceTorqueSensors, CheckTactileSensors, and DetectCollision.
Definition at line 489 of file StateBase.cpp.
|
virtual |
Virtual function, in which the behaviour of state is defined, when it is entered.
Can be overridden, but it is optional.
Reimplemented in ControlModeChooser, InstallTerminateConditions, Preshape, LiftObject, SelectObject, CalcVelocities, CloseHandWithJointAngles, CloseHandWithTorques, MoveJointsVelControl, WaitForUpdates, VisualServoWrapper, CheckObjectInHand, GraspingWithTorques, ValidateTcpPose, LocalizeObject, VisualServoObject, VisualServo, LookBetweenHandAndObject, FindAndGraspObject, MoveJointsPosControl, MoveJointsPosVelControl, CheckForceTorqueSensors, CheckTactileSensors, and DetectCollision.
Definition at line 496 of file StateBase.cpp.
|
virtual |
Virtual function, in which the behaviour of state is defined, when it is exited. Can be overridden, but it is optional.
Reimplemented in InstallTerminateConditions, CheckObjectInHand, Preshape, LiftObject, MoveJointsVelControl, SelectObject, CalcVelocities, CloseHandWithJointAngles, CloseHandWithTorques, MoveJointsPosControl, MoveJointsPosVelControl, WaitForUpdates, VisualServoWrapper, LookBetweenHandAndObject, GraspingWithTorques, LocalizeObject, VisualServoObject, VisualServo, CheckForceTorqueSensors, CheckTactileSensors, DetectCollision, and FindAndGraspObject.
Definition at line 506 of file StateBase.cpp.
Definition at line 98 of file StateBase.cpp.
|
virtual |
This functions updates the substates.
For local states only calls the substates refetch function, but for remoteStates requests the data via Ice.
Reimplemented in RemoteState.
Definition at line 830 of file StateBase.cpp.
void reset | ( | ) |
Function to reset the state: clear name, clear substatesList, clear transition etc.
Definition at line 887 of file StateBase.cpp.
|
virtual |
Virtual function, that can be reimplemented to calculate complex operations.
It runs in it's own thread.
This function is called after onEnter(). This function can continue to run even if the state has been left (onExit() has been called), but all calculations will be discarded (Output- and Localparameters will be reseted).
Calls to external components will still be executed!
Calls to sendEvent() will be ignored, after the state has been left.
Reimplemented in RemoteStateOffererBase, CheckObjectInHand, CalculateJointAngleConfiguration, MoveJointsPosControl, MoveJointsPosVelControl, CheckForceTorqueSensors, CheckTactileSensors, and DetectCollision.
Definition at line 500 of file StateBase.cpp.
void setContext | ( | StatechartContextInterface * | context | ) |
Definition at line 513 of file StateBase.cpp.
void setInitialized | ( | bool | enable | ) |
void setParameter | ( | StateParameterMap & | paramMap, |
const std::string & | key, | ||
const Variant & | variant | ||
) |
Definition at line 662 of file StateBase.cpp.
void setParameterContainer | ( | StateParameterMap & | paramMap, |
const std::string & | key, | ||
const VariantContainerBase & | valueContainer | ||
) |
void setParameterContainer | ( | StateParameterMap & | paramMap, |
const std::string & | key, | ||
const VariantContainerBasePtr & | valueContainer | ||
) |
void setStateClassName | ( | std::string | className | ) |
setStateClassName() sets the string, that contains a stringrepresentation of this class. Should not be called usually. The classname gets automatically set in the constructor of the derived class StateTemplate<T>.
className | Stringrepresentation of the classname (e.g. StateBase for this class) |
Definition at line 824 of file StateBase.cpp.
void setStatePhase | ( | StateBase::StatePhase | newPhase | ) |
|
virtual |
Reimplemented in RemoteState.
Definition at line 559 of file StateBase.cpp.
std::unique_ptr<Impl> impl |
Definition at line 258 of file StateBase.h.