rosjava(pure) pubsub tutorial
Hi~
I'm using the new, pure-java rosjava. I installed ros(diamonback) and rosjava by rosinstall in my ubuntu(lucid). and build rosjava.jar successfully.
I want talk to other node using pubsub tutorial in rosjava. I imported rosjava.jar and other libraries in eclipse project and modified the source as below. (commons-codec-1.3.jar, commons-httpclient-3.1.jar, commons-loggin-1.1.1.jar, dnsjava-2.1.1.jar, guava-r07.jar, junit-4.8.2.jar, mockito-all-1.8.5.jar, netty-3.2.4.Final.jar, rosjava.jar)
When I run below program by java application, I got this error message.
Hello
java.lang.NullPointerException
at org.ros.Node.<init>(Node.java:95)
at Hell.main(Hell.java:19)
at Hell.main(Hell.java:43)
I also tried to debugging with eclipse but, I couldn't debugging with source with this message
Source not found, [Edit Source Lookup Path ...] button.
I tried to connect ros source directory(ros/rosjava/rosjava/src) and include the rosjava source(org.ros), but It also fail to find the source.
Please help me. I'm beginner of the java language. If this question is too sil7ly, Please understand me.
Thanks!
/*
* Copyright (C) 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
import com.google.common.base.Preconditions;
import org.ros.Node;
import org.ros.NodeConfiguration;
import org.ros.NodeMain;
import org.ros.Publisher;
public class Hell implements NodeMain {
private Node node;
/**
* @param args
*/
public void main(NodeConfiguration configuration){
Preconditions.checkState(node == null);
Preconditions.checkNotNull(configuration);
try {
node = new Node("talker", configuration);
Publisher<org.ros.message.std_msgs.String> publisher =
node.createPublisher("chatter", org.ros.message.std_msgs.String.class);
int seq = 0;
while (true) {
org.ros.message.std_msgs.String str = new org.ros.message.std_msgs.String();
str.data = "Hello world! " + seq++;
publisher.publish(str);
Thread.sleep(1000);
}
} catch (Exception e) {
if (node != null) {
node.getLog().fatal(e);
} else {
e.printStackTrace();
}
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
System.out.println("Hello");
Hell h = new Hell();
NodeConfiguration node_cfg = new NodeConfiguration();
h.main(node_cfg);
}
public void shutdown() {
node.shutdown();
node = null;
}
}