| 716 | } |
| 717 | |
| 718 | NodeStatus 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 | |
| 758 | void BlackboardRestore(const std::vector<Blackboard::Ptr>& backup, Tree& tree) |
| 759 | { |
nothing calls this directly
no test coverage detected