Skip to content

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

ParameterTypeDefaultDescription
node_nameslist[str]requiredNames of the frames to look up. Names not found in the tree are simply absent from the result.

Returns

TypeDescription
dictThe found nodes, keyed by name.

Raises

ExceptionCondition
ValueErrornode_names is not a list.
ValueErrorAn element of node_names is not a string.