Announcing Java and Android for ROS2

Sorry for crossposting, but I thought you folks might be interested in this.

Hey,

I just made public a set of Java and Android bindings for ROS2, I wrote
them a while ago, but they needed some updates and never had made a
proper release of them before.

Anyway, I’ve pushed it all to GitHub, they are licensed as Apache 2.0. You can follow the instructions
on [1] if you’d like to try out the examples.

There’s a few caveats (it wouldn’t be a ROS project if the word “caveat” weren’t in the announcement):

  • Not all of the API is implemented, things like QoS profiles are missing for example.
  • Domains are not supported, I stil lhave pending implementing a mechanism for setting the domain id programmatically.
  • No support for services or intraprocess communication.
  • Lack of documentation and tests

In the following days I’ll polish a few things and also put up a demo, but meanwhile you can use all this to write ROS2 applications that can run on an Android device, on a PC with the JRE and communicate with other applications written in Python or C++.

All kinds of feedback are more than welcome!

Enjoy :slight_smile:

1 - https://github.com/esteve/ros2_java

4 Likes

This is awesome @esteve! I want to test it as soon as I get a chance.

Thank again @esteve

I have lots of questions:

  • How to add & run tests (JUnit or with other testing framework) ?
  • Do you plan to add service support ?
  • Do you plan to add launch support ?
  • Do you plan to add parameter/dynamic-reconfiguration support ?

I propose my help.

Thank again @esteve

Thank you for trying it out and for your feedback :slight_smile:

  • How to add & run tests (JUnit or with other testing framework) ?

rcljava applications can use Gradle as a build system, so adding tests is
similar to any other Gradle project. However, rcljava would benefit a lot
from a specialized Gradle plug-in, so Gradle files for rcljava applications
could be much more streamlined.

As for rcljava itself, tests need to be integrated with CMake though,
because rcljava itself does not use Gradle.

  • Do you plan to add service support ?

Yes! However that requires some thought as to how to integrate services
directly with rcl instead of replicating the code from rclcpp.

  • Do you plan to add launch support ?

Not sure I understand what you mean. That part of the infrastructure
belongs in ROS2 itself, not in the language-specific bindings. Could you
expand this a bit?

  • Do you plan to add parameter/dynamic-reconfiguration support ?

Much like services, support for parameters need to exist first in rcl, and
then implemented in the client libraries. Services are already available in
rcl, but unfortunately parameters aren’t yet.

Dynamic reconfiguration is not implemented in ROS2 yet.

I propose my help.

Great! What would you like to work on? My first thought would be refining
what’s already in rcljava (build system, tests, etc.), before implementing
any new features (e.g. services), but if there’s anything else you’d like
to work on, just let me know.

Thanks!

I have started in my github to complete your implementation :

with:

  • JavaDoc
  • Header file (but i see you push-it in your last commit why not use OSRF ?)
  • QoS profile
  • Testing (but I need to add on gradle)
  • Java Service (need to add on JNI call)
  • Java Parameter (need rcl finished by core team)

I propose to you to make a clean Merge Request of JavaDoc and Testing.

For the launch case :
Nothing was define in ROS2 design page, but by experience of ROS1 if i make a xxxxxx.laucnh file and java is special.
In your implentation you need to :
eg. java -cp install_isolated/rosidl_generator_java/share/rosidl_generator_java/java/rosidl_generator_java.jar: ....
I would like to know if is possible to generate a simple script for shortcut the launch.
eg. talker_java.sh (or without exention)

Sorry for the slow response, been travelling lately.

This is impressive, thank you so much!

ros2_java is an independent project, as such, the copyright ownership is not under OSRF’s name. This is fairly common with other packages, like rosjava, whose copyright is owned by Google.

I’ll reply with more detail in the pull requests you have submitted on GitHub.

I think that’d be a bit complicated, because the JAR files may be installed anywhere and the script couldn’t know that. But if you find a way to generate such script, I’d love to add it to ros2_java

Thanks!

(crossposting from the ROS SIG NG)

A few updates to this. No demo yet, but here’s a few changes since the last time:

  • Lots of cleanups (and I mean lots)
  • Support for client and services, you can find examples in [1]
  • Added a few simple tests. The hardest part was getting the
    infrastructure in place, I expect to add more tests now that it’s much
    easier.
  • Yet another update to the Android PR to FastRTPS [2]
  • A Gradle plugin that works with both Java and Android projects [3].
    Compare for example the new build.gradle files [4][5] to the previous
    ones [6][7]

If you use this somehow, let me know if there’s anything that you’d like to see in future releases.

Enjoy!

1 - https://github.com/esteve/ros2_java_examples/tree/master/rcljava_examples/src/main/java/org/ros2/rcljava/examples
2 - https://github.com/eProsima/Fast-RTPS/pull/26
3 - https://plugins.gradle.org/plugin/org.ros2.tools.gradle
4 - https://github.com/esteve/ros2_java_examples/blob/master/rcljava_examples/build.gradle
5 - https://github.com/esteve/ros2_android_examples/blob/master/ros2_listener_android/build.gradle
6 - https://github.com/esteve/ros2_java_examples/blob/cf645b5eb23a51603e33a506abdce165eaff2ef0/rcljava_examples/build.gradle
7 - https://github.com/esteve/ros2_android_examples/blob/46deed26c7f86cecfef72074d3efdec5c1ccde46/ros2_talker_android/build.gradle