MATLAB Answers

Error using ros.BagSel​ection/des​erializeMe​ssages

37 views (last 30 days)
sbal20 on 6 May 2020
Edited: sbal20 on 7 May 2020
I am getting the following error trying to read a Rosbag file. Following another questions I have increased the Java heap memory.
I have created a request to Mathworks, but probably the comunity could help also.
I appreciate you help.
Steps to replicate de error.
>> bag = rosbag('/rosbag_file.bag');
>> bag
bag =
BagSelection with properties:
FilePath: '/rosbag_file.bag'
StartTime: 1.583866799690000e+09
EndTime: 1.583868599470000e+09
NumMessages: 1140612
AvailableTopics: [5×3 table]
AvailableFrames: {0×1 cell}
MessageList: [1140612×4 table]
>> bag.AvailableTopics
ans =
5×3 table
NumMessages MessageType MessageDefinition
/odo 131474 nav_msgs/Odometry {' uint32 S [...]
/Rpm 323514 std_msgs/Float64 {0×0 char [...]
/flag 323514 std_msgs/Bool {0×0 char [...]
/pose 323514 nav_msgs/Odometry {' uint32 S [...]
/gps 12862 gps_common/GPSFix {' uint32 S [...]
Error when reading a subset:
>>bag2 = select(bag,'Time',[bag.StartTime bag.StartTime + 1],'Topic','/odo');
Error using ros.BagSelection/deserializeMessages (line 641)
Java exception occurred:
java.lang.IndexOutOfBoundsException: Invalid combined index of 1684630641, maximum is 19960408
at org.jboss.netty.buffer.SlicedChannelBuffer.<init>(
at org.jboss.netty.buffer.HeapChannelBuffer.slice(
at org.jboss.netty.buffer.AbstractChannelBuffer.readSlice(
at org.ros.internal.message.field.PrimitiveFieldType$14.deserialize(
at org.ros.internal.message.field.PrimitiveFieldType$14.deserialize(
at org.ros.internal.message.field.ValueField.deserialize(
at org.ros.internal.message.DefaultMessageDeserializer.deserialize(
at org.ros.internal.message.field.MessageFieldType.deserialize(
at org.ros.internal.message.field.MessageFieldType.deserialize(
at org.ros.internal.message.field.ValueField.deserialize(
at org.ros.internal.message.DefaultMessageDeserializer.deserialize(
Error in ros.BagSelection/readMessages (line 278)
msgs = obj.deserializeMessages(obj.MessageList, rows);


Sign in to comment.

Accepted Answer

Cam Salzberger
Cam Salzberger on 6 May 2020
This looks like the same issue that is mentioned in this bug report. Try reading the messages out of the rosbag using:
msgs = readMessages(bag2, "DataFormat", "struct");
This should allow you to access the data still, though the messages will be structures rather than classes. It has the added benefit of being faster to extract the data from the rosbag. If you have any specialized messages you want to use the convenience methods to extract data from (e.g. readImage, readXYZ, etc.), you can copy the data from the struct message into an empty message object and call the method using that.
We've seen this more commonly with compressed rosbags. If it's an option, and the "DataFormat","struct" isn't enough for you, consider trying to record the rosbag in an uncompressed format.

  1 Comment

sbal20 on 7 May 2020
Thank you very much for your reply, unfortunately extract a structured message did not work also.
>>msgs = readMessages(bagselect1, "DataFormat", "struct");
Caught "std::exception" Exception message is:
ROSLZ4_DATA_ERROR: malformed data to decompress
The specialized messages look really useful, unfortunately I don not have that type of messages in my data. I will analyze the behavior with uncompressed data.
Uncompressed data was read it smoothly with both commands. Thank you again.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!