Find Nodes
SUMMARY
find_nodes searches the tree for one or more frames by name and returns a dict keyed by name, so a Skill can check whether a frame exists before acting on it.
The Skill
python
found = tree.find_nodes(["world", "camera"])The Code
python
"""
Example of TransformTree.find_nodes.
"""
from loguru import logger
from telekinesis.tf import tftree
def main():
"""
Look up one or more nodes in the tree by name.
"""
tree = tftree.TransformTree("world")
tree.add("world", "camera", [0, 0, 1, 0, 0, 0], rot_type="deg")
found = tree.find_nodes(["world", "camera", "does_not_exist"])
logger.info(f"Found nodes: {list(found.keys())}")
if __name__ == "__main__":
main()Parameter Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
node_names | list[str] | required | Names of the frames to look up. Names not found in the tree are simply absent from the result. |
Returns
| Type | Description |
|---|---|
dict | The found nodes, keyed by name. |
Raises
| Exception | Condition |
|---|---|
ValueError | node_names is not a list. |
ValueError | An element of node_names is not a string. |