Usage of MessageDeserializer to create message from byte array

asked 2015-02-27 13:40:20 -0500

r2doesinc gravatar image

updated 2015-03-02 07:54:52 -0500

Hello! I am working on rebuilding ros_serial for android and have run into a problem creating the actual Message object from the byte array.

In the last supported version, it was as simple as

TopicInfo tI = new TopicInfo();

Ros now uses the MessageDeserializer and MessageSerializer, and for the life of me, I cant seem to get the ChannelBuffer to cooperate. The obvious usage would be,

 ChannelBuffer channelBuffer = ChannelBuffers.copiedBuffer(ByteOrder.LITTLE_ENDIAN, buffer);
 MessageDeserializer<Message> serializer = node.getMessageSerializationFactory().newMessageDeserializer(type);

but this crashes with the following error.

E//node ( 2549): Unable to read input stream E//node ( 2549): java.lang.IndexOutOfBoundsException: Invalid combined index of 458881, maximum is 72 E//node ( 2549): at org.jboss.netty.buffer.SlicedChannelBuffer.<init>( E//node ( 2549): at org.jboss.netty.buffer.HeapChannelBuffer.slice( E//node ( 2549): at org.jboss.netty.buffer.AbstractChannelBuffer.readSlice( E//node ( 2549): at org.ros.internal.message.field.PrimitiveFieldType$14.deserialize( E//node ( 2549): at org.ros.internal.message.field.PrimitiveFieldType$14.deserialize( E//node ( 2549): at org.ros.internal.message.field.ValueField.deserialize( E//node ( 2549): at org.ros.internal.message.DefaultMessageDeserializer.deserialize( E//node ( 2549): at com.cloudspace.rosserial.Protocol.parsePacket( E//node ( 2549): at com.cloudspace.rosserial.ROSSerial.handleByte( E//node ( 2549): at E//node ( 2549): at

How do you deserialize a message passed from ros_serial?

edit retag flag offensive close merge delete


I have the same problem with it.

barovehicles gravatar image barovehicles  ( 2017-08-29 02:10:18 -0500 )edit