Change Parent
SUMMARY
change_parent re-parents a frame under a different frame, preserving its pose in the world by recomputing its transform to the new parent.
The Skill
python
tree.change_parent("camera", "base_link")Example

The camera frame re-parented under a different frame, with its pose in the world unchanged.
The Code
python
"""
Example of TransformTree.change_parent.
"""
from loguru import logger
from telekinesis.tf import tftree
def main():
"""
Move a frame under a different parent, keeping its pose in the world.
"""
tree = tftree.TransformTree("world")
tree.add("world", "robot", [1, 0, 0, 0, 0, 0], rot_type="deg")
tree.add("robot", "camera", [0, 0, 0.5, 0, 0, 0], rot_type="deg")
logger.info(f"Parent before: {tree.get_parent('camera').get_name()}")
tree.change_parent("camera", "world")
logger.info(f"Parent after: {tree.get_parent('camera').get_name()}")
logger.info(f"camera pose in world (unchanged): {tree.lookup_transform('world', 'camera')}")
tree.visualize_rerun(axis_len=0.5)
if __name__ == "__main__":
main()Parameter Configuration
| Parameter | Type | Default | Description |
|---|---|---|---|
node_name | str | required | The name of the frame to move. |
new_parent_name | str | required | The name of the frame to re-parent it under. |
Raises
| Exception | Condition |
|---|---|
TypeError | node_name is not a string. |
TypeError | new_parent_name is not a string. |
ValueError | Either node_name or new_parent_name does not exist in the tree. |

