Add Tree::wakeUpSignal() getter#1127
Open
tonynajjar wants to merge 3 commits intoBehaviorTree:masterfrom
Open
Conversation
Tree::setSleepOverride() for custom clock-aware sleepingTree::wakeUpSignal() getter
Open
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Tree::sleep()usesWakeUpSignal::waitFor(), which internally callsstd::condition_variable::wait_for()— this always measures time againststeady_clock(wall time). When using a simulated clock that runs faster or slower than real time (e.g., ROS 2's/clocktopic withuse_sim_time), the tree tick rate doesn't scale with the simulation. At 10x sim speed, a 100ms loop timeout still blocks 100ms real time, so the tree ticks 10x too slowly relative to the simulated world.C++ provides no mechanism to make
condition_variablewait on a custom clock, so any solution requires polling.Solution
Add
Tree::wakeUpSignal()— a simple getter that returns the tree's sharedWakeUpSignal. This allows frameworks to implement their own clock-aware sleep logic externally while still being able to check for wake-up signals (preemption).For example, in ROS 2 (Nav2), the between-tick sleep loop can poll the ROS clock for the deadline while doing short
waitFor(1ms)calls to stay responsive to preemption: