rosjava custom messages: can compile and import, but not use as expected

asked 2014-11-25 13:06:06 -0500

ears_and_tails gravatar image

updated 2014-11-25 13:07:49 -0500

I am using rosindigo and rosjava. I created a rosjava_message package to create a custom foo.msg for use in my rosjava node. I followed the example in

Ros recognizes my message:

rosmsg show foo_msgs/foo

int32 intVar

float32 floatVar

string stringVar

I see it is built and foo.class looks reasonable. The generated cpp files look good too.

I can import in my publisher node and create a publisher:

final Publisher<foo> publisher_custom =
       foo._TYPE); myMessage = publisher_custom.newMessage(); myMessage = publisher_custom.newMessage();

Now I expect to be able to do myMessage.setIntVar(5), but that results in a compilation error.

If I use java's inspection to print the methods available to myMessage, it's the same methods availabe if it was a std_msgs.String message!

If I do rostopic echo /custom/topic, an exception results. I the rostopic echo expects my foo message type, but I think the std_msgs.String is being used and results in this exception:

WARNING: An exception was thrown by a user handler while handling an exception event ([id: 0x063b05a0, / :> /] EXCEPTION: java.lang.IllegalStateException: Unexpected message MD5 c9954cba4a4cc14c464daad6dfbafe15 != 131c7b16e90d7646b67a1c83cd590279) org.ros.exception.RosRuntimeException: java.lang.IllegalStateException: Unexpected message MD5 c9954cba4a4cc14c464daad6dfbafe15 != 131c7b16e90d7646b67a1c83cd590279 at org.ros.internal.transport.ConnectionTrackingHandler.exceptionCaught( at at at at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived( at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode( at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived( at at at at at at at java.util.concurrent.ThreadPoolExecutor.runWorker( at java.util.concurrent.ThreadPoolExecutor$ at Caused by: java.lang.IllegalStateException: Unexpected message MD5 c9954cba4a4cc14c464daad6dfbafe15 != 131c7b16e90d7646b67a1c83cd590279 at at org.ros.internal.node.topic.DefaultPublisher.finishHandshake( at org.ros.internal.transport.tcp.TcpServerHandshakeHandler.handleSubscriberHandshake( at org.ros.internal.transport.tcp.TcpServerHandshakeHandler.messageReceived( ... 13 more

Any pointers on how to proceed? I don't understand why the class I'm importing somehow isn't the right class(?). I only define foo.msg in one place.

edit retag flag offensive close merge delete