[ros-users] rosjava Exception if create two Nodes with same name

Nicholas Butko nbutko at ucsd.edu
Wed Jun 22 14:48:36 UTC 2011


Damon,

One option is to take the course of "When in doubt, follow the behavior of
roscpp." In that case, when a second node registers with the same name, the
first node dies. For example, if you run

{{{
rosrun roscpp_tutorials talker
}}}

twice, the second instance behaves normally, but the first instance shows

{{{
[ INFO] [1308753854.115622000]: hello world 72
[ INFO] [1308753854.215643000]: hello world 73
[ WARN] [1308753854.285720000]: Shutdown request received.
[ WARN] [1308753854.285791000]: Reason given for shutdown: [new node
registered with same name]
[ INFO] [1308753854.315770000]: hello world 74
}}}

Just a thought. What do you think?

--Nick


On Wed, Jun 22, 2011 at 7:03 AM, Damon Kohler <damonkohler at google.com>wrote:

> So, I can explain what's going on, but I'll have to think about what
> the correct behavior should be. Please file an issue about this.
>
> Basically, the exception that's being thrown is correct. You should
> not try to register two nodes with the same name.
>
> The reason it still works is that you don't _have_ to register a
> subscriber in order to connect it to a publisher. At the point the
> exception is thrown, the subscriber has enough information to connect
> to the publisher.
>
> Because the master registration happens asynchronously, it doesn't
> affect your ability to connect to the publisher. To do that, we'd
> either have to wait for registration to succeed, or disconnect you
> some time in the future if it failed. Both of those options are pretty
> terrible.
>
> Damon
>
> On Tue, Jun 21, 2011 at 8:25 PM, Abhishek Verma
> <toabhishekverma at gmail.com> wrote:
> > How about remote subscribers ?
> > I dont know if this use case exist or not but There can be remote
> > publisher/subscriber?
> > What happens in c++? Do code core refuse connection?
> >
> > Rosjava need fix ...I am seeing this exception but publisher and
> subscriber
> > are able to communicate..(with exception)
> >
> >
> > Thanks and Regards
> > Abhishek Verma
> >
> >
> > On Tue, Jun 21, 2011 at 6:41 PM, Nicholas Butko <nbutko at ucsd.edu> wrote:
> >>
> >> 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.
> >> 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.
> >> --Nick
> >> On Tue, Jun 21, 2011 at 10:33 AM, Abhishek Verma
> >> <toabhishekverma at gmail.com> wrote:
> >>>
> >>> Hi Friends,
> >>> I am seeing following exception
> >>> 21-Jun-2011 18:29:01 org.apache.xmlrpc.server.XmlRpcErrorLogger log
> >>> SEVERE: Failed to invoke method registerSubscriber in class
> >>> org.ros.internal.node.xmlrpc.MasterImpl: null
> >>> org.apache.xmlrpc.common.XmlRpcInvocationException: Failed to invoke
> >>> method registerSubscriber in class
> org.ros.internal.node.xmlrpc.MasterImpl:
> >>> null
> >>> at
> >>>
> org.apache.xmlrpc.server.ReflectiveXmlRpcHandler.invoke(ReflectiveXmlRpcHandler.java:129)
> >>> at
> >>>
> org.apache.xmlrpc.server.ReflectiveXmlRpcHandler.execute(ReflectiveXmlRpcHandler.java:106)
> >>> at
> >>>
> org.apache.xmlrpc.server.XmlRpcServerWorker.execute(XmlRpcServerWorker.java:46)
> >>> at org.apache.xmlrpc.server.XmlRpcServer.execute(XmlRpcServer.java:86)
> >>> at
> >>>
> org.apache.xmlrpc.server.XmlRpcStreamServer.execute(XmlRpcStreamServer.java:200)
> >>> at org.apache.xmlrpc.webserver.Connection.run(Connection.java:208)
> >>> at org.apache.xmlrpc.util.ThreadPool$Poolable$1.run(ThreadPool.java:68)
> >>> Caused by: java.lang.IllegalStateException
> >>> at
> >>> com.google.common.base.Preconditions.checkState(Preconditions.java:129)
> >>> at
> >>>
> org.ros.internal.node.server.MasterServer.addSlave(MasterServer.java:80)
> >>> at
> >>>
> org.ros.internal.node.server.MasterServer.registerSubscriber(MasterServer.java:110)
> >>> at
> >>>
> org.ros.internal.node.xmlrpc.MasterImpl.registerSubscriber(MasterImpl.java:123)
> >>> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> >>> at
> >>>
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
> >>> at
> >>>
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
> >>> at java.lang.reflect.Method.invoke(Method.java:597)
> >>> at
> >>>
> org.apache.xmlrpc.server.ReflectiveXmlRpcHandler.invoke(ReflectiveXmlRpcHandler.java:115)
> >>>
> >>> My code is
> >>> //Publisher
> >>> node = new Node("Camera1", configuration);
> >>> publisher = node.createPublisher("Camera1",
> >>> org.ros.message.sensor_msgs.Image.class);
> >>> ....................
> >>> //Subscriber
> >>>  node = new Node("Camera1", configuration);
> >>>       System.out.println("ScreenView.main() Starting");
> >>> //      final Log log = node.getLog();
> >>>       node.createSubscriber("Camera1", new
> >>> MessageListener<org.ros.message.sensor_msgs.Image>() {
> >>>         public void onNewMessage(org.ros.message.sensor_msgs.Image
> >>> message) {
> >>>           System.out
> >>> .println("Subscriber \"" + message + "\"");
> >>>         }
> >>>       }, org.ros.message.sensor_msgs.Image.class);
> >>>
> >>> Reason behind this exception is Nodes with same name.
> >>> If I change this name and create different nodes in publisher and
> >>> subscribers code then its fine.
> >>> Anyone has any idea why is that or we are not supposed to create node
> >>> with same name?
> >>> Thanks and Regards
> >>> Abhishek Verma
> >>>
> >>> _______________________________________________
> >>> ros-users mailing list
> >>> ros-users at code.ros.org
> >>> https://code.ros.org/mailman/listinfo/ros-users
> >>>
> >>
> >>
> >> _______________________________________________
> >> ros-users mailing list
> >> ros-users at code.ros.org
> >> https://code.ros.org/mailman/listinfo/ros-users
> >>
> >
> >
> > _______________________________________________
> > ros-users mailing list
> > ros-users at code.ros.org
> > https://code.ros.org/mailman/listinfo/ros-users
> >
> >
>
>
>
> --
> ----------------------------------------------
> Damon Kohler
> Software Engineer
>
> Google Germany GmbH
> Dienerstr. 12
> 80331 München
> ----------------------------------------------
> AG Hamburg, HRB 86891
> Sitz der Gesellschaft: Hamburg
> Geschäftsführer: John Herlihy, Graham Law, Lloyd Martin, Kent Walker
> ----------------------------------------------
> Diese E-Mail ist vertraulich. Wenn Sie nicht der richtige Adressat
> sind, leiten Sie diese bitte nicht weiter, informieren den Absender
> und löschen Sie die E-Mail und alle Anhänge. Vielen Dank.
>
> This email is confidential. If you are not the right addressee please
> do not forward it, please inform the sender, and please erase this
> e-mail including any attachments. Thanks.
> _______________________________________________
> ros-users mailing list
> ros-users at code.ros.org
> https://code.ros.org/mailman/listinfo/ros-users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ros.org/pipermail/ros-users/attachments/20110622/743d34f5/attachment-0002.html>


More information about the ros-users mailing list