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 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
| Parameter | Type | Default | Description |
|---|---|---|---|
source_name | str | required | The name of the existing frame the new frame is added under. |
target_name | str | required | The name of the new frame. |
transform | np.ndarray | list | required | The transform from source_name to target_name: a (4, 4) matrix, or a 6-element (deg/rad) or 7-element (quat) pose. |
rot_type | str | "mat" | One of "deg", "rad", "quat", "mat". |
Raises
| Exception | Condition |
|---|---|
TypeError | source_name is not a string. |
TypeError | target_name is not a string. |
ValueError | transform is not a (4, 4) np.ndarray or a 6/7-element list. |
ValueError | rot_type is not one of "deg", "rad", "quat", "mat". |
ValueError | No frame named source_name exists in the tree. |
ValueError | A frame named target_name already exists in the tree. |