ROS Resources: Documentation | Support | Discussion Forum | Service Status | Q&A
Ask Your Question

Can I roslaunch a rosjava node?

asked 2014-03-27 09:12:23 -0500

In previous versions of rosjava, I used to be able to start my node using roslaunch or rosrun. Now, it seems that to execute a node (as shown in the tutorials), I have to use the following syntax: ./my_pub_sub_tutorial com.github.rosjava_catkin_package_a.my_pub_sub_tutorial.Talker &

Please advise if it is still possible to use roslaunch and a launch file. I prefer to launch my java nodes this way, to be able to set parameters in a consistent way with my C++ based nodes. Now, I get an errror, "cannot launch node of type [execute]".

Also, it is not clear if I should be creating my rosjava subprojects as libraries (jar files) or executables to do this.

Thanks in advance.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted

answered 2014-04-23 17:03:51 -0500

It turns out that this was working before due to a gradlew trick that creates an executable, linked to the jar file, that I had set up a long time ago, and forgotten. This was based on another post that I found (see the link in the code comment). I added this to my build.gradle:

 * Create a deploy task to make an executable named "execute",
 * that can be used from the roslaunch .launch files.
 * To run this from this directory, do:
 * ../gradlew deployApp
 * see:
task deployApp(dependsOn: 'installApp') << {
  File binDir = new File(project.projectDir, '/bin')
  if (! binDir.isDirectory()) {
    println "Creating $binDir directory"
  File link = new File(binDir,"execute")
  File target = new File(project.projectDir, "build/install/$$")
  println "Creating symlink from $link.absolutePath to $target.absolutePath"
  ant.symlink(link: link.absolutePath, resource: target.absolutePath, overwrite: true)

Then, I can have a launchfile with a node that looks like this, note the type of "execute" for the java node:

<node pkg="my_pub_sub_tutorial" type="execute" name="my_pub_sub_tutorial" args="com.github.rosjava_catkin_package_a.my_pub_sub_tutorial.Talker"/>

and I can roslaunch it like any other node.

edit flag offensive delete link more

answered 2014-04-09 15:56:45 -0500

Daniel Stonier gravatar image

updated 2014-04-09 15:58:01 -0500

Two ways that I can think of, though I haven't really tried this out much myself, so let me know how they go.

You can create shell scripts to executable jars that can then be used in roslaunch. Damon does this with his test scripts in rosjava_core. e.g.

exec java -jar `rospack find rosjava`/dist/rosjava.jar org.ros.ParameterServerTestNode $@

Alternatively, you should be able to put those installApp scripts directly into a roslaunch (is this how you were trying?):

<node pkg="my_pub_sub_tutorial" type="my_pub_sub_tutorial" name="my_pub_sub_tutorial" args="com.github.rosjava_catkin_package_a.my_pub_sub_tutorial.Talker"/>
edit flag offensive delete link more


Thanks, Daniel for your help. Your roslaunch is close, it just needs the type to be set to an executable. See my answer below. I found this solution once, and then it got lost when I migrated everything to Catkin. The nice thing is that it all builds in catkin now, and I can roslaunch.

ceverett gravatar imageceverett ( 2014-04-23 17:06:12 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools


Asked: 2014-03-27 09:12:23 -0500

Seen: 1,444 times

Last updated: Apr 23 '14