Listener.java
Go to the documentation of this file.
00001 import ros.*;
00002 import ros.communication.*;
00003 
00004 public class Listener {
00005     public static void main(String args[]) 
00006     throws InterruptedException, RosException {
00007         final Ros ros = Ros.getInstance();
00008         ros.init("Listner");
00009         
00010         ros.pkg.std_msgs.msg.String msg = new ros.pkg.std_msgs.msg.String();
00011         
00012         NodeHandle n = ros.createNodeHandle();        
00013         
00014         Subscriber.Callback<ros.pkg.std_msgs.msg.String> callback = 
00015         new Subscriber.Callback<ros.pkg.std_msgs.msg.String>() {
00016             public void call(ros.pkg.std_msgs.msg.String msg) {
00017                 ros.logInfo("Received [" + msg.data + "]"); 
00018             }
00019         };    
00020         
00021         Subscriber<ros.pkg.std_msgs.msg.String> sub; 
00022         sub = n.subscribe("chatter", 
00023                           new ros.pkg.std_msgs.msg.String(), 
00024                           callback, 
00025                           100);
00026         
00027         n.spin();
00028     }
00029 }


test_rosjava_jni
Author(s): Jason Wolfe (jawolfe@willowgarage.com)
autogenerated on Thu Jan 2 2014 11:07:07