Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 51 additions & 11 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,54 @@ on: [push, pull_request]

jobs:
build_and_test:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
steps:
- name: Install Java
run: |
sudo apt-get update -qq
sudo apt-get install -y default-jdk gradle
- uses: actions/checkout@v2
- uses: ros-tooling/setup-ros@0.2.1
- uses: ros-tooling/setup-ros@v0.2
with:
required-ros-distributions: dashing
required-ros-distributions: galactic
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will introduce conflicts with changes in https://github.com/osrf/ros2_java/

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this conflicts don't matter much, I'm ok with them

- uses: ros-tooling/[email protected]
with:
package-name: rosidl_generator_java rcljava_common rcljava
target-ros2-distro: dashing
target-ros2-distro: galactic
vcs-repo-file-url: ${{ github.workspace }}/ros2_java_desktop.repos

build_android:
runs-on: ubuntu-18.04
runs-on: ubuntu-20.04
strategy:
fail-fast: false
matrix:
include:
- colcon_meta: |
{
"names": {
"rcl": {
"cmake-args": [ "-DBUILD_TESTING=OFF" ]
},
"rcl_yaml_param_parser": {
"cmake-args": [ "-DBUILD_TESTING=OFF" ]
},
"rclcpp": {
"cmake-args": [ "-DBUILD_TESTING=OFF" ]
},
"rclcpp_action": {
"cmake-args": [ "-DBUILD_TESTING=OFF" ]
},
"rclcpp_lifecycle": {
"cmake-args": [ "-DBUILD_TESTING=OFF" ]
},
"rcutils": {
"cmake-args": [ "-DBUILD_TESTING=OFF" ]
},
"rosidl_typesupport_c": {
"cmake-args": [ "-DBUILD_TESTING=OFF" ]
},
}
}
steps:
- name: Install Java
run: |
Expand All @@ -43,20 +73,25 @@ jobs:
sudo apt-get update && sudo apt-get install -y python3-colcon-common-extensions python3-vcstool python3-lark-parser python3-dev
- name: Install colcon extensions for Gradle
run: |
sudo pip3 install git+git://github.com/colcon/colcon-gradle.git
sudo pip3 install git+git://github.com/colcon/colcon-ros-gradle.git
sudo pip3 install git+https://github.com/colcon/colcon-gradle.git
sudo pip3 install git+https://github.com/colcon/colcon-ros-gradle.git
- name: Install Android NDK
run: |
curl -LO https://dl.google.com/android/repository/android-ndk-r21d-linux-x86_64.zip
unzip android-ndk-r21d-linux-x86_64.zip
- name: Install QEMU emulation binaries
run: |
sudo apt-get update && sudo apt-get install -y qemu-user
- name: Setup workspace with VCS repo file
run: |
mkdir -p ros2_java_ws/src
cd ros2_java_ws
curl -sL file://${{ github.workspace }}/ros2_java_android.repos | vcs import src
# Use checked out version of ros2_java
rm -rf src/ros2_java/ros2_java
ln --symbolic ${{ github.workspace }} src/ros2_java
rm -rf src/ros2-java/ros2_java
ln --symbolic ${{ github.workspace }} src/ros2-java
- name: Create colcon defaults file
run: printf "${{matrix.colcon_meta}}" > ${{ github.workspace }}/colcon.meta
- name: Build ros2_java for Android
run: |
export PYTHON3_EXEC="$( which python3 )"
Expand All @@ -69,9 +104,11 @@ jobs:

