MCPcopy Create free account
hub / github.com/BehaviorTree/BehaviorTree.CPP / tickRoot

Method tickRoot

src/bt_factory.cpp:718–756  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

716}
717
718NodeStatus Tree::tickRoot(TickOption opt, std::chrono::milliseconds sleep_time)
719{
720 NodeStatus status = NodeStatus::IDLE;
721
722 if(!wake_up_)
723 {
724 initialize();
725 }
726
727 if(rootNode() == nullptr)
728 {
729 throw RuntimeError("Empty Tree");
730 }
731
732 while(status == NodeStatus::IDLE ||
733 (opt == TickOption::WHILE_RUNNING && status == NodeStatus::RUNNING))
734 {
735 status = rootNode()->executeTick();
736
737 // Inner loop. The previous tick might have triggered the wake-up
738 // in this case, unless TickOption::EXACTLY_ONCE, we tick again
739 while(opt != TickOption::EXACTLY_ONCE && status == NodeStatus::RUNNING &&
740 wake_up_->waitFor(std::chrono::milliseconds(0)))
741 {
742 status = rootNode()->executeTick();
743 }
744
745 if(isStatusCompleted(status))
746 {
747 rootNode()->resetStatus();
748 }
749 if(status == NodeStatus::RUNNING && sleep_time.count() > 0)
750 {
751 sleep(std::chrono::milliseconds(sleep_time));
752 }
753 }
754
755 return status;
756}
757
758void BlackboardRestore(const std::vector<Blackboard::Ptr>& backup, Tree& tree)
759{

Callers

nothing calls this directly

Calls 5

RuntimeErrorClass · 0.85
isStatusCompletedFunction · 0.85
waitForMethod · 0.80
resetStatusMethod · 0.80
executeTickMethod · 0.45

Tested by

no test coverage detected