jrosclient is a pure Java client which allows to interact with ROS.
Previously it had support only for ROS1 (Noetic).
In new version it supports ROS2 (Humble Hawksbill) as well.
Github page
Documentation
There are separate support for ROS2 Topics, Actions and Services.
For ROS2 transport protocol implementation, jrosclient relies on rtpstalk which is also Java based and does not depend on any native libraries.
9 Likes
Previously jrosclient supported only ROS2 services.
Now we added support for ROS1 services as well in jros1services
1 Like
Release of jros2client v3
Major update is support of ROS2 CycloneDDS RMW.
Details:
Previously rtpstalk supported only RTPS versions 2.2 and 2.3. CycloneDDS 0.9.x (Papillons), which is included into ROS2 Humble, uses RTPS 2.1. Because jrosclient relies on rtpstalk for RTPS communication, it could not interact with ROS2 nodes running on CycloneDDS RMW. Major change in jrosclient v3, is update to new version of rtpstalk, which now supports RTPS 2.1 and consequently allows jrosclient to interact with ROS2 CycloneDDS RMW.
We recently added Android 14 support to jrosclient:
- no need for any native libraries and make split apks per each architecture (ARM, x86) or use Android NDK
- tested under FastDDS, CycloneDDS
- no need to root the phone
As of now support is only for ROS2, ROS1 is in progress
2 Likes
Added Android 14 support for ROS1 as well.
As opposed to jros2client (multicast requirement), jros1client can even run inside Android emulator.
1 Like
Added support for ROS 2 Jazzy Jalisco
Now users in the same Java application can communicate with both ROS2 distributions (Humble and Jazzy) without need to recompile anything (of course if messages format is the same, which is true in the most cases).
Additionally with new version of jrosclient users can specify QOS policies when subscribing to ROS2 topics.
4 Likes
Previously jrosservices provided only Java client to ROS services.
New version of jrosservices allows users to implement ROS2 services in Java and then run and execute any incoming requests from other ROS nodes.
Supported ROS releases Jazzy/Humble.
As for RMW, only FastDDS is supported right now (for CycloneDDS see Service interoperability with FastRTPS issue)
Example of implementing “jros_add_two_ints” ROS Service in Java:
var clientFactory = new JRos2ClientFactory();
var serviceClientFactory = new JRos2ServicesFactory();
ServiceHandler<AddTwoIntsRequestMessage, AddTwoIntsResponseMessage> proc =
request -> {
System.out.println("Received new request " + request);
var response = new AddTwoIntsResponseMessage(request.a + request.b);
System.out.println("Result " + response);
return response;
};
try (var client = clientFactory.createClient();
var service =
serviceClientFactory.createService(
client,
new AddTwoIntsServiceDefinition(),
"jros_add_two_ints",
proc)) {
service.start();
System.out.println("Press Enter to stop ROS service...");
System.in.read();
}
Next, we plan to let users implement not only ROS services but ROS actions too, and similarly run them from Java.
1 Like
With new version of jros2actionlib:5.0 users can run ROS2 Action Server in Java and execute goals requested by other ROS2 nodes:
Supported ROS releases Jazzy/Humble.
Code:
var clientFactory = new JRos2ClientFactory();
var actionlibFactory = new JRos2ActionFactory();
Function<Integer, int[]> fibo = order -> {
var seq = new int[order];
seq[0] = 1;
if (seq.length == 1) return seq;
seq[1] = 1;
if (seq.length == 2) return seq;
for (int i = 2; i < seq.length; i++) {
seq[i] = seq[i - 1] + seq[i - 2];
}
return seq;
};
ActionHandler<FibonacciGoalMessage, FibonacciResultMessage> handler =
goal -> {
System.out.println("Received new goal " + goal);
var result = new FibonacciResultMessage(fibo.apply(goal.order));
System.out.println("Result " + result);
return CompletableFuture.completedFuture(result);
};
try (var client = clientFactory.createClient();
var actionServer =
actionlibFactory.createActionServer(
client, new FibonacciActionDefinition(), "jros_fibonacci", handler)) {
actionServer.start();
System.out.println("Press Enter to stop ROS Action Server...");
System.in.read();
}
In terminal, use “ros2” command to send goals to “jros_fibonacci” Java action server:
% ros2 action send_goal /jros_fibonacci action_tutorials_interfaces/action/Fibonacci "{order: 10}"
Waiting for an action server to become available...
Sending goal:
order: 10
Goal accepted with ID: 226d976848e249ae8dfd106dfd81a1f6
Result:
sequence:
- 1
- 1
- 2
- 3
- 5
- 8
- 13
- 21
- 34
- 55
Goal finished with status: SUCCEEDED
1 Like