Message Type: rosjava subscriber problem
Hello ROS community,
My problem seems pretty simple to fix, but since I'm new to ROS (and my java is a bit rusty) and I'm running into a few problems. Right now, all I'm doing is trying to create a subscriber node that will subscribe to the turtlebot's /odom message. Currently in my onNewMessage method, I have no code except a simple System.out.println("Well, at least I got something..."); To test if I successfully detect the message.
Unfortunately I never make it to that point in my code as I run into this guy:
EXCEPTION: java.lang.NegativeArraySizeException) org.ros.exception.RosRuntimeException: java.lang.NegativeArraySizeException
I'm positive that the /odom topic is running and can rostopic echo it just fine. Here is my code, I got it from the rosjava external documentation and modified it to try and accept the nav_msgs/Odometry type instead of a String. I got the original code here: http://docs.rosjava.googlecode.com/hg/rosjava_core/html/getting_started.html
package mypackagename;
import nav_msgs.Odometry;
import org.ros.message.MessageListener;
import org.ros.namespace.GraphName;
import org.ros.node.AbstractNodeMain;
import org.ros.node.ConnectedNode;
import org.ros.node.topic.Subscriber;
public class OdometryCollector extends AbstractNodeMain {
public GraphName getDefaultNodeName() {
return new GraphName("mypackagename/OdemetryCollector");
}
public void onStart(ConnectedNode connectedNode) {
Subscriber<nav_msgs.Odometry> odomCollector = connectedNode.newSubscriber("/odom", "nav_msgs/Odometry");
odomCollector.addMessageListener(new MessageListener<nav_msgs.Odometry>() {
public void onNewMessage(nav_msgs.Odometry arg0) {
System.out.println("Well, At least I got something...");
};
});
}
}
This is my console output with the --info option activated:
Loading node class: robonav.OdometryCollector Jun 20, 2012 9:36:36 AM org.ros.internal.node.client.Registrar <init> INFO: MasterXmlRpcEndpoint URI: http://192.168.0.24:11311 Jun 20, 2012 9:36:36 AM org.ros.internal.node.client.Registrar onPublisherAdded INFO: Registering publisher: Publisher<publisherdefinition<publisheridentifier<nodeidentifier< robonav="" odemetrycollector,="" <a="" href="http://192.168.0.226:39828">http://192.168.0.226:39828/>, TopicIdentifier</rosout>>, Topic<topicidentifier< rosout="">, TopicDescription<rosgraph_msgs log,="" acffd30cd6b6de30f120938c17c593fb="">>>> Jun 20, 2012 9:36:36 AM org.ros.internal.node.client.Registrar callMaster INFO: Response<success, registered="" [="" robonav="" odemetrycollector]="" as="" publisher="" of="" [="" rosout],="" [<a="" href="http://192.168.0.24:55348">http://192.168.0.24:55348/]> Jun 20, 2012 9:36:36 AM org.ros.internal.node.topic.DefaultPublisher$1 onMasterRegistrationSuccess INFO: Publisher registered: Publisher<publisherdefinition<publisheridentifier<nodeidentifier< robonav="" odemetrycollector,="" <a="" href="http://192.168.0.226:39828">http://192.168.0.226:39828/>, TopicIdentifier</rosout>>, Topic<topicidentifier< rosout="">, TopicDescription<rosgraph_msgs log,="" acffd30cd6b6de30f120938c17c593fb="">>>> Jun 20, 2012 9:36:36 AM org.ros.internal.node.client.Registrar onSubscriberAdded INFO: Registering subscriber: Subscriber<topic<topicidentifier< odom="">, TopicDescription<nav_msgs odometry,="" cd5e73d190d741a2f92e81eda573aca7>>>="" jun="" 20,="" 2012="" 9:36:36="" am="" org.ros.internal.node.client.registrar="" callmaster="" info:="" response<success,="" subscribed="" to="" [="" odom],="" [<a="" href="http://192.168.0.24:60375">http://192.168.0.24:60375/]> Jun 20, 2012 9:36:36 AM org.ros.internal.node.topic.DefaultSubscriber$1 onMasterRegistrationSuccess INFO: Subscriber registered: Subscriber<topic ...