|
|
This class is the implementation of the Slice Definition of a state. More...
#include <ArmarXCore/statechart/StateBase.h>
Inheritance diagram for StateBase: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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| 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. | |
| virtual void | defineParameters () |
| Virtual function, in which input/local/output parameters can be specified. | |
| virtual void | defineState () |
| Virtual function, in which this state can be configured. | |
| virtual void | defineSubstates () |
| Virtual function, in which substates, transition and mappings can be added. | |
| StateBasePtr | findSubstateByName (const std::string &substateName) |
| Utility function to find a substate of this state by the name. | |
| 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. | |
| std::string | getLocalHierarchyString () const |
| Function to get a string that contains als parent states and this state. (e.g. "Robot->Functional->Idling") | |
| 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 | |
| StatePhase | getStatePhase () const |
| EventPtr | getTriggeredEndstateEvent () const |
| This function returns the event that was triggered by entering an endstate. | |
| 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. | |
| virtual bool | isInitialized () const |
| Returns the status of this state. Only if a state is initialized, it can be used. | |
| 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. | |
| virtual void | onEnter () |
| Virtual function, in which the behaviour of state is defined, when it is entered. Can be overridden, but it is optional. | |
| virtual void | onExit () |
| Virtual function, in which the behaviour of state is defined, when it is exited. Can be overridden, but it is optional. | |
| StateBase & | operator= (const StateBase &source) |
| virtual void | refetchSubstates () |
| This functions updates the substates. | |
| void | reset () |
| Function to reset the state: clear name, clear substatesList, clear transition etc. | |
| virtual void | run () |
| Virtual function, that can be reimplemented to calculate complex operations. | |
| 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>. | |
| 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. | |
| MessageTypeT | getEffectiveLoggingLevel () const |
| Logging () | |
| void | setLocalMinimumLoggingLevel (MessageTypeT level) |
| With setLocalMinimumLoggingLevel the minimum verbosity-level of log-messages can be set. | |
| 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. | |
| 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.
| enum StatePhase |
| StateBase | ( | ) |
|
override |
| 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 |
| void __checkPhaseMin | ( | StateBase::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.
|
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.
|
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.
| void __setParentState | ( | StateBase * | parentState | ) |
| void __throwUnknownParameter | ( | const StateParameterMap & | paramMap, |
| const std::string & | key ) const |
| void __updateGlobalStateId | ( | ) |
|
virtual |
Reimplemented in RemoteState.
| bool addParameter | ( | StateParameterMap & | paramMap, |
| const std::string & | key, | ||
| VariantTypeId | type, | ||
| bool | optional, | ||
| VariantPtr | defaultValue = VariantPtr() ) const |
| bool addParameterContainer | ( | StateParameterMap & | paramMap, |
| const std::string & | key, | ||
| const ContainerType & | containerType, | ||
| bool | optional, | ||
| VariantContainerBasePtr | defaultValue = VariantContainerBasePtr() ) const |
| 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 DynamicRemoteState, NoUserCodeState, RemoteState, RemoteStateWrapper, State, StateTemplate< StateType >, StateTemplate< CounterStateTemplate< EvCounterNotFulfilled, EvCounterFulfilled > >, StateTemplate< FinalState< EvDummy > >, StateTemplate< IceGeneratedState >, StateTemplate< RobotPreInitialized >, StateTemplate< Stateadd_x_to_y >, StateTemplate< Statechart_Robot >, StateTemplate< Statechart_StatechartPerfomanceTest >, StateTemplate< Statechart_StateParameterExample >, StateTemplate< StatechartClient >, StateTemplate< StatechartInstallConditionExample >, StateTemplate< stateInstallCondition >, StateTemplate< stateInstallTimeout >, StateTemplate< StateResult >, StateTemplate< StateRobotControl >, StateTemplate< StateRun >, and StateTemplate< TimeoutExampleStatechart >.
|
pure virtual |
Implemented in DynamicRemoteState, RemoteState, RemoteStateWrapper, and State.
|
virtual |
Function to copy the states with all it substates and transitions.
Creates new copies of all substates and copies them as well.
|
inlinevirtual |
Virtual function, in which input/local/output parameters can be specified.
Reimplemented in CounterStateTemplate< EventTypeConditionNotFulfilled, EventTypeConditionFulfilled >, CounterStateTemplate< EvCounterNotFulfilled, EvCounterFulfilled >, CounterStateTemplate< EvCounterNotFulfilled, EvCounterFulfilled >, DynamicRemoteState, FinalStateBase< EventType, StateType >, FinalStateBase< EvDummy, FinalState< EvDummy > >, Stateadd_x_to_y, Statechart_StatechartPerfomanceTest, Statechart_StateParameterExample, StatechartClient, StatechartInstallConditionExample, StateResult, StateRun, StateRun, and XMLState.
|
inlinevirtual |
Virtual function, in which this state can be configured.
Function gets automatically called in init();
Reimplemented in Statechart_Robot, Statechart_StatechartPerfomanceTest, Statechart_StateParameterExample, StatechartClient, StatechartInstallConditionExample, StateRun, and TimeoutExampleStatechart.
|
inlinevirtual |
Virtual function, in which substates, transition and mappings can be added.
Reimplemented in Stateadd_x_to_y, Statechart_Robot, Statechart_StatechartPerfomanceTest, Statechart_StateParameterExample, StatechartClient, StatechartInstallConditionExample, StateRobotControl, TimeoutExampleStatechart, and XMLState.
| 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 |
|
static |
|
inline |
| 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 RemoteState, and State.
| std::string getLocalHierarchyString | ( | ) | const |
Function to get a string that contains als parent states and this state. (e.g. "Robot->Functional->Idling")
| Ice::Int getLocalUniqueId | ( | ) | const |
|
virtual |
Reimplemented in RemoteState, and State.
| void getParameter | ( | const StateParameterMap & | paramMap, |
| const std::string & | key, | ||
| VariantPtr & | value ) const |
| void getParameterContainer | ( | const StateParameterMap & | paramMap, |
| const std::string & | key, | ||
| VariantContainerBasePtr & | valueContainer ) const |
| const std::string & getStateClassName | ( | ) | const |
| std::string getStateName | ( | ) | const |
getStateName
| StateBase::StatePhase getStatePhase | ( | ) | const |
| EventPtr getTriggeredEndstateEvent | ( | ) | const |
| 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.
|
virtual |
Returns the status of this state. Only if a state is initialized, it can be used.
Reimplemented in RemoteState.
| 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 MoveJointsPosControl, MoveJointsPosVelControl, MoveJointsVelControl, CheckForceTorqueSensors, CheckObjectInHand, CheckTactileSensors, DetectCollision, StateRun, and LookBetweenHandAndObject.
|
virtual |
Virtual function, in which the behaviour of state is defined, when it is entered.
Can be overridden, but it is optional.
Reimplemented in CounterStateTemplate< EventTypeConditionNotFulfilled, EventTypeConditionFulfilled >, CounterStateTemplate< EvCounterNotFulfilled, EvCounterFulfilled >, CounterStateTemplate< EvCounterNotFulfilled, EvCounterFulfilled >, FinalStateBase< EventType, StateType >, FinalStateBase< EvDummy, FinalState< EvDummy > >, CalcVelocities, CloseHandWithJointAngles, CloseHandWithTorques, ControlModeChooser, FindAndGraspObject, GraspingWithTorques, InstallTerminateConditions, LiftObject, LocalizeObject, MoveJointsPosControl, MoveJointsPosVelControl, MoveJointsVelControl, Preshape, SelectObject, ValidateTcpPose, VisualServo, VisualServoObject, VisualServoWrapper, WaitForUpdates, CheckForceTorqueSensors, CheckObjectInHand, CheckTactileSensors, DetectCollision, RobotPreInitialized, Stateadd_x_to_y, Statechart_StateParameterExample, StatechartInstallConditionExample, stateInstallCondition, stateInstallTimeout, StateResult, StateRobotControl, StateRun, StateRun, and LookBetweenHandAndObject.
|
virtual |
Virtual function, in which the behaviour of state is defined, when it is exited. Can be overridden, but it is optional.
Reimplemented in CounterStateTemplate< EventTypeConditionNotFulfilled, EventTypeConditionFulfilled >, CounterStateTemplate< EvCounterNotFulfilled, EvCounterFulfilled >, CounterStateTemplate< EvCounterNotFulfilled, EvCounterFulfilled >, CalcVelocities, CloseHandWithJointAngles, CloseHandWithTorques, FindAndGraspObject, GraspingWithTorques, InstallTerminateConditions, LiftObject, LocalizeObject, MoveJointsPosControl, MoveJointsPosVelControl, MoveJointsVelControl, Preshape, SelectObject, VisualServo, VisualServoObject, VisualServoWrapper, WaitForUpdates, CheckForceTorqueSensors, CheckObjectInHand, CheckTactileSensors, DetectCollision, stateInstallCondition, stateInstallTimeout, StateRun, StateRun, and LookBetweenHandAndObject.
|
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.
| void reset | ( | ) |
Function to reset the state: clear name, clear substatesList, clear transition etc.
|
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 MoveJointsPosControl, MoveJointsPosVelControl, CheckForceTorqueSensors, CheckObjectInHand, CheckTactileSensors, DetectCollision, CalculateJointAngleConfiguration, and RemoteStateOffererBase.
| void setContext | ( | StatechartContextInterface * | context | ) |
| void setInitialized | ( | bool | enable | ) |
| void setParameter | ( | StateParameterMap & | paramMap, |
| const std::string & | key, | ||
| const Variant & | variant ) |
| 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) |
| void setStatePhase | ( | StateBase::StatePhase | newPhase | ) |
|
virtual |
Reimplemented in RemoteState.
| std::unique_ptr<Impl> impl |