You may find yourself wanting to extend the functionality provided by the default nodes in this package by adding your own parent, action, conditional, or update nodes.
In order to create your own custom nodes, the nodes can exist anywhere in the directory mr_bt/src/nodes/
as a .py
file.
All behavior tree nodes are created as a python class in a python file. The name of your .py
file should correspond with the name of your class within the file.
For example, if you want to create a node called MyNewNode
, the file that it exists in should be called my_new_node.py
and the class definition should be class MyNewNode(SomeNodeType):
.
Each different type of node will have a required "tick" function, but the naming is different depending on the type of node you are creating. Regardless of what the "main" of function is called, it always returns one of three string type values: "success"
, "failure"
, or "running"
.
For further details on how to create custom nodes of each type, see the following sections.
To create a custom conditional node, you must define your node class by inheriting from the superclass that defines a generic conditional node.
You also must include the condition
function as the "tick" function that returns a bool
type depending on the state of the relavent blackboard
Here is an example of a custom conditional node:
This type of node will return a boolean value.
To create a custom action node, you must define your node class by inheriting from the superclass that defines a generic action node.
You also must include the execute
function as the "tick" function that performs the actions of the node.
Here is an example of a custom action node:
This type of node will return one of the following string values: "success"
, "failure"
, or "running"
To create a custom update node, you must define your node class by inheriting from the superclass that defines a generic update node.
You also must include the update_blackboard
function as the "tick" function that updates the blackboard with relevant information.
Here is an example of a custom update node:
This type of node will return one of the following string values: "success"
, "failure"
, or "running"