22#include <rclcpp/rclcpp.hpp>
28namespace client_behaviors
36 std::unique_lock<std::recursive_mutex> lock(
getStateMachine()->getMutex(), std::defer_lock);
37 while (!lock.try_lock())
40 rclcpp::sleep_for(std::chrono::milliseconds(1));
46 getLogger(),
"[SequenceNode %p] next onEntry: %ld",
static_cast<const void *
>(
this),
50 auto onDelayedConfigureFn = first;
53 getLogger(),
"[SequenceNode %p] Behavior on delayed sequence configure",
54 static_cast<const void *
>(
this));
55 bh_ = onDelayedConfigureFn();
56 std::string currentNodeName =
bh_->getName();
59 getLogger(),
"[SequenceNode %p] Subscribing OnSuccess",
static_cast<const void *
>(
this));
64 getLogger(),
"[SequenceNode %p] subnode %s on entry",
static_cast<const void *
>(
this),
65 currentNodeName.c_str());
66 bh_->executeOnEntry();
69 getLogger(),
"[SequenceNode %p] subnode %s on entry finished",
static_cast<const void *
>(
this),
70 currentNodeName.c_str());
71 bh_->waitOnEntryThread(
false);
73 getLogger(),
"[SequenceNode %p] subnode %s thread finished",
static_cast<const void *
>(
this),
74 currentNodeName.c_str());
84 if (is_shutdown_requested)
89 rclcpp::sleep_for(std::chrono::milliseconds(200));
90 const auto & head = *
bh_;
93 "[CbSequence %p] Waiting for subnodes to finish %ld. Current head Behavior: %s ",
98 this->
conn_.disconnect();
114 getLogger(),
"[CbSequence %p] All subnodes finished",
static_cast<const void *
>(
this));
119 RCLCPP_INFO(
getLogger(),
"[CbSequence %p] Aborting",
static_cast<const void *
>(
this));
127 getLogger(),
"[CbSequence %p] Success NextCbSequence %ld",
static_cast<const void *
>(
this),
135 getLogger(),
"[CbSequence %p] Abort NextCbSequence %ld",
static_cast<const void *
>(
this),
137 this->
conn_.disconnect();
138 this->
conn2_.disconnect();
142 getLogger(),
"[CbSequence %p] Abort NextCbSequence requesting for force finish",
143 static_cast<const void *
>(
this));
virtual rclcpp::Logger getLogger() const
virtual rclcpp::Node::SharedPtr getNode() const
ISmaccStateMachine * getStateMachine()
bool isShutdownRequested()
onEntry is executed in a new thread. However the current state cannot be left until the onEntry threa...
void requestForceFinish()
bool recursiveConsumeNext()
std::atomic< int > consume_
smacc2::SmaccSignalConnection conn_
smacc2::SmaccSignalConnection conn2_
std::list< std::function< std::shared_ptr< smacc2::SmaccAsyncClientBehavior >()> > sequenceNodes_
std::shared_ptr< smacc2::SmaccAsyncClientBehavior > bh_
std::string demangleType(const std::type_info *tinfo)