Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

haltTree doesn't effectively halt tickWhileRunning #686

Open
tony-p opened this issue Oct 30, 2023 · 5 comments
Open

haltTree doesn't effectively halt tickWhileRunning #686

tony-p opened this issue Oct 30, 2023 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@tony-p
Copy link
Contributor

tony-p commented Oct 30, 2023

haltTree resets the tree status to IDLE which then in the tickRoot only breaks out of the inner loop, which is then restarted by the outer loop

NodeStatus Tree::tickRoot(TickOption opt, std::chrono::milliseconds sleep_time)
{
  ...
  // Always run if IDLE
  while (status == NodeStatus::IDLE ||
         (opt == TickOption::WHILE_RUNNING && status == NodeStatus::RUNNING))
  {
   ...

    // Inner loop. The previous tick might have triggered the wake-up
    // in this case, unless TickOption::EXACTLY_ONCE, we tick again
    while( opt != TickOption::EXACTLY_ONCE &&
           status == NodeStatus::RUNNING &&
           wake_up_->waitFor(std::chrono::milliseconds(0)) )
    {
      status = rootNode()->executeTick();
      // Due to halt tree status is now IDLE, normal exiting operation would be SUCCESS or FAIL
    }
    ...
  }
  return status;
}
@tony-p
Copy link
Contributor Author

tony-p commented Oct 30, 2023

It may make more sense to make haltTree set the tree status to FAILED as it has not ended successfully

@facontidavide facontidavide self-assigned this Oct 30, 2023
@facontidavide facontidavide added the bug Something isn't working label Oct 30, 2023
@facontidavide
Copy link
Collaborator

I agree and, funny coincidence, I was thinking about that this morning. But of course, since tickWhileRunning is blocking, the only way you can call haltTree is in another thread.

But I should cover this case!

About returning FAILED... that is another problem, since FAILING and HALTING are two different concepts.
I will address this in the next release. Fell free to suggest a PR if you have an idea

@tony-p
Copy link
Contributor Author

tony-p commented Oct 31, 2023

Yes a new HALTED/HALTING status would be more appropriate

@facontidavide
Copy link
Collaborator

I see your point but... not gonna happen. A new status would mean rewriting ALL the control nodes and decorators

@tony-p
Copy link
Contributor Author

tony-p commented Oct 31, 2023

Yeah I understand is a pretty major API change, and that is why I originally suggested FAILED instead, but I also get your point that it is not each node that failed, (and can imagine could induce nasty side effects), so that status is only really relevant for the root node

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants