%% Get Transformations from rosbag File
% Get transformations from rosbag (.bag) files by loading the rosbag and checking the available frames. From these frames, use getTransform to query the transformation between two coordinate frames.
%
% Load the rosbag.

bag = rosbag('ros_turtlesim.bag');

%
% Get a list of available frames.

frames = bag.AvailableFrames;

%
% Get the latest transformation between two coordinate frames.

tf = getTransform(bag,'world',frames{1});

%
% Check for a transformation available at a specific time and retrieve the transformation. Use canTransform to check if the transformation is available. Specify the time using rostime.

tfTime = rostime(bag.StartTime + 1);
if (canTransform(bag,'world',frames{1},tfTime))
    tf2 = getTransform(bag,'world',frames{1},tfTime);
end

% Copyright 2019 The MathWorks, Inc.
%