Bases: TreeNode
An action node encapsulates the notion of a self-contained action
or behavior. The bulk of the observable actions of a behavior tree
are due to the action nodes.
ActionNode
s are one of the two kinds of leaf nodes in a Behavior
Tree - the other being the ConditionNode
.
Parameters:
Name |
Type |
Description |
Default |
name |
`str`
|
The given name of this node.
|
required
|
Source code in src/dendron/action_node.py
| class ActionNode(TreeNode):
"""
An action node encapsulates the notion of a self-contained action
or behavior. The bulk of the observable actions of a behavior tree
are due to the action nodes.
`ActionNode`s are one of the two kinds of leaf nodes in a Behavior
Tree - the other being the `ConditionNode`.
Args:
name (`str`):
The given name of this node.
"""
def __init__(self, name) -> None:
super().__init__(name)
def set_logger(self, new_logger) -> None:
"""
Set the logger for this node.
"""
self.logger = new_logger
def set_log_level(self, new_level) -> None:
"""
Set the log level for this node.
"""
self.log_level = new_level
def node_type(self) -> NodeType:
"""
Get the type of this node.
Returns:
`NodeType`: The type (`ACTION`).
"""
return NodeType.ACTION
def get_node_by_name(self, name : str) -> Optional[TreeNode]:
"""
Search for a node by its name.
Args:
name (`str`):
The name of the node we are looking for.
Returns:
`Optional[TreeNode]`: Either a node with the given name,
or None.
"""
if self.name == name:
return self
else:
return None
def pretty_repr(self, depth = 0) -> str:
"""
Return a string representation of this node at the given depth.
Args:
depth (`int`):
The depth of this node in a surrounding tree.
Returns:
`str`: The indented string representation.
"""
tabs = '\t'*depth
repr = f"{tabs}Action {self.name}"
return repr
|
set_logger(new_logger)
Set the logger for this node.
Source code in src/dendron/action_node.py
| def set_logger(self, new_logger) -> None:
"""
Set the logger for this node.
"""
self.logger = new_logger
|
set_log_level(new_level)
Set the log level for this node.
Source code in src/dendron/action_node.py
| def set_log_level(self, new_level) -> None:
"""
Set the log level for this node.
"""
self.log_level = new_level
|
node_type()
Get the type of this node.
Returns:
Type |
Description |
NodeType
|
NodeType : The type (ACTION ).
|
Source code in src/dendron/action_node.py
| def node_type(self) -> NodeType:
"""
Get the type of this node.
Returns:
`NodeType`: The type (`ACTION`).
"""
return NodeType.ACTION
|
get_node_by_name(name)
Search for a node by its name.
Parameters:
Name |
Type |
Description |
Default |
name |
`str`
|
The name of the node we are looking for.
|
required
|
Returns:
Type |
Description |
Optional[TreeNode]
|
Optional[TreeNode] : Either a node with the given name,
|
Optional[TreeNode]
|
|
Source code in src/dendron/action_node.py
| def get_node_by_name(self, name : str) -> Optional[TreeNode]:
"""
Search for a node by its name.
Args:
name (`str`):
The name of the node we are looking for.
Returns:
`Optional[TreeNode]`: Either a node with the given name,
or None.
"""
if self.name == name:
return self
else:
return None
|