Skip to content

Get Parent

SUMMARY

get_parent returns the TransformNode that is the parent of the named frame.

The Skill

python
parent = tree.get_parent("camera")

The Code

python
"""
Example of TransformTree.get_parent.
"""

from loguru import logger

from telekinesis.tf import tftree


def main():
    """
    Get the parent of a frame in the tree.
    """
    tree = tftree.TransformTree("world")
    tree.add("world", "camera", [0, 0, 1, 0, 0, 0], rot_type="deg")

    parent = tree.get_parent("camera")
    logger.info(f"Parent of camera: {parent.get_name()}")

if __name__ == "__main__":
    main()

Parameter Configuration

ParameterTypeDefaultDescription
node_namestrrequiredThe name of the frame to look up the parent of.

Returns

TypeDescription
TransformNode | NoneThe parent node, or None if node_name is the tree's root.

Raises

ExceptionCondition
TypeErrornode_name is not a string.
ValueErrorNo frame named node_name exists in the tree.