Skip to content

Add

SUMMARY

add creates a new frame under an existing source_name frame, given the transform between them as a 4x4 matrix or a 6/7-element pose.

UNITS

transform's position component is in meters, whether passed as a (4, 4) matrix (rot_type="mat") or a pose list. Rotation is in degrees ("deg"), radians ("rad"), or unitless ("quat").

The Skill

python
tree.add("world", "camera", [0, 0, 1, 0, 0, 0], rot_type="deg")

Example

A new frame added under an existing frame in a TransformTree, visualized in Rerun

A camera frame added under the world root.

The Code

python
"""
Example of TransformTree.add.
"""

from loguru import logger

from telekinesis.tf import tftree


def main():
    """
    Add a new frame under an existing frame in the tree.
    """
    tree = tftree.TransformTree("world")

    tree.add("world", "camera", [0, 0, 1, 0, 0, 0], rot_type="deg")
    logger.info(f"Frames after add: {list(tree.find_nodes(['world', 'camera']).keys())}")

    tree.visualize_rerun(axis_len=0.5)

if __name__ == "__main__":
    main()

Parameter Configuration

ParameterTypeDefaultDescription
source_namestrrequiredThe name of the existing frame the new frame is added under.
target_namestrrequiredThe name of the new frame.
transformnp.ndarray | listrequiredThe transform from source_name to target_name: a (4, 4) matrix, or a 6-element (deg/rad) or 7-element (quat) pose.
rot_typestr"mat"One of "deg", "rad", "quat", "mat".

Raises

ExceptionCondition
TypeErrorsource_name is not a string.
TypeErrortarget_name is not a string.
ValueErrortransform is not a (4, 4) np.ndarray or a 6/7-element list.
ValueErrorrot_type is not one of "deg", "rad", "quat", "mat".
ValueErrorNo frame named source_name exists in the tree.
ValueErrorA frame named target_name already exists in the tree.