%% Run Loop At Fixed Rate Using rosrate
% Initialize the ROS master and node.

rosinit

%
% Create a rate object that runs at 1 Hz.

r = rosrate(1);

%
% Start loop that prints iteration and time elapsed. Use waitfor to pause the loop until the next time interval. Reset r prior to the loop execution. Notice that each iteration executes at a 1-second interval.

reset(r)
for i = 1:10
	time = r.TotalElapsedTime;
	fprintf('Iteration: %d - Time Elapsed: %f\n',i,time)
	waitfor(r);
end

%
% Shut down the ROS network.

rosshutdown

% Copyright 2019 The MathWorks, Inc.
%