feat(blackboard): add GetBlackboardByKey and SetBlackboardByKey for dynamic-key access#11
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new BehaviorTree.CPP behavior node to read a blackboard value using a key computed at tick time, enabling dynamic-key cache lookups (including root-scope @ keys).
Changes:
- Introduces
GetBlackboardByKeySyncActionNode withkeyinput andvalueoutput. - Registers the new behavior in the plugin loader and library build.
- Extends the existing plugin-load test to instantiate the new node.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/get_blackboard_by_key.cpp |
Implements tick-time dynamic-key blackboard read and output propagation. |
include/experimental_behaviors/get_blackboard_by_key.hpp |
Declares the new behavior and documents its ports/semantics. |
src/register_behaviors.cpp |
Registers GetBlackboardByKey with the behavior factory. |
CMakeLists.txt |
Adds the new source file to the shared library build. |
test/test_behavior_plugins.cpp |
Adds instantiation coverage for the new node in the plugin-load test. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Replace hand-rolled brace-stripping with setOutput<BT::Any> to handle SubTree auto-remap sentinels and whitespace correctly. - Document that empty-valued entries are reported as FAILURE. - Correct port type in docstring (AnyTypeAllowed, not BT::Any).
Write-side complement to GetBlackboardByKey. BT.CPP's native SetBlackboard passes string-typed sources through TypeInfo::parseString when the destination is not std::string; for AnyTypeAllowed destinations (entries created implicitly by Script `:=` on subtree ports) no converter is registered, so parseString returns an empty Any and silently clobbers the write. SetBlackboardByKey copies the source Any directly, preserving both type and value. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
v0.0.6 sources /opt/underlay_ws/install/setup.sh, which no longer exists in the picknikciuser/moveit-studio:main-humble image, so the Install rosdeps step fails before build or test run. v0.0.7 is the upstream fix that removes those three sourcing lines. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
cf0b93f to
6101af1
Compare
henrygerardmoore
left a comment
Contributor
There was a problem hiding this comment.
LGTM other than one thing; works well where you use it in the autowash config
…Key description Description previously only mentioned the missing-entry case, but tick() also returns FAILURE for a missing/empty `key` port and for entries that exist but hold no value. Update the description string so the UI help text matches the actual semantics. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Member
|
To confirm, when this gets merged into core, SetBlackboard should be marked as deprecated? |
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.
Summary
Adds a pair of behaviors for reading/writing blackboard entries under runtime-computed keys — the missing primitives for dynamic-key access in BT.CPP v4.
GetBlackboardByKey— reads an entry whose key is resolved at tick time (typically built via a Script node from other blackboard variables). Mirrors the shape of BT.CPP's nativeSetBlackboard, which already supports a dynamicoutput_keyport but has no read-side complement. Value copy goes throughsetOutput<BT::Any>so SubTree auto-remap sentinels ({=}/=) and blackboard-pointer validation are handled by BT.CPP's canonical helper.SetBlackboardByKey— write-side complement. Not just a wrapper aroundSetBlackboard: BT.CPP's native action runsTypeInfo::parseStringwhenever the source is a string and the destination type is notstd::string. Destinations created implicitly by a Script:=assignment carryAnyTypeAllowedand have no registered converter, soparseStringreturns an emptyAnyand silently clobbers the write.SetBlackboardByKeycopies the sourceAnydirectly, preserving both type and value.The
@prefix for root-scope blackboard access is honored transparently in both behaviors (handled insideBlackboard::getEntry/createEntry).Why
No native dynamic-key read/write pair exists in BT.CPP v4. The conversion bug in
SetBlackboard(see above) makes it unsafe for caching script-produced values regardless of whether the key is static or dynamic. These two small primitives fill both gaps.Motivating use case
Caching pre-computed motion trajectories on the root blackboard during a pre-flight planning pass, then retrieving them during execution in a separate subtree — eliminating duplicated planning calls. Landing in a separate PR against
autowash_config.Test plan
test_load_behavior_plugins).autowash_configregression suite.SetBlackboardByKeyin place (nativeSetBlackboardproduced the empty-Any bug described above).🤖 Generated with Claude Code