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

6 views (last 30 days)
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');
>>readMessages(bag2);
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>(SlicedChannelBuffer.java:46)
at org.jboss.netty.buffer.HeapChannelBuffer.slice(HeapChannelBuffer.java:200)
at org.jboss.netty.buffer.AbstractChannelBuffer.readSlice(AbstractChannelBuffer.java:323)
at org.ros.internal.message.field.PrimitiveFieldType$14.deserialize(PrimitiveFieldType.java:599)
at org.ros.internal.message.field.PrimitiveFieldType$14.deserialize(PrimitiveFieldType.java:565)
at org.ros.internal.message.field.ValueField.deserialize(ValueField.java:68)
at org.ros.internal.message.DefaultMessageDeserializer.deserialize(DefaultMessageDeserializer.java:45)
at org.ros.internal.message.field.MessageFieldType.deserialize(MessageFieldType.java:111)
at org.ros.internal.message.field.MessageFieldType.deserialize(MessageFieldType.java:38)
at org.ros.internal.message.field.ValueField.deserialize(ValueField.java:68)
at org.ros.internal.message.DefaultMessageDeserializer.deserialize(DefaultMessageDeserializer.java:45)
Error in ros.BagSelection/readMessages (line 278)
msgs = obj.deserializeMessages(obj.MessageList, rows);

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.
-Cam
  1 Comment
sbal20
sbal20 on 7 May 2020
Edited: 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.
Update:
Uncompressed data was read it smoothly with both commands. Thank you again.

Sign in to comment.

More Answers (0)

Categories

Find more on ROS Log Files and Transformations in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!