Skip to content

Update

SUMMARY

update sets a new transform between an existing frame and its parent, given 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.update("camera", [0, 0, 1.2, 0, 0, 0], rot_type="deg")

Example

Before

Frame pose before update

The camera frame at its original pose in the tree.

After

Frame pose after update

The same frame after update sets its new transform to its parent.

The Code

python
"""
Example of TransformTree.update.
"""

from loguru import logger
import time

from telekinesis.tf import tftree


def main():
    """
    Update the transform of an existing frame in the tree.
    """
    tree = tftree.TransformTree("world")
    tree.add("world", "camera", [0, 0, 1, 0, 0, 0], rot_type="deg")
    tree.visualize_rerun()
    logger.info(f"camera pose before update: {tree.lookup_transform('world', 'camera', rot_type='deg')}")

    time.sleep(3)
    tree.update("camera", [-0.5, -0.5, 1.5, 0, 0, 0], rot_type="deg")
    tree.visualize_rerun()
    logger.info(f"camera pose after update: {tree.lookup_transform('world', 'camera', rot_type='deg')}")

if __name__ == "__main__":
    main()

Parameter Configuration

ParameterTypeDefaultDescription
source_namestrrequiredThe name of the frame whose transform to its parent is updated.
transformnp.ndarray | listrequiredThe new transform to the frame's parent: a (4, 4) matrix, or a 6-element (deg/rad) or 7-element (quat) pose.
rot_typestr"deg"One of "deg", "rad", "quat", "mat". Note this default differs from add's, which defaults to "mat".

Raises

ExceptionCondition
TypeErrorsource_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.