File tree Expand file tree Collapse file tree
rcljava_utils/src/main/java/org/ros2/rcljava/tool Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1717import java .util .concurrent .ConcurrentSkipListSet ;
1818
1919import org .ros2 .rcljava .RCLJava ;
20+ import org .ros2 .rcljava .node .Node ;
2021
2122/**
2223 * Node tool CLI
2324 * @author Mickael Gaillard <mick.gaillard@gmail.com>
2425 */
2526public class Ros2Nodes {
27+ private static String NAME = Ros2Nodes .class .getSimpleName ().toLowerCase ();
28+
2629
2730 public static void main (String [] args ) throws InterruptedException {
2831
2932 // Initialize RCL
3033 RCLJava .rclJavaInit ();
31-
32- System .out .println ("List of Nodes :" );
33-
34- ConcurrentSkipListSet <String > nodeNames = new ConcurrentSkipListSet <String >(RCLJava .getNodeNames ());
34+ Node node = RCLJava .createNode (NAME );
35+ ConcurrentSkipListSet <String > nodeNames = new ConcurrentSkipListSet <String >(node .getNodeNames ());
36+ RCLJava .spinOnce (node );
3537
3638 if (nodeNames .size () > 0 ) {
3739 for (String entity : nodeNames ) {
38- System .out .println (String .format ("\t |> %s" , entity ));
40+ System .out .println (String .format ("%s" , entity ));
3941 }
4042 }else {
4143 System .out .println ("Empty topics !" );
4244 }
4345
46+ node .dispose ();
4447 RCLJava .shutdown ();
4548 }
4649}
You can’t perform that action at this time.
0 commit comments