Announcing Java and Android for ROS2

663 views
Skip to first unread message

Esteve Fernandez

unread,
Aug 23, 2016, 4:33:02 PM8/23/16
to ROS SIG NG ROS
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 :-)

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

Steven

unread,
Aug 23, 2016, 11:38:28 PM8/23/16
to ROS SIG NG ROS
This is great Esteve! Thanks for sharing! Cool that you support various middleware implementations!

How are you thinking of supporting intraprocess communication -- short circuit message passing before it makes it to the JNI bindings? Sorry if noob questions... I used ROS1 and rosjava awhile ago and have been following ROS2 anxious for a stab at a java implementation!

Steve

Esteve Fernandez

unread,
Aug 24, 2016, 7:07:37 AM8/24/16
to ros-sig-ng-ros
Hi Steve,

On Wed, Aug 24, 2016 at 5:38 AM, Steven <whathasno...@gmail.com> wrote:
> This is great Esteve! Thanks for sharing!

thanks for your kind words :-) Let me know if you find ros2_java
useful and if there's anything that can be improved.

> Cool that you support various middleware implementations!

Any RMW implementation that implements the C typesupport interface
will do. So far all the supported RMW implementations (opensplice,
fastrtps, connext) of ROS2 work with ros2_java.

> How are you thinking of supporting intraprocess communication -- short
> circuit message passing before it makes it to the JNI bindings? Sorry if
> noob questions... I used ROS1 and rosjava awhile ago and have been following
> ROS2 anxious for a stab at a java implementation!

Yeah, what you describe is what I had in mind, all the Java <-> JNI
<-> RCL conversions have a cost, which can be avoided if subscribers
and publishers happen to be running in the same process.

BTW, I forgot to mention what currently works, I ended up focusing too
much on what doesn't in my previous email, I'm a terrible publicist.

- Creation of named nodes
- Code generation for primitives (integers, floating point numbers,
strings, etc.), nested types, lists and fixed-sized arrays
- Typesafe publishers and subscribers for any message
- Android 4.4+, when using
https://github.com/eProsima/Fast-RTPS/pull/26 as a DDS implementation.
Please share your experience in that PR, it'd help the FastRTPS
developers know there's interest in having their code running on Android
and it'd be great to get the changes merged upstream.
- Support for Java 8's lambdas for callbacks and interface-based
callbacks (via implementing the rcljava.Consumer interface) for Java 7
and lower.
- Support for Gradle, no need for CMake for building Java applications

Cheers.

William Woodall

unread,
Aug 24, 2016, 2:20:22 PM8/24/16
to ROS SIG NG ROS
Cool! 👍

How are you using Gradle? Are you calling it from CMake (I see CMakeLists.txt still) or is it just that the artifacts let you use gradle for code that goes on top or something else?

Thanks for sharing,

--
You received this message because you are subscribed to the Google Groups "ROS SIG NG ROS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ros-sig-ng-ros+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
William Woodall
ROS Development Team

Esteve Fernandez

unread,
Aug 24, 2016, 4:41:52 PM8/24/16
to ros-sig-ng-ros
Thanks!

I added an additional build system for Ament [1] which runs Gradle. The Gradle scripts are rather ugly, I'm thinking of writing a Gradle plugin for ament_gradle projects would help so that Gradle build scripts wouldn't require so much boilerplate code.

rcljava itself uses CMake to build a JNI wrapper for each RMW implementation (much like rclpy), but the examples [2][3] for both Java and Android use Gradle as a build system.

Cheers.

William Woodall

unread,
Aug 24, 2016, 4:44:08 PM8/24/16
to ROS SIG NG ROS
Cool :)

Esteve Fernandez

unread,
Aug 25, 2016, 5:37:17 AM8/25/16
to ros-sig-ng-ros
Thanks! :-)

There's still a lot of stuff to do, but I'd say it's feature par with the rclpy bindings. I hope I can find some time next week for putting up a demo that uses the sensors from an Android device to drive a robot. Or for some sort of IoT application, given that it's DDS after all.

Brian Gerkey

unread,
Aug 25, 2016, 5:23:40 PM8/25/16
to ros-sig...@googlegroups.com
Nice! And +1 to a compelling Android demo.

Esteve Fernandez

unread,
Oct 4, 2016, 8:12:28 AM10/4/16
to ros-sig-ng-ros
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!

Reply all
Reply to author
Forward
0 new messages