Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f3fb4cc

Browse files
author
Davide Faconti
committed
wip
1 parent fb6062b commit f3fb4cc

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

src/pythonnode.h

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ PYBIND11_MODULE(BehaviorTreePython, m)
3131
return params.find(key) != params.end();
3232
} )
3333
.def("__getitem__",
34-
[](NodeParameters &m, const std::string &k) -> const std::string & {
35-
auto it = m.find(k);
36-
if (it == m.end())
34+
[](NodeParameters &params, const std::string &key) -> const std::string &
35+
{
36+
auto it = params.find(key);
37+
if (it == params.end()){
3738
throw py::key_error();
39+
}
3840
return it->second;
3941
},
4042
py::return_value_policy::copy // ref + keepalive
@@ -47,6 +49,25 @@ PYBIND11_MODULE(BehaviorTreePython, m)
4749
//------------------------------------------
4850
}
4951

52+
const std::string xml_text = R"(
53+
54+
# define Action HelloPythonAction
55+
56+
class HelloPythonAction(ActionNode):
57+
58+
def __init__(self, name, params):
59+
ActionNode.__init__(self,name, params)
60+
61+
def tick(self):
62+
print("tick called.")
63+
return NodeStatus.SUCCESS;
64+
65+
def halt(self):
66+
print("halt called.")
67+
68+
def requiredNodeParameters()
69+
return [("paramA", "1"), ("paramB", "2")]
70+
)";
5071

5172
// clang-format on
5273

0 commit comments

Comments
 (0)