Skip to content

Copy

SUMMARY

copy deep-copies the tree and applies an optional prefix/suffix to every frame name, so the copy can coexist with the original without name collisions.

The Skill

python
tree_copy = tree.copy(prefix="copy_")

Example

A TransformTree and its renamed deep copy, visualized in Rerun

The original tree alongside its deep copy, coexisting under a renamed root.

The Code

python
"""
Example of TransformTree.copy.
"""

from loguru import logger

from telekinesis.tf import tftree


def main():
    """
    Deep copy a tree with a renamed root.
    """
    tree = tftree.TransformTree("world")
    tree.add("world", "camera", [0, 0, 1, 0, 0, 0], rot_type="deg")

    tree_copy = tree.copy(prefix="copy_")
    logger.info(f"Original root: {tree.get_root_name()}")
    logger.info(f"Copy root: {tree_copy.get_root_name()}")
    logger.info(f"Copy frames: {list(tree_copy.get_all_frames(reference_node_name=tree_copy.get_root_name()).keys())}")

    tree.visualize_rerun(axis_len=0.5)
    tree_copy.visualize_rerun(axis_len=0.5)

if __name__ == "__main__":
    main()

Parameter Configuration

ParameterTypeDefaultDescription
prefixstr""Prefix added to every frame name in the copy, including the root.
suffixstr""Suffix added to every frame name in the copy, including the root.

Returns

TypeDescription
TransformTreeA deep copy of the tree, with prefix/suffix applied to every frame name.

Raises

ExceptionCondition
TypeErrorprefix is not a string.
TypeErrorsuffix is not a string.