Skip to content
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

Unable to get Repeat decorator to work properly #423

Open
apoorvcn47 opened this issue Aug 7, 2023 · 0 comments
Open

Unable to get Repeat decorator to work properly #423

apoorvcn47 opened this issue Aug 7, 2023 · 0 comments

Comments

@apoorvcn47
Copy link

I want the node "SetBlackboardValue" to repeat 3 times. But it only runs once and the tree finishes execution. Is there something I am doing wrong here?

###################
import py_trees
from py_trees.decorators import Repeat

class SetBlackboardValue(py_trees.behaviour.Behaviour):
def init(self, name):
super().init(name)

def update(self):
    print("Setting Blackboard Value")
    return py_trees.common.Status.SUCCESS

def create_behavior_tree():
root = py_trees.composites.Sequence("Behavior Tree", False)

repeat_behavior = Repeat(
    name="Repeat",
    child=SetBlackboardValue("Set Blackboard Value"),
    num_success=3  # Set the number of times to repeat the node
)

root.add_child(repeat_behavior)

return root

def main():
behavior_tree = create_behavior_tree()
tree = py_trees.trees.BehaviourTree(behavior_tree)

try:
    print("Behavior Tree Execution:")
    tree.setup(timeout=15)
    tree.tick()
        # pass
    # while tree.tick():
    #     pass
finally:
    print("Behavior Tree Finished")

if name == "main":
main()

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

No branches or pull requests

1 participant