BehaviorTree/BehaviorTree.CPP

check if blackboard value exist

mnumanuyar opened this issue · 4 comments

Is there any way to check if blackboard value is set? Sometimes there are some ways around this (default values for subtrees or nodes, setting a dummy value at the start and checking for it etc.) But is there any other way?

Somehow failing a node (instead of throwing error) if a mapped blackboard value dont exist also works for me

yes, there is. Are you talking about:

  1. direct access to the blackboard (that it is discouraged)
  2. getInput
  3. Scripting language in pore-post conditions?

for 1 and 2: I was looking a way to do it without writing a new node, so if such node doesn't exist, knowing it can be written is good

for 3: how can i check if a blackboard variable is not set yet with scripting ? My understanding is if such a variable is used (unless as a left side of := ) an error is thrown, which immediately halts the tree.

As a side note while testing for this I realised this tree doesnt fail:


     <BehaviorTree ID="tmp_test">
          <Sequence name="root">
               <Script code="foo=1"/>
               <SaySomething   message="{foo}" />
               <Script code="bar:=2"/>
               <SaySomething   message="{bar}" />
          </Sequence>
     </BehaviorTree>

But in docs it says

The difference between the operator ":=" and "=" is that the former may create a new entry in the blackboard, if it doesn't exist, whilst the latter will throw an exception if the blackboard doesn't contain the entry.

so I was expecting <Script code="foo=1"/> to fail. I am using 4.3 so it might be because of that

ok, so you don't want to check that inside a node but you want to have a node that does that check. Understood.

No, we should create such a Node, I don't have it.

This is also NOT supported yet in the scripting language.

I am using 4.3 so it might be because of that

I can not debug all version, only the newest.

Your tree is not failing because the mere existence of <SaySomething message="{foo}" /> will generate a placeholder for foo during the creation of the tree.

Your tree is not failing because the mere existence of <SaySomething message="{foo}" /> will generate a placeholder for foo during the creation of the tree.

Ahh, got it. Ok, thank you for your answers, unless this issue triggers any kind of change, this issue can be closed, all my questions are answered, Thank you again for your hardwork :D