# Can I roslaunch a rosjava node?

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.

edit retag close merge delete

Sort by » oldest newest most voted

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:
*
*/
File binDir = new File(project.projectDir, '/bin')
if (! binDir.isDirectory()) {
println "Creating $binDir directory" binDir.mkdirs() } File link = new File(binDir,"execute") File target = new File(project.projectDir, "build/install/$project.name/bin/$project.name") 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. more 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. #!/bin/sh 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"/>

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.

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