%% Work with ROS Duration Objects
% Create ROS Duration objects, perform addition and subtraction, and compare duration objects. You can also add duration objects to ROS Time objects to get another Time object.
% Create a duration using seconds and nanoseconds.

dur1 = rosduration(100,2000000)

%
% Create a duration using a floating-point value. This sets the seconds using the integer portion and nanoseconds with the remainder.

dur2 = rosduration(20.5)

%
% Add the two durations together to get a single duration.

dur3 = dur1 + dur2

%
% Subtract durations and get a negative duration. You can initialize durations with negative values as well.

dur4 = dur2 - dur1
dur5 = rosduration(-1,2000000)

%
% Compare durations.

dur1 > dur2

%
% Add a duration to a ROS Time object.

time = rostime('now','system')
timeFuture = time + dur3

% Copyright 2019 The MathWorks, Inc.
%