%% Apply Transformation using TransformStamped Object
% Apply a transformation from a TransformStamped object to a PointStamped message.
% Start ROS network and setup transformations.

rosinit
exampleHelperROSStartTfPublisher

%
% Create transformation tree and wait for tree to update. Get the transform between the robot base and its camera center. Inspect the transformation.

tftree = rostf;
waitForTransform(tftree,'camera_center','robot_base');
tform = getTransform(tftree,'camera_center','robot_base');
showdetails(tform)

%
% Create point to transform. You could also get this point message off the ROS network.

pt = rosmessage('geometry_msgs/PointStamped');
pt.Header.FrameId = 'camera_center';
pt.Point.X = 3;
pt.Point.Y = 1.5;
pt.Point.Z = 0.2;

%
% Apply the transformation to the point.

tfpt = apply(tform,pt);

%
% Shutdown ROS network.

rosshutdown

% Copyright 2019 The MathWorks, Inc.