cd ros2_java_ws
colcon build \
--packages-ignore cyclonedds rcl_logging_log4cxx rosidl_generator_py \
--packages-ignore cyclonedds rcl_logging_spdlog rcl_logging_log4cxx rosidl_generator_py \
--packages-up-to rcljava \
--metas ${{ github.workspace }}/colcon.meta \
--cmake-args \
-DRCL_LOGGING_IMPLEMENTATION=rcl_logging_noop \
-DPYTHON_EXECUTABLE=${PYTHON3_EXEC} \
-DPYTHON_LIBRARY=${PYTHON3_LIBRARY} \
-DPYTHON_INCLUDE_DIR=${PYTHON3_INCLUDE_DIR} \
Expand All @@ -82,6 +119,9 @@ jobs:
-DANDROID_STL=c++_shared \
-DANDROID_ABI=${ANDROID_ABI} \
-DANDROID_NDK=${ANDROID_NDK} \
-DANDROID=ON \
-DTHIRDPARTY_android-ifaddrs=FORCE \
-DTHIRDPARTY=ON \
-DCOMPILE_EXAMPLES=OFF \
-DCMAKE_FIND_ROOT_PATH="${PWD}/install"
-DCMAKE_FIND_ROOT_PATH="${PWD}/install" \
-DCMAKE_CROSSCOMPILING_EMULATOR="/usr/bin/qemu-arm"
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

| Target | Status |
|-------------------------------------------|---------------|
| **ROS Dashing - Ubuntu Bionic (OpenJDK)** | ![Build Status](https://github.com/ros2-java/ros2_java/workflows/CI/badge.svg?branch=dashing) |
| **ROS Galactic - Ubuntu Focal (OpenJDK)** | ![Build Status](https://github.com/ros2-java/ros2_java/workflows/CI/badge.svg?branch=main) |

## Introduction

Expand Down Expand Up @@ -86,13 +86,13 @@ Make sure you have Gradle 3.2 (or later) installed.

1. Source your ROS 2 installation, for example:

source /opt/ros/dashing/setup.bash
source /opt/ros/galactic/setup.bash

1. Download the ROS 2 Java repositories into a workspace:

mkdir -p ros2_java_ws/src
cd ros2_java_ws
curl -skL https://raw.githubusercontent.com/ros2-java/ros2_java/dashing/ros2_java_desktop.repos | vcs import src
curl -skL https://raw.githubusercontent.com/ros2-java/ros2_java/main/ros2_java_desktop.repos | vcs import src

1. **Linux only** Install ROS dependencies:

Expand Down Expand Up @@ -127,7 +127,7 @@ Although the `ros2_java_android.repos` file contains all the repositories for th

mkdir -p $HOME/ros2_android_ws/src
cd $HOME/ros2_android_ws
curl https://raw.githubusercontent.com/ros2-java/ros2_java/dashing/ros2_java_android.repos | vcs import src
curl https://raw.githubusercontent.com/ros2-java/ros2_java/main/ros2_java_android.repos | vcs import src

1. Set Android build configuration:

Expand Down
19 changes: 0 additions & 19 deletions azure-pipelines.yml

This file was deleted.

4 changes: 2 additions & 2 deletions rcljava/include/org_ros2_rcljava_client_ClientImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ extern "C" {
* Method: nativeSendClientRequest
* Signature: (JJJJJLorg/ros2/rcljava/interfaces/MessageDefinition;)V
*/
JNIEXPORT void
JNIEXPORT jlong
JNICALL Java_org_ros2_rcljava_client_ClientImpl_nativeSendClientRequest(
JNIEnv *, jclass, jlong, jlong, jlong, jlong, jlong, jobject);
JNIEnv *, jclass, jlong, jlong, jlong, jlong, jobject);

/*
* Class: org_ros2_rcljava_client_ClientImpl
Expand Down
8 changes: 5 additions & 3 deletions rcljava/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<build_export_depend>builtin_interfaces</build_export_depend>
<build_export_depend>rcl_interfaces</build_export_depend>
<build_export_depend>rmw</build_export_depend>
<build_export_depend>rosidl_generator_c</build_export_depend>
<build_export_depend>rosidl_runtime_c</build_export_depend>
<build_export_depend>rosidl_generator_java</build_export_depend>
<build_export_depend>rosidl_typesupport_c</build_export_depend>

Expand All @@ -31,7 +31,7 @@
<exec_depend>rcl</exec_depend>
<exec_depend>rmw_implementation_cmake</exec_depend>
<exec_depend>rmw_implementation</exec_depend>
<exec_depend>rosidl_generator_c</exec_depend>
<exec_depend>rosidl_runtime_c</exec_depend>
<exec_depend>rosidl_parser</exec_depend>

<test_depend>ament_lint_auto</test_depend>
Expand All @@ -41,7 +41,9 @@
<test_depend>rcljava_common</test_depend>
<test_depend>rmw_implementation_cmake</test_depend>
<test_depend>rmw</test_depend>
<test_depend>rosidl_generator_c</test_depend>
<test_depend>rosidl_runtime_c</test_depend>
<!--TODO(ivanpauno): we need this for some strange reason to make test builds-->
<test_depend>rosidl_generator_cpp</test_depend>
<test_depend>rosidl_generator_java</test_depend>
<test_depend>std_msgs</test_depend>

Expand Down
2 changes: 1 addition & 1 deletion rcljava/src/main/cpp/org_ros2_rcljava_RCLJava.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "rcl/rcl.h"
#include "rcl/timer.h"
#include "rmw/rmw.h"
#include "rosidl_generator_c/message_type_support_struct.h"
#include "rosidl_runtime_c/message_type_support_struct.h"

#include "rcljava_common/exceptions.hpp"
#include "rcljava_common/signatures.hpp"
Expand Down
8 changes: 5 additions & 3 deletions rcljava/src/main/cpp/org_ros2_rcljava_client_ClientImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "rcl/node.h"
#include "rcl/rcl.h"
#include "rmw/rmw.h"
#include "rosidl_generator_c/message_type_support_struct.h"
#include "rosidl_runtime_c/message_type_support_struct.h"

#include "rcljava_common/exceptions.hpp"
#include "rcljava_common/signatures.hpp"
Expand All @@ -34,9 +34,9 @@ using rcljava_common::exceptions::rcljava_throw_rclexception;
using rcljava_common::signatures::convert_from_java_signature;
using rcljava_common::signatures::destroy_ros_message_signature;

JNIEXPORT void JNICALL
JNIEXPORT jlong JNICALL
Java_org_ros2_rcljava_client_ClientImpl_nativeSendClientRequest(
JNIEnv * env, jclass, jlong client_handle, jlong sequence_number,
JNIEnv * env, jclass, jlong client_handle,
jlong jrequest_from_java_converter_handle, jlong jrequest_to_java_converter_handle,
jlong jrequest_destructor_handle, jobject jrequest_msg)
{
Expand All @@ -53,6 +53,7 @@ Java_org_ros2_rcljava_client_ClientImpl_nativeSendClientRequest(

void * request_msg = convert_from_java(jrequest_msg, nullptr);

int64_t sequence_number;
rcl_ret_t ret = rcl_send_request(client, request_msg, &sequence_number);

destroy_ros_message_signature destroy_ros_message =
Expand All @@ -65,6 +66,7 @@ Java_org_ros2_rcljava_client_ClientImpl_nativeSendClientRequest(
rcl_reset_error();
rcljava_throw_rclexception(env, ret, msg);
}
return static_cast<jlong>(sequence_number);
}

JNIEXPORT void JNICALL
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include "rcl/rcl.h"
#include "rcl/timer.h"
#include "rmw/rmw.h"
#include "rosidl_generator_c/message_type_support_struct.h"
#include "rosidl_runtime_c/message_type_support_struct.h"

#include "rcljava_common/exceptions.hpp"
#include "rcljava_common/signatures.hpp"
Expand Down
2 changes: 1 addition & 1 deletion rcljava/src/main/cpp/org_ros2_rcljava_node_NodeImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "rcl/node.h"
#include "rcl/rcl.h"
#include "rmw/rmw.h"
#include "rosidl_generator_c/message_type_support_struct.h"
#include "rosidl_runtime_c/message_type_support_struct.h"

#include "rcljava_common/exceptions.hpp"
#include "rcljava_common/signatures.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "rcl/node.h"
#include "rcl/rcl.h"
#include "rmw/rmw.h"
#include "rosidl_generator_c/message_type_support_struct.h"
#include "rosidl_runtime_c/message_type_support_struct.h"

#include "rcljava_common/exceptions.hpp"
#include "rcljava_common/signatures.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include "rcl/node.h"
#include "rcl/rcl.h"
#include "rmw/rmw.h"
#include "rosidl_generator_c/message_type_support_struct.h"
#include "rosidl_runtime_c/message_type_support_struct.h"

#include "rcljava_common/exceptions.hpp"
#include "rcljava_common/signatures.hpp"
Expand Down
23 changes: 14 additions & 9 deletions rcljava/src/main/java/org/ros2/rcljava/client/ClientImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.time.Duration;
import java.lang.ref.WeakReference;
import java.lang.IllegalStateException;
import java.lang.InterruptedException;
import java.lang.Long;
import java.util.AbstractMap;
Expand Down Expand Up @@ -52,7 +53,6 @@ public class ClientImpl<T extends ServiceDefinition> implements Client<T> {
private final WeakReference<Node> nodeReference;
private long handle;
private final String serviceName;
private long sequenceNumber = 0;
private Map<Long, Map.Entry<Consumer, RCLFuture>> pendingRequests;

private final Class<MessageDefinition> requestType;
Expand All @@ -79,8 +79,8 @@ public void accept(Future<V> input) {}
public final <U extends MessageDefinition, V extends MessageDefinition> Future<V>
asyncSendRequest(final U request, final Consumer<Future<V>> callback) {
synchronized (pendingRequests) {
sequenceNumber++;
nativeSendClientRequest(handle, sequenceNumber, request.getFromJavaConverterInstance(),
long sequenceNumber = nativeSendClientRequest(
handle, request.getFromJavaConverterInstance(),
request.getToJavaConverterInstance(), request.getDestructorInstance(), request);
RCLFuture<V> future = new RCLFuture<V>(this.nodeReference);

Expand All @@ -96,15 +96,20 @@ public final <U extends MessageDefinition> void handleResponse(
synchronized (pendingRequests) {
long sequenceNumber = header.sequenceNumber;
Map.Entry<Consumer, RCLFuture> entry = pendingRequests.remove(sequenceNumber);
Consumer<Future> callback = entry.getKey();
RCLFuture<U> future = entry.getValue();
future.set(response);
callback.accept(future);
if (entry != null) {
Consumer<Future> callback = entry.getKey();
RCLFuture<U> future = entry.getValue();
future.set(response);
callback.accept(future);
return;
}
throw new IllegalStateException(
"No request made with the given sequence number: " + sequenceNumber);
}
}

private static native void nativeSendClientRequest(long handle, long sequenceNumber,
long requestFromJavaConverterHandle, long requestToJavaConverterHandle,
private static native long nativeSendClientRequest(
long handle, long requestFromJavaConverterHandle, long requestToJavaConverterHandle,
long requestDestructorHandle, MessageDefinition requestMessage);

public final Class<MessageDefinition> getRequestType() {
Expand Down
4 changes: 2 additions & 2 deletions rcljava_common/cmake/Modules/JavaExtra.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ function(ament_add_junit_tests TARGET_NAME)
set(${TARGET_NAME}_jar_dependencies "${JUNIT_JAR}${SEPARATOR}${HAMCREST_JAR}")

add_jar("${TARGET_NAME}_jar"
"${_source_files}"
SOURCES "${_source_files}"
OUTPUT_NAME
"${TARGET_NAME}"
INCLUDE_JARS
"${ARG_INCLUDE_JARS}"
${ARG_INCLUDE_JARS}
"${JUNIT_JAR}"
"${HAMCREST_JAR}"
)
Expand Down
Loading