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

Update show_only_visited to preserve indentation #273

Conversation

andrewbest-tri
Copy link
Contributor

No description provided.

@andrewbest-tri
Copy link
Contributor Author

andrewbest-tri commented Jan 31, 2020

Output from a test I ran

#!/usr/bin/env python

import py_trees
from itertools import product

root = py_trees.composites.Sequence(name="root")
child = py_trees.composites.Sequence(name="child1")
child2 = py_trees.composites.Sequence(name="child2")
child3 = py_trees.composites.Sequence(name="child3")
root.add_child(child)
root.add_child(child2)
root.add_child(child3)

child.add_child(py_trees.behaviours.Count(name='Count', fail_until=0, running_until=1, success_until=6,))
child2.add_child(py_trees.behaviours.Count(name='Count', fail_until=0, running_until=1, success_until=6,))
child2_child1 = py_trees.composites.Sequence(name="Child2_child1")
child2_child1.add_child(py_trees.behaviours.Count(name='Count', fail_until=0, running_until=1, success_until=6,))
child2.add_child(child2_child1)
child3.add_child(py_trees.behaviours.Count(name='Count', fail_until=0, running_until=1, success_until=6,))

snapshot_visitor = py_trees.visitors.SnapshotVisitor()
tree = py_trees.trees.BehaviourTree(root)
tree.add_visitor(snapshot_visitor)

for tick in range(2):
    tree.tick()
    for show_visited, show_status in product([False, True], [False, True]):
        print("-"*10)
        print ("Tick {} only visited({}) show status({})".format(tick, show_visited, show_status))
        print(
            py_trees.display.unicode_tree(
                tree.root,
                show_status=show_status,
                show_only_visited=show_visited,
                visited=snapshot_visitor.visited,
                previously_visited=snapshot_visitor.previously_visited
            )
        )
        print()
----------
Tick 0 only visited(False) show status(False)
[-] root [*]
    [-] child1 [*]
        --> Count [*] -- running
    [-] child2
        --> Count
        [-] Child2_child1
            --> Count
    [-] child3
        --> Count


----------
Tick 0 only visited(False) show status(True)
[-] root [*]
    [-] child1 [*]
        --> Count [*] -- running
    [-] child2 [-]
        --> Count [-]
        [-] Child2_child1 [-]
            --> Count [-]
    [-] child3 [-]
        --> Count [-]


----------
Tick 0 only visited(True) show status(False)
[-] root [*]
    [-] child1 [*]
        --> Count [*] -- running
    [-] child2
        ...
    [-] child3
        ...


----------
Tick 0 only visited(True) show status(True)
[-] root [*]
    [-] child1 [*]
        --> Count [*] -- running
    [-] child2 [-]
        ...
    [-] child3 [-]
        ...


----------
Tick 1 only visited(False) show status(False)
[-] root [*]
    [-] child1 [o]
        --> Count [o]
    [-] child2 [*]
        --> Count [*] -- running
        [-] Child2_child1
            --> Count
    [-] child3
        --> Count


----------
Tick 1 only visited(False) show status(True)
[-] root [*]
    [-] child1 [o]
        --> Count [o]
    [-] child2 [*]
        --> Count [*] -- running
        [-] Child2_child1 [-]
            --> Count [-]
    [-] child3 [-]
        --> Count [-]


----------
Tick 1 only visited(True) show status(False)
[-] root [*]
    [-] child1 [o]
        --> Count [o]
    [-] child2 [*]
        --> Count [*] -- running
        [-] Child2_child1
            ...
    [-] child3
        ...


----------
Tick 1 only visited(True) show status(True)
[-] root [*]
    [-] child1 [o]
        --> Count [o]
    [-] child2 [*]
        --> Count [*] -- running
        [-] Child2_child1 [-]
            ...
    [-] child3 [-]
        ...


@stonier
Copy link
Member

stonier commented Jan 31, 2020

Played with it locally, I really like it. 👍

@stonier stonier merged commit 175c0d1 into splintered-reality:devel Jan 31, 2020
@stonier
Copy link
Member

stonier commented Jan 31, 2020

You are now in the commit history!

@stonier
Copy link
Member

stonier commented Jan 31, 2020

Released in v2.0.8

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