0
$\begingroup$

Rosanswers logo

I'm running rosjava on Eclipse on a Mac without installing ROS, but just pulling in rosjava_core in my build.gradle, thinking this is possible after reading this tutorial http://wiki.ros.org/rosjava/Tutorials/indigo/No%20Ros%20Installation. I create a RosTest class with a main method that just calls RosRun.main("ros.Talker"). Talker has code from the rosjava tutorial to publish Hello World every second. When Talker tries to instantiate a publisher or publish a message, not sure which, I get a ConnectException trying to connect to some socket. Any help is appreciated. I'm trying to avoid having to work on Linux and installing ROS, but since the code will eventually end up on a Raspberry Pi, it's not out of the picture. I would just love to believe that rosjava can be used like any other library without installing ros or pulling it down from github and running gradlew install.

My Build.gradle

repositories {
  maven {
    url "https://github.com/rosjava/rosjava_mvn_repo/raw/master"
  }
}

dependencies {
  compile 'org.ros.rosjava_core:rosjava:[0.2,0.3)'
  compile 'org.ros.rosjava_messages:geometry_msgs:[1.11,1.12)' }

My Error Log

Oct 12, 2016 10:05:56 PM org.ros.internal.node.topic.DefaultPublisher$1 onMasterRegistrationFailure

INFO: Publisher registration failed: Publisher<PublisherDefinition<PublisherIdentifier<NodeIdentifier</Talker, http://127.0.0.1:57539/>, TopicIdentifier</rosout>>, Topic<TopicIdentifier</rosout>, TopicDescription<rosgraph_msgs/Log, acffd30cd6b6de30f120938c17c593fb>>>>

Oct 12, 2016 10:06:01 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection refused
Oct 12, 2016 10:06:01 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: Retrying request
Oct 12, 2016 10:06:01 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection refused
Oct 12, 2016 10:06:01 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: Retrying request
Oct 12, 2016 10:06:01 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: I/O exception (java.net.ConnectException) caught when processing request: Connection refused
Oct 12, 2016 10:06:01 PM org.apache.commons.httpclient.HttpMethodDirector executeWithRetry
INFO: Retrying request
Oct 12, 2016 10:06:01 PM org.ros.internal.node.client.Registrar callMaster

SEVERE: Exception caught while communicating with master.

java.lang.RuntimeException: java.net.ConnectException: Connection refused
at org.ros.internal.node.xmlrpc.XmlRpcClientFactory$1.invoke(XmlRpcClientFactory.java:157)
at com.sun.proxy.$Proxy0.registerPublisher(Unknown Source)
at org.ros.internal.node.client.MasterClient.registerPublisher(MasterClient.java:144)
at org.ros.internal.node.client.Registrar$1$1.call(Registrar.java:138)
at org.ros.internal.node.client.Registrar$1$1.call(Registrar.java:135)
at org.ros.internal.node.client.Registrar.callMaster(Registrar.java:111)
at org.ros.internal.node.client.Registrar.access$100(Registrar.java:51)
at org.ros.internal.node.client.Registrar$1.call(Registrar.java:135)
at org.ros.internal.node.client.Registrar$1.call(Registrar.java:132)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: java.net.ConnectException: Connection refused
at java.net.PlainSocketImpl.socketConnect(Native Method)
at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:345)
at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
at java.net.Socket.connect(Socket.java:589)
at sun.reflect.GeneratedMethodAccessor5.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.apache.commons.httpclient.protocol.ReflectionSocketFactory.createSocket(ReflectionSocketFactory.java:140)
at org.apache.commons.httpclient.protocol.DefaultProtocolSocketFactory.createSocket(DefaultProtocolSocketFactory.java:125)
at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
at org.apache.xmlrpc.client.XmlRpcCommonsTransport.writeRequest(XmlRpcCommonsTransport.java:227)
at org.apache.xmlrpc.client.XmlRpcStreamTransport.sendRequest(XmlRpcStreamTransport.java:151)
at org.apache.xmlrpc.client.XmlRpcHttpTransport.sendRequest(XmlRpcHttpTransport.java:143)
at org.apache.xmlrpc.client.XmlRpcClientWorker$1.run(XmlRpcClientWorker.java:80)

... 1 more

Oct 12, 2016 10:06:01 PM org.ros.internal.node.topic.DefaultPublisher$1 onMasterRegistrationFailure

INFO: Publisher registration failed: Publisher<PublisherDefinition<PublisherIdentifier<NodeIdentifier</Talker, http://127.0.0.1:57539/>, TopicIdentifier</rosout>>, Topic<TopicIdentifier</rosout>, TopicDescription<rosgraph_msgs/Log, acffd30cd6b6de30f120938c17c593fb>>>>

Originally posted by couchwarrior on ROS Answers with karma: 5 on 2016-10-12

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

Afaict, there's nothing really wrong, other than that your node(s) is (are) trying to contact a ROS master that isn't responding.

Are you starting one before trying to run your node(s)?


Edit:

How do I start a ROS Master?

Well, typically you'd use a roscore instance, but that would require a ROS installation. I'm not a rosjava expert, but it does include a pure Java master implementation afaik. It's just slightly less straightforward to run it.

The wiki/android/RosActivity tutorial has some info on how to add a Master Chooser to your application, but that seems like it's Android only (the chooser also allows you to start a new local master).

5 mins googling led me to this comment by Damon Kohler and this issue on how to create a minimal master in rosjava. Perhaps that is something you can use. It might be that this is no longer something you'd need to create yourself (ie: rosjava includes a stand-alone master already), but I can't find anything right now.

PS: just to make sure the rest of your application is ok, I'd actually test against a 'normal' roscore. That would give you a proper baseline, after which you could look into the rosjava master. But it obviously depends on whether you have a ROS installation handy somewhere.


Originally posted by gvdhoorn with karma: 86574 on 2016-10-13

This answer was ACCEPTED on the original site

Post score: 1


Original comments

Comment by couchwarrior on 2016-10-13:
How do I start a ROS Master?

Comment by couchwarrior on 2016-10-14:
Thanks, I also found this answer. Tested it and it works. No ROS needed :)

Comment by gvdhoorn on 2016-10-15:
Good to hear you got it to work.

No ROS needed :)

That is a bit of strange thing to say: rosjave is a ROS client library, so in a way, you're still using ROS.

Comment by couchwarrior on 2016-10-15:
You're right. I meant I didn't need to go through the normal ROS installation

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.