Simple way of starting ROSJava Nodes from using rosrun or roslaunch #140
Description
Original author: remi.barraquand (August 27, 2012 14:49:06)
Dear all!
In the current version of ROS Java it appears that the only way to run a node is to call the ./build/install/$projectName/bin/$projectName executable which is created by the 'installApp' gradle task.
This can be annoying, for instance you may want to run your node using the rosrun utility or using the roslaunch utility.
The purpose of this post is to propose to you a simple way to do it. The solution is simple. I updated the build.gradle file to embed a "deployApp" task (the whole file is given as an attached file):
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)
}
I fact it simply create a symbolic link in the /bin directory.
The reason why the file created is named "execute" is because if you use $project.name instead it does not work for some obscure reasons.... (I didn't investigate any further...)
Well, now what you have to do is simply call:
> gradle deployApp
Then do:
> rosrun pkg_name execute some.package.path.YourNodeClass
If you want to create a basic launch file, simply:
<launch>
<node pkg="$pkg_name"
name="$pkg_name"
type="execute"
args="some.package.path.YourNodeClass"
output="screen">
</node>
</launch>
I hope this will help,
Best,
Rémi Barraquand
Original issue: http://code.google.com/p/rosjava/issues/detail?id=140