Extract timeseries from rosbag with std_msgs/Bool messages

8 views (last 30 days)
Hi,
I have recorded a rosbag with a /teleop_control topic, to which messages of type std_msgs/Bool are published. I need to read this as a timeseries object, to later synchronize with other topics. But I'm getting errors when trying to use the timeseries function, which worked fine with Twist messages.
To check it, I have done:
bag_teleop_control.MessageList
ans =
46×4 table
Time Topic MessageType FileOffset
__________ _______________ _____________ __________
1.5637e+09 /teleop_control std_msgs/Bool 208303
1.5637e+09 /teleop_control std_msgs/Bool 214527
1.5637e+09 /teleop_control std_msgs/Bool 1307088
.
.
.
And:
rosmsg info std_msgs/Bool
logical Data
But this gives me an error:
timeseries(bag_teleop_control, 'Data');
Error using robotics.ros.BagSelection/getTimeseriesArguments (line 726)
The Data property does not exist for message type std_msgs/Bool.
Error in robotics.ros.BagSelection/timeseries (line 442)
props = obj.getTimeseriesArguments(messageType, varargin{:});
Does someone know what am I getting wrong?
  4 Comments
Cam Salzberger
Cam Salzberger on 25 Jul 2019
That is pretty odd. When you did readMessages (both with and without the struct option), did the messages contain values in the Data property of the messages? Or were they empty, or all equal to the same value?
It does look like you could extract the time series to get the structure and time, then fill in the data using messages?
boolData = timeseries(bag_teleop_control);
boolMsgStructs = readMessages(bag_teleop_control, "DataFormat", "struct");
boolData.Data = [boolMsgStruct.Data]';
Sorry if the code might not work. I'm away from MATLAB right now, so can't try it out. But that's one idea for a workaround.
-Cam
Vinicius Schettino
Vinicius Schettino on 25 Jul 2019
Yes, the values obtained from readMessages come out correct.
Your code gave me an error, but a small change fix it:
boolData = timeseries(bag_teleop_control);
boolData.Data = cellfun(@(x) x.Data, readMessages(bag_teleop_control));
I still don't know why the timeseries function fails for Bool messages, but at leat it is a simple enough workaround. Thanks!

Sign in to comment.

Answers (0)

Products


Release

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!