Skip to content

Conversation

@pleemann
Copy link
Contributor

I have a tree, which checks some pre-conditions in our system state, using a ReactiveSequence, and executes some (re)actions if they are not met. The pre-conditions are checked using a simple custom node, which reads the system state.
I have a callback mechanism, which notifies me when the system state changes, and I would like to tick the tree based on these events instead of a fixed rate. The callbacks can be executed from different threads, so I would like to avoid ticking the tree in the callback directly.

What seems to work is something like this:

void ReactionManager::workerMain() {
  while (!exitWorkerLoop_) {
    tree_->tickOnce();
    tree_->sleep(std::chrono::milliseconds(10000));
  }
}

void ReactionManager::wakeupWorker() {
  if (tree_) {
    if (!tree_->subtrees.empty()) {
      auto& nodes = tree_->subtrees.front()->nodes;
      if (!nodes.empty()) {
        nodes.front()->emitWakeUpSignal();
      }
    }
  }
}

However, I wondered why the Tree itself does not have such a emitWakeUpSignal? This pull request adds this method.

@facontidavide facontidavide merged commit 08605d1 into BehaviorTree:master Oct 30, 2025
10 checks passed
@facontidavide
Copy link
Collaborator

makes sense

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants