Skip to content

add unit test for subtree with default values and autoremap enabled - #1272

Merged
facontidavide merged 5 commits into
BehaviorTree:masterfrom
ottojo:subtree_default_autoremap
Nov 7, 2026
Merged

facontidavide merged 5 commits into
BehaviorTree:masterfrom
ottojo:subtree_default_autoremap

Conversation

@ottojo

@ottojo ottojo commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

This adds a failing unit test for #1271

ottojo and others added 4 commits October 29, 2026 11:13
With _autoremap="true" the SubTree model was skipped entirely, so an
input_port default was never applied and reading the port failed with
"Variable not found".

Now, for a modelled input port that is not explicitly remapped, a parent
key of the same name still wins (autoremap); if no such entry exists when
the tree is created, the literal default is set in the SubTree blackboard,
as it is without autoremap. Output/inout ports and "{key}" defaults keep
the previous autoremap behavior.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ehaviorTree#1271)

With _autoremap="true", a SubTree model input_port literal default is applied
only if no entry with that name exists in the parent blackboard chain when the
tree is created. Document this (including the workaround: set the key in the
blackboard before createTree, or remap the port explicitly) and add a test
that pins it: a key written later by a Script does not win over the default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@facontidavide

Copy link
Copy Markdown
Collaborator

Thanks @ottojo for the failing test. I pushed the fix on top of your branch, so this PR now fixes #1271: a9e6ab4 is the fix and 7704b2f adds docs plus a test. Your two commits are kept.

Root cause: with _autoremap="true", recursivelyCreateSubtree skipped the SubTree model entirely (xml_parsing.cpp), so input_port defaults were never applied. Now, for a modelled input port with a literal default that isn't explicitly remapped: if no entry with that name exists in the parent blackboard when the tree is created, the default is set in the SubTree's blackboard. Otherwise the parent key wins, as before.

Creation-time rule (documented in PORT_CONNECTION_RULES.md and pinned by a test): a parent key that only appears at runtime, for example <Script code="in_value:=7"/> before the SubTree, is shadowed by the default. To make the parent value win, set the key in the blackboard before createTree() or remap the port explicitly. A runtime fallback would need a new Blackboard member, which breaks ABI, so it's not an option in 4.x. Output and bidirectional ports keep their previous behavior.

I'll squash-merge once CI is green.

@facontidavide
facontidavide merged commit 69f6e4a into BehaviorTree:master Nov 7, 2026
17 checks passed
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