-
Notifications
You must be signed in to change notification settings - Fork 1
Feature: Add conditional nodes in behaviour trees #10
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
Conversation
The review for this will take some more time, since we will have to discuss the design. The ticket for this was pretty new and no discussion of how this should look was done. I am not sure what is implemented is what we would have gone with. I did take a brief look though and I noticed that you are checking a conditional and then checking args during the evaluation of the conditional. I believe that some of this could have been taken care of if you just placed the evaluation between line 458 and 459. So basically, you process the args check if the node is a conditional and only process the items in the conditional if it is true. Something like that. EDIT: I do see that you followed a similar pattern as the subtree and maybe that is appropriate. |
Thank you again for your detailed feedback! It is very much appreciated. I'm still very new to coding so this is extremely helpful. |
Some suggestions based on my comment in #5. On parser.py#L452 add: condition = xml_node.attrib.get("if")
if condition:
include_node = self._evaluate_condition(condition, args)
if not include_node:
return None This would require the following change in the _build_tree function: py_trees_parser/py_trees_parser/parser.py Line 475 in af33449
to: if child is not None:
children.append(child) This will make all nodes able to be conditionals I think. I am not really sure if we need to do something to support the group tag explicitly as I think this will just be handled by the following code already: py_trees_parser/py_trees_parser/parser.py Lines 471 to 475 in af33449
|
Thank you for the suggestion! I'll try testing it first then send pr for review. |
Seems like the conclusion of the discussion in #5 is that we prefer do add conditionals directly to the node like ROS2 xml launch files. Thank you for your contribution and feel free to suggest or make improvements any time. |
Implements conditional nodes for behaviour trees (Fixes #5).
Description
Added the ability to conditionally include or exclude nodes in behaviour trees based on argument values. This makes subtrees more configurable and modular by allowing different parts of a tree to be enabled or disabled based on runtime parameters.
Implementation details
_evaluate_condition
method to evaluate conditional expressions with argument substitution_build_tree
to handle the new<conditional>
XML tagExample usage
This enables more flexible behaviour tree configurations where different nodes can be included based on argument values.