Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Running rosjava nodes using rosrun #33

Open
jubeira opened this issue Oct 3, 2017 · 1 comment
Open

Running rosjava nodes using rosrun #33

jubeira opened this issue Oct 3, 2017 · 1 comment

Comments

@jubeira
Copy link

jubeira commented Oct 3, 2017

I noticed that currently there is no "standard" way of calling a rosjava node in the regular ROS way (i.e. rosrun [package] [node] [params]).
After trying this out a little bit, I figured that we are just one step away from there (I updated the tutorials a bit). Basically, after following the standard steps to create a package, you can use rosrun like this:

# rosrun [package] [rosjava project] [node class full name]
rosrun rosjava_catkin_package_a my_pub_sub_tutorial com.github.rosjava.rosjava_catkin_package_a.my_pub_sub_tutorial.Talker

Because Gradle creates an executable script which calls RosRun class in rosjava, with the class to execute as its parameter.

The problem is that the task installApp actually creates two executable scripts inside the package. rosrun will then ask the user which one to execute instead of executing it directly.

[rosrun] You have chosen a non-unique executable, please pick one of the following:
1) /home/juan/rosjava_test_ws/src/package/project/build/scripts/project
2) /home/juan/rosjava_test_ws/src/package/project/build/install/project/bin/project
3) /home/juan/rosjava_test_ws/src/package/project/build/scripts/project
4) /home/juan/rosjava_test_ws/src/package/project/build/install/project/bin/project

If we could just eliminate the scripts under scripts directory, rosrun would work right away.

Two quick solutions come to my mind. The first one is to tweak the rosjava project template to delete them, adding something like this:

installApp.doLast {
    file('build/scripts').deleteDir()
}

The second one would be to use a custom plugin instead of application (i.e. ros-java-application), which would add the application plugin and a new task ("cleanup" or something like that). Then, tweak the CMakeLists to call this new cleanup task after installApp.
Perhaps there is a better option to tweak installApp directly from a plugin instead of using the project level build.gradle, but I really don't know how to do that in a clean way.

To sum up, this would allow using rosrun just like a regular ROS package right after using catkin_make and sourcing the workspace.

If this sounds good, I offer myself to create a PR with the fixes. Thoughts?
/cc @adamantivm @ernestmc

@gonzalezsieira
Copy link

gonzalezsieira commented Apr 6, 2018

This solution is great, but (at least for me) it only works the first time gradlew deployApp is executed. If this task is UP-TO-DATE because no changes were made, the scripts will be there when you call rosrun.

Here it is a workaround to ensure that scripts are always deleted:

task cleanScripts(dependsOn: 'installApp') << {
    file('build/scripts').deleteDir()
}

installApp.finalizedBy(cleanScripts)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants