Main Content

transformTree

Define coordinate frames and relative transformations

Since R2020b

Description

The transformTree object contains an organized tree structure for coordinate frames and their relative transformations over time. The object stores the relative transformations between children frames and their parents. You can specify a timestamped transform for frames and query the relative transformations between different frames in the tree. The object interpolates intermediate timestamps using a constant velocity assumption for linear motion, and spherical linear interpolation (SLERP) for angular motion. Otherwise, the relative transformations are kept constant past the range of the timestamps specified. Times prior to the first timestamp return NaN.

Use the updateTransform function to add timestamps to the tree by defining the parent-to-child relationships. Query specific transformations at given timestamps using getTransform and display the frame relationships using show.

Creation

Description

frames = transformTree creates a transformation tree data structure with a single frame, "root", with the maximum number of frames and timestamped transforms per frame, set to 10.

frames = transformTree(baseName) specifies the name of the root frame as a string or character vector.

example

frames = transformTree(baseName,numFrames) additionally sets the MaxNumFrames property, which defines the max number of named frames in the object.

frames = transformTree(baseName,numFrames,numTransforms) additionally sets the MaxNumTransforms property, which defines the max number of timestamped transforms per frame name.

frames = transformTree(baseName,numFrames,numTransforms,rootTime) additionally specifies the timestamp of the initial baseName frame as a scalar time in seconds.

Properties

expand all

Maximum number of frames in the tree, specified as a positive integer. Each frame has associated timestamped transforms that define the state of the frame at those specific times.

Data Types: double

Maximum number of timestamped transforms per frame, specified as a positive integer. This property sets an upper limit on the number of timestamped transforms the object can store for each frame named in the structure. A transformTree object with MaxNumFrames and MaxNumTransforms set to 10 can store a maximum of 100 transformations with 10 for each frame.

Data Types: double

Current number of coordinate frames stored, specified as a positive integer. The object starts with a single root frame, and new frames and specific timestamps are added using updateTransform function.

Data Types: double

Object Functions

getGraphGraph object representing tree structure
getTransformGet relative transform between frames
infoList all frame names and stored timestamps
removeTransformRemove frame transform relative to its parent
showShow transform tree
updateTransformUpdate frame transform relative to its parent

Examples

collapse all

Set East-North-Up coordinate frame as the root frame in the scenario

tree = transformTree("ENU");

Create a front-left-up UAV body frame by transforming the root frame. Set the UAV body frame to have initial position of 5 meters east, 5 meters up, and no rotation relative to the root frame.

updateTransform(tree,"ENU","UAVFLU",[5 0 5],[1 0 0 0],0)

Show the root and UAV body frame.

figure
show(tree);

Figure contains an axes object. The axes object contains 10 objects of type patch, line, text.

Show the transformation tree. The transformation tree shows that the UAV body frame is a child of the root frame

plot(getGraph(tree))

Figure contains an axes object. The axes object contains an object of type graphplot.

Move the UAV frame to a new position and orientation for a duration of 10 seconds.

updateTransform(tree,"ENU","UAVFLU",[10 10 10],eul2quat([pi/4 0 0]),10)

Show the UAV frame at 1 second increments. At each time step, the show function performs interpolation using a constant velocity assumption for linear motion, and spherical linear interpolation (SLERP) for angular motion.

ts = linspace(0,5,5);
for idx = 1:5
show(tree, ts(idx));
hold on
end

Figure contains an axes object. The axes object contains 50 objects of type patch, line, text.

Obtain the transform between the root frame and the final UAV body frame.

getTransform(tree,"ENU","UAVFLU",5)
ans = 4×4

    0.9239   -0.3827         0    7.5000
    0.3827    0.9239         0    5.0000
         0         0    1.0000    7.5000
         0         0         0    1.0000

Version History

Introduced in R2020b