function exampleHelperROS2PlotTimestamps(msg,hAxes)
%exampleHelperROS2PlotTimestamps Subscriber callback function for stamped data
%   exampleHelperROS2PoseCallback(MESSAGE,AXES) returns no arguments. Instead it
%   plots the timestamps in the message headers against when the callback
%   was run.
%
%   See also ManageQualityOfServicePoliciesInROS2Example.

%   Copyright 2019 The MathWorks, Inc.

% Set up axes if necessary
if isempty(hAxes.Children)
    hold(hAxes,"on")
    xlabel(hAxes,"Time received")
    ylabel(hAxes,"Message timestamp")
    datetick(hAxes,"x","mm:ss")
end

% Plot the time received against the timestamp
receiptTime = datetime("now");
msgTimestamp = double(msg.header.stamp.sec)+...
    double(msg.header.stamp.nanosec)*1e-9;
plot(hAxes,receiptTime,msgTimestamp,"*k")
text(hAxes,receiptTime,msgTimestamp,sprintf(" %.0d",msgTimestamp))
end