ROS nodes must have unique names. Two start two nodes of the same type in c++, you would use the command line arguments to set the name of the nodes, which would override the default. <div><br></div><div>I'm not sure if this command line argument name remapping was implemented in java, but if it wasn't, you may consider having java append a random number to the end of the node name. </div>
<div><br></div><div>--Nick </div><div><br><div class="gmail_quote">On Tue, Jun 21, 2011 at 10:33 AM, Abhishek Verma <span dir="ltr"><<a href="mailto:toabhishekverma@gmail.com">toabhishekverma@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi Friends,<div><br></div><div>I am seeing following exception </div><div><br></div><div><div>21-Jun-2011 18:29:01 org.apache.xmlrpc.server.XmlRpcErrorLogger log</div>
<div>SEVERE: Failed to invoke method registerSubscriber in class org.ros.internal.node.xmlrpc.MasterImpl: null</div>

<div>org.apache.xmlrpc.common.XmlRpcInvocationException: Failed to invoke method registerSubscriber in class org.ros.internal.node.xmlrpc.MasterImpl: null</div><div><span style="white-space:pre-wrap">      </span>at org.apache.xmlrpc.server.ReflectiveXmlRpcHandler.invoke(ReflectiveXmlRpcHandler.java:129)</div>


<div><span style="white-space:pre-wrap">  </span>at org.apache.xmlrpc.server.ReflectiveXmlRpcHandler.execute(ReflectiveXmlRpcHandler.java:106)</div><div><span style="white-space:pre-wrap">    </span>at org.apache.xmlrpc.server.XmlRpcServerWorker.execute(XmlRpcServerWorker.java:46)</div>


<div><span style="white-space:pre-wrap">  </span>at org.apache.xmlrpc.server.XmlRpcServer.execute(XmlRpcServer.java:86)</div><div><span style="white-space:pre-wrap">   </span>at org.apache.xmlrpc.server.XmlRpcStreamServer.execute(XmlRpcStreamServer.java:200)</div>


<div><span style="white-space:pre-wrap">  </span>at org.apache.xmlrpc.webserver.Connection.run(Connection.java:208)</div><div><span style="white-space:pre-wrap">       </span>at org.apache.xmlrpc.util.ThreadPool$Poolable$1.run(ThreadPool.java:68)</div>


<div>Caused by: java.lang.IllegalStateException</div><div><span style="white-space:pre-wrap"> </span>at com.google.common.base.Preconditions.checkState(Preconditions.java:129)</div><div><span style="white-space:pre-wrap">       </span>at org.ros.internal.node.server.MasterServer.addSlave(MasterServer.java:80)</div>


<div><span style="white-space:pre-wrap">  </span>at org.ros.internal.node.server.MasterServer.registerSubscriber(MasterServer.java:110)</div><div><span style="white-space:pre-wrap">   </span>at org.ros.internal.node.xmlrpc.MasterImpl.registerSubscriber(MasterImpl.java:123)</div>


<div><span style="white-space:pre-wrap">  </span>at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)</div><div><span style="white-space:pre-wrap">   </span>at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)</div>


<div><span style="white-space:pre-wrap">  </span>at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)</div><div><span style="white-space:pre-wrap"> </span>at java.lang.reflect.Method.invoke(Method.java:597)</div>


<div><span style="white-space:pre-wrap">  </span>at org.apache.xmlrpc.server.ReflectiveXmlRpcHandler.invoke(ReflectiveXmlRpcHandler.java:115)</div></div><div><br></div><div><br></div><div>My code is </div>

<div><br></div><div>//Publisher</div><div><div>node = new Node(<font color="#3366ff">"Camera1"</font>, configuration);</div><div><span style="white-space:pre-wrap">                      </span>publisher = node.createPublisher("Camera1",</div>


<div><span style="white-space:pre-wrap">                                  </span>org.ros.message.sensor_msgs.Image.class);</div></div><div>....................</div><div><br></div><div>//Subscriber </div><div><div> node = new Node(<font color="#3366ff">"Camera1</font>", configuration);</div>


<div>      System.out.println("ScreenView.main() Starting");</div><div>//      final Log log = node.getLog();</div><div>      node.createSubscriber("Camera1", new MessageListener<org.ros.message.sensor_msgs.Image>() {</div>


<div>        public void onNewMessage(org.ros.message.sensor_msgs.Image message) {</div><div>          System.out</div><div><span style="white-space:pre-wrap">                           </span>.println("Subscriber \"" + message + "\"");</div>


<div>        }</div><div>      }, org.ros.message.sensor_msgs.Image.class);</div></div><div><br></div><div><br></div><div>Reason behind this exception is Nodes with same name.</div><div>If I change this name and create different nodes in publisher and subscribers code then its fine.</div>


<div><br></div><div>Anyone has any idea why is that or we are not supposed to create node with same name?</div><div><br clear="all">Thanks and Regards<br>Abhishek Verma<br>
</div>
<br>_______________________________________________<br>
ros-users mailing list<br>
<a href="mailto:ros-users@code.ros.org">ros-users@code.ros.org</a><br>
<a href="https://code.ros.org/mailman/listinfo/ros-users" target="_blank">https://code.ros.org/mailman/listinfo/ros-users</a><br>
<br></blockquote></div><br></div>