-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathblack_demo.py
52 lines (41 loc) · 1.41 KB
/
black_demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from py_trees.common import Status
import py_trees
import pybts
from cachetools import Cache
class TestNodeA(pybts.Node, pybts.Action):
def __init__(self):
super().__init__()
self.cache = self.attach_blackboard_client(name='cache', namespace='a')
self.cache.register_key('value', pybts.Access.WRITE)
self.cache.register_key('age', pybts.Access.WRITE)
self.cache.register_key('name', pybts.Access.WRITE)
# self.cache.name = '1'
# self.cache.age = 'a'
# self.cache.value = 1
def update(self) -> Status:
self.cache.value = 1
return Status.SUCCESS
class TestNodeB(pybts.Node, pybts.Action):
def __init__(self):
super().__init__()
self.cache = self.attach_blackboard_client(name='cache', namespace='a')
self.cache.register_key('value', pybts.Access.WRITE)
self.cache.register_key('age', pybts.Access.WRITE)
self.cache.register_key('name', pybts.Access.WRITE)
def update(self) -> Status:
print(py_trees.blackboard.Blackboard.storage)
return Status.FAILURE
if __name__ == '__main__':
node = pybts.Parallel(
name='',
children=[
# TestNodeA(),
TestNodeA(),
# TestNodeA(),
TestNodeB()
],
success_threshold=-1
)
node.setup()
node.tick_once()
print(node.status)