%% Create rosbag Selection Using BagSelection Object
% Load a rosbag log file and parse out specific messages based on the selected criteria.
%
% Create a BagSelection object of all the messages in the rosbag log file.

bagMsgs = rosbag('ex_multiple_topics.bag');

%
% Select a subset of the messages based on their timestamp and topic.

bagMsgs2 = select(bagMsgs,'Time',...
           [bagMsgs.StartTime bagMsgs.StartTime + 1],'Topic','/odom');

%
% Retrieve the messages in the selection as a cell array.

msgs = readMessages(bagMsgs2);

%
% Return certain message properties as a time series.

ts = timeseries(bagMsgs2,'Pose.Pose.Position.X', ...
           'Twist.Twist.Angular.Y');

% Copyright 2015 The MathWorks, Inc.