Lookup Transform
SUMMARY
lookup_transform returns the transform from a source frame to a target frame, anywhere in the tree, as a 4x4 matrix or a pose in the requested rot_type.
UNITS
The returned position component is in meters, whether returned 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
camera_pose_world = tree.lookup_transform("camera", "world", rot_type="deg")Example

A robot and camera frame, with the transform between them looked up directly.
The Code
python
"""
Example of TransformTree.lookup_transform.
"""
from loguru import logger
from telekinesis.tf import tftree
def main():
"""
Get the transform between any two frames in the tree.
"""
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")
world_T_camera = tree.lookup_transform("world", "camera")
logger.info(f"world_T_camera:\n{world_T_camera}")
camera_pose_world = tree.lookup_transform("camera", "world", rot_type="deg")
logger.info(f"camera_pose_world (deg): {camera_pose_world}")
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 frame the returned transform is expressed relative to. |
target_name | str | required | The name of the frame to look up. |
rot_type | str | "mat" | One of "deg", "rad", "quat", "mat". |
Returns
| Type | Description |
|---|---|
np.ndarray | list | The transform from source_name to target_name, as a (4, 4) matrix (rot_type="mat") or a pose list. |
Raises
| Exception | Condition |
|---|---|
TypeError | source_name is not a string. |
TypeError | target_name is not a string. |
ValueError | rot_type is not one of "deg", "rad", "quat", "mat". |
ValueError | Either source_name or target_name does not exist in the tree. |