SMACC
Loading...
Searching...
No Matches
smacc_state.cpp
Go to the documentation of this file.
1#include <smacc/smacc_state.h>
3
4namespace smacc
5{
7{
8 return demangleSymbol(typeid(*this).name());
9}
10
12{
13 ROS_INFO_STREAM("NOTIFY TRANSITION: " << transitionType->getFullName());
14
15 //auto currstateinfo = this->getStateMachine().getCurrentStateInfo();
16 auto currstateinfo = this->stateInfo_;
17
18 if (currstateinfo != nullptr)
19 {
20 //ROS_ERROR_STREAM("CURRENT STATE INFO: " << currstateinfo->fullStateName);
21 for (auto &transition : currstateinfo->transitions_)
22 {
23 std::string transitionCandidateName = transition.transitionTypeInfo->getFullName();
24 //ROS_ERROR_STREAM("candidate transition: " << transitionCandidateName);
25
26 if (transitionType->getFullName() == transitionCandidateName)
27 {
28 this->getStateMachine().publishTransition(transition);
29 return;
30 }
31 }
32
33 // debug information if not found
34 ROS_ERROR_STREAM("Transition happened, from current state " << currstateinfo->getDemangledFullName() << " but there is not any transitioninfo match available to publish transition: " << transitionType->getFullName());
35 std::stringstream ss;
36
37 auto stateinfo = currstateinfo;
38
39 for (auto &transition : currstateinfo->transitions_)
40 {
41 std::string transitionCandidateName = transition.transitionTypeInfo->getFullName();
42 ROS_ERROR_STREAM("- candidate transition: " << transitionCandidateName);
43 }
44
45 ROS_ERROR("Ancestors candidates: ");
46
47 std::list<const SmaccStateInfo *> ancestors;
48 stateinfo->getAncestors(ancestors);
49
50 for (auto &ancestor : ancestors)
51 {
52 ROS_ERROR_STREAM(" * Ancestor " << ancestor->getDemangledFullName() << ":");
53 for (auto &transition : ancestor->transitions_)
54 {
55 std::string transitionCandidateName = transition.transitionTypeInfo->getFullName();
56 ROS_ERROR_STREAM("- candidate transition: " << transitionCandidateName);
57 if (transitionType->getFullName() == transitionCandidateName)
58 {
59 ROS_ERROR("GOTCHA");
60 }
61 }
62 }
63 }
64 else
65 {
66 ROS_ERROR_STREAM("Transition happened, but current state was not set. Transition candidates:");
67 }
68}
69
70} // namespace smacc
void publishTransition(const SmaccTransitionInfo &transitionInfo)
virtual std::string getClassName()
Definition: smacc_state.cpp:6
virtual ISmaccStateMachine & getStateMachine()=0
void notifyTransitionFromTransitionTypeInfo(std::shared_ptr< smacc::introspection::TypeInfo > &transitionTypeInfo)
Definition: smacc_state.cpp:11
const smacc::introspection::SmaccStateInfo * stateInfo_
Definition: smacc_state.h:95
std::shared_ptr< TypeInfo > Ptr
std::string demangleSymbol()
Definition: introspection.h:75