"Official" Java Client Library

I would love to switch to rcljava, but I think a major concern from us is how to distribute the resulting application(s). ROS2 support is a small part of out application, however it is hard to use ROS2 without making your application compile and start using the ROS2 build/launch systems.

I think to have Java developers adopt ROS2, it should play well with the Java build systems (Gradle/Maven) and it should be distributed as a single dependency line in your gradle file. (api: 'org.ros:rcljava:1.0.0) and start without a ROS2 workspace.

As for serializing/deserializing I think that is best done in the target language, or sending raw data should at least be exposed from rclc. The serialization format CDR is pretty trivial to implement and fast-rtps already includes Java code to generate the messages. On the other hand, native calls have an enormous overhead so having to drop down to native code for every field will be a major performance hit. Furthermore, string serialization needs some smarts to be allocation free and will not play well with JNI. Our current serialization libraries also allow serialization to YAML/JSON/XML which allows us to use the ROS idl format for all serialization needs.

To give some background I’ve tried to make a rcl for C# used with Unity a while ago. We work on Unity integration to give non-robot-developers/students an easy way to make our robot do certain tasks. However I ran in the following issues

  • Installing and using ROS2 under Windows is hard for non-developers (or at least was till Bouncy) and a lot of work for developers
  • You have to start your application/IDE from the ROS2 workspace (either a bat/sh file or terminal usage)
  • Does not play well with the packaging and application creation of Unity (or any other system).
  • Creating a new message requires rebooting in every OS and recompiling the native library and then publishing it.

After spending significant time on this, I created a trivial Websocket/JSON bridge (using our Java implementation) to talk to ROS2 which is much less work to support than even just installing/building ROS2.

I think that unfortunately, the current ROS2 ecosystem makes the easiest way to expose ROS2 in an existing application written in a different language than C/C++ (or a C/C++ application with a legacy build system/main) is to use a service like https://github.com/RobotWebTools/ros2-web-bridge.