ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

Rosjava ConnectException Eclipse without installing ROS

asked 2016-10-12 23:16:42 -0500

couchwarrior gravatar image

updated 2016-10-13 02:46:37 -0500

gvdhoorn gravatar image

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... . 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 ...
(more)
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-10-13 12:47:52 -0500

gvdhoorn gravatar image

updated 2016-10-14 03:33:20 -0500

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.

edit flag offensive delete link more

Comments

How do I start a ROS Master?

couchwarrior gravatar image couchwarrior  ( 2016-10-13 22:13:27 -0500 )edit

Thanks, I also found this answer. Tested it and it works. No ROS needed :)

couchwarrior gravatar image couchwarrior  ( 2016-10-14 21:20:36 -0500 )edit

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.

gvdhoorn gravatar image gvdhoorn  ( 2016-10-15 06:01:02 -0500 )edit

You're right. I meant I didn't need to go through the normal ROS installation

couchwarrior gravatar image couchwarrior  ( 2016-10-15 14:20:29 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-10-12 23:15:52 -0500

Seen: 237 times

Last updated: Oct 14 '16