10#include <smacc_msgs/SmaccStatus.h>
11#include <smacc_msgs/SmaccTransitionLogEntry.h>
16 : private_nh_(
"~"), stateSeqCounter_(0)
18 ROS_INFO(
"Creating State Machine Base");
23 if (
nh_.getParam(
"run_mode", runMode))
25 if (runMode ==
"debug")
29 else if (runMode ==
"release")
35 ROS_ERROR(
"Incorrect run_mode value: %s", runMode.c_str());
46 ROS_INFO(
"[SmaccSignals] object signal disconnecting %ld", (
long)object_ptr);
50 callbackSemaphore->finalize();
55 ROS_INFO(
"[SmaccSignals] no signals found %ld", (
long)object_ptr);
61 ROS_INFO(
"Finishing State Machine");
83 std::lock_guard<std::recursive_mutex> lock(
m_mutex_);
87 ROS_WARN_STREAM(
"[StateMachine] setting state active "
93 std::list<const SmaccStateInfo *> ancestorList;
96 for (
auto &ancestor : ancestorList)
98 status_msg_.current_states.push_back(ancestor->toShortName());
106 status_msg_.global_variable_names.push_back(entry.first);
107 status_msg_.global_variable_values.push_back(entry.second.first());
119 smacc_msgs::SmaccTransitionLogEntry transitionLogEntry;
120 transitionLogEntry.timestamp = ros::Time::now();
138 ROS_WARN_STREAM(
"State machine base creation:" << shortname);
140 stateMachinePub_ =
nh_.advertise<smacc_msgs::SmaccStateMachine>(shortname +
"/smacc/state_machine_description", 1);
142 transitionLogPub_ =
nh_.advertise<smacc_msgs::SmaccTransitionLogEntry>(shortname +
"/smacc/transition_log", 1);
150 ROS_WARN(
"Requesting Transition Log History, current size: %ld", this->
transitionLogHistory_.size());
157 std::lock_guard<std::recursive_mutex> lock(
m_mutex_);
159 smacc_msgs::SmaccStateMachine state_machine_msg;
169 ROS_DEBUG(
"locking state machine: %s", msg.c_str());
175 ROS_DEBUG(
"unlocking state machine: %s", msg.c_str());
void publishTransition(const SmaccTransitionInfo &transitionInfo)
std::shared_ptr< SmaccStateMachineInfo > stateMachineInfo_
void initializeROS(std::string smshortname)
std::string getStateMachineName()
SignalDetector * signalDetector_
ISmaccStateMachine(SignalDetector *signalDetector)
smacc_msgs::SmaccStatus status_msg_
virtual ~ISmaccStateMachine()
ros::Publisher stateMachineStatusPub_
void lockStateMachine(std::string msg)
ros::ServiceServer transitionHistoryService_
const std::map< std::string, std::shared_ptr< smacc::ISmaccOrthogonal > > & getOrthogonals() const
std::shared_ptr< SmaccStateInfo > currentStateInfo_
smacc::SMRunMode runMode_
std::map< void *, std::shared_ptr< CallbackCounterSemaphore > > stateCallbackConnections
std::recursive_mutex m_mutex_
void state_machine_visualization(const ros::TimerEvent &)
virtual void onInitialize()
this function should be implemented by the user to create the orthogonals
ros::Publisher transitionLogPub_
std::map< std::string, std::shared_ptr< smacc::ISmaccOrthogonal > > orthogonals_
void updateStatusMessage()
std::map< std::string, std::pair< std::function< std::string()>, boost::any > > globalData_
void unlockStateMachine(std::string msg)
void disconnectSmaccSignalObject(void *object)
void getTransitionLogHistory()
void checkStateMachineConsistence()
ros::Publisher stateMachinePub_
std::vector< smacc_msgs::SmaccTransitionLogEntry > transitionLogHistory_
void initialize(ISmaccStateMachine *stateMachine)
void transitionInfoToMsg(const SmaccTransitionInfo &transition, smacc_msgs::SmaccTransition &transitionMsg)
std::string demangleSymbol()