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

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
5

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: https://code.google.com/p/rosjava/issues/detail?id=140
 */
task deployApp(dependsOn: 'installApp') << {
  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.

edit flag offensive delete link more
1

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.

#!/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"/>
edit flag offensive delete link more

Comments

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 image ceverett  ( 2014-04-23 17:06:12 -0500 )edit

Question Tools

Stats

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

Seen: 1,760 times

Last updated: Apr 23 '14