Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e1c45fe
Update Android instructions
jacobperron Jul 29, 2020
5be9e3d
Update Android repos file
jacobperron Jul 29, 2020
35f2ed2
Added job for Android
esteve Jul 30, 2020
1755930
Only build the rcljava subset of dependencies
esteve Jul 30, 2020
48566ff
Fix URL
esteve Jul 30, 2020
a539df7
Replace ros-tooling scripts with plain commands
esteve Jul 30, 2020
50d5043
Fix typo
esteve Jul 30, 2020
cb064e7
Install vcstool for vcs
esteve Jul 30, 2020
32254fc
Install Android NDK
esteve Jul 30, 2020
9687f4f
Add ros2_java workspace to CMake find root path
esteve Jul 30, 2020
e0ba560
Disable building tests
esteve Jul 30, 2020
291a4b7
Do not build osrf_testing_tools_cpp as it uses execinfo.h, which is n…
esteve Jul 30, 2020
821126d
Workaround for Android
esteve Jul 30, 2020
39df81c
Reenable building tests
esteve Jul 30, 2020
6588c51
Skip cyclonedds for now
esteve Jul 30, 2020
1d8b2b9
Install lark parser
esteve Jul 30, 2020
0e36392
Install python3-dev
esteve Jul 30, 2020
dffac9b
Pass PYTHON_LIBRARY and PYTHON_INCLUDE_DIR to the CMake Python module
esteve Aug 11, 2020
a8acdc6
Skip rcl_logging_log4cxx
esteve Aug 11, 2020
5e69e65
Use rmw fork for Android. Skip CycloneDDS packages
esteve Aug 11, 2020
1bbe59e
Revert to 1.6
esteve Aug 11, 2020
1423330
Configure log4j dynamically to avoid errors when building for Android
esteve Aug 11, 2020
ad3be98
Configure log4j dynamically to avoid errors when building for Android
esteve Aug 11, 2020
b81c008
Switch to jacob/instructions temporarily
esteve Aug 11, 2020
ad7388f
Fix compilation error
esteve Aug 11, 2020
87103f3
Trim repos file for Android
esteve Aug 11, 2020
57e6037
Readd googletest repo
esteve Aug 11, 2020
f2970d7
Fix missing import
esteve Aug 11, 2020
419c23c
Build entire workspace
esteve Aug 11, 2020
6fb45b8
Only build up to the Android examples
esteve Aug 11, 2020
921c6a2
Install colcon extensions for Gradle
esteve Aug 12, 2020
6befaf1
Revert changes for desktop
esteve Aug 12, 2020
fb1b67e
Move ros2_android repo to ros2-java org
esteve Aug 12, 2020
2a06d80
Install Gradle
esteve Aug 24, 2020
9a011be
Build rcljava_examples
esteve Aug 24, 2020
a972529
Install Gradle
esteve Aug 24, 2020
4b0aeb2
Do not build rcljava_examples temporarily
esteve Aug 24, 2020
02c9551
Update README.md
esteve Sep 18, 2020
dfb5ed0
Do not use fork
esteve Sep 18, 2020
c3f852a
Use repos files from GitHub workspace
jacobperron Sep 19, 2020
0c02ab0
Add checkout action for cloning the branch to test
jacobperron Sep 19, 2020
6a7a536
Use version of ros2_java in the branch being tested
jacobperron Sep 19, 2020
0a231ea
Switch back to dashing branch
jacobperron Sep 19, 2020
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
73 changes: 70 additions & 3 deletions .github/workflows/build_and_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,80 @@ jobs:
steps:
- name: Install Java
run: |
sudo apt update -qq
sudo apt install -y default-jdk
sudo apt-get update -qq
sudo apt-get install -y default-jdk gradle
- uses: actions/checkout@v2
- uses: ros-tooling/setup-ros@0.0.14
with:
required-ros-distributions: dashing
- uses: ros-tooling/action-ros-ci@8d58122
with:
package-name: rosidl_generator_java rcljava_common rcljava
source-ros-binary-installation: dashing
vcs-repo-file-url: https://raw.githubusercontent.com/ros2-java/ros2_java/dashing/ros2_java_desktop.repos
vcs-repo-file-url: ${{ github.workspace }}/ros2_java_desktop.repos

build_android:
runs-on: ubuntu-18.04
steps:
- name: Install Java
run: |
sudo apt-get update -qq
sudo apt-get install -y default-jdk gradle
- uses: actions/checkout@v2
- name: Setup locale for ROS 2
run: |
sudo locale-gen en_US en_US.UTF-8
sudo update-locale LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8
export LANG=en_US.UTF-8
- name: Setup sources for ROS 2
run: |
sudo apt-get update && sudo apt-get install -y curl gnupg2 lsb-release
curl -sL https://raw.githubusercontent.com/ros/rosdistro/master/ros.asc | sudo apt-key add -
sudo sh -c 'echo "deb [arch=$(dpkg --print-architecture)] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" > /etc/apt/sources.list.d/ros2-latest.list'
- name: Install ROS 2 dependencies
run: |
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
- 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: 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
- name: Build ros2_java for Android
run: |
export PYTHON3_EXEC="$( which python3 )"
export PYTHON3_LIBRARY="$( ${PYTHON3_EXEC} -c 'import os.path; from distutils import sysconfig; print(os.path.realpath(os.path.join(sysconfig.get_config_var("LIBPL"), sysconfig.get_config_var("LDLIBRARY"))))' )"
export PYTHON3_INCLUDE_DIR="$( ${PYTHON3_EXEC} -c 'from distutils import sysconfig; print(sysconfig.get_config_var("INCLUDEPY"))' )"
export ANDROID_ABI=armeabi-v7a
export ANDROID_NATIVE_API_LEVEL=android-21
export ANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-clang
export ANDROID_NDK=${PWD}/android-ndk-r21d

cd ros2_java_ws
colcon build \
--packages-ignore cyclonedds rcl_logging_log4cxx rosidl_generator_py \
--packages-up-to rcljava \
--cmake-args \
-DPYTHON_EXECUTABLE=${PYTHON3_EXEC} \
-DPYTHON_LIBRARY=${PYTHON3_LIBRARY} \
-DPYTHON_INCLUDE_DIR=${PYTHON3_INCLUDE_DIR} \
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
-DANDROID_FUNCTION_LEVEL_LINKING=OFF \
-DANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL} \
-DANDROID_TOOLCHAIN_NAME=${ANDROID_TOOLCHAIN_NAME} \
-DANDROID_STL=c++_shared \
-DANDROID_ABI=${ANDROID_ABI} \
-DANDROID_NDK=${ANDROID_NDK} \
-DTHIRDPARTY=ON \
-DCOMPILE_EXAMPLES=OFF \
-DCMAKE_FIND_ROOT_PATH="${PWD}/install"
83 changes: 38 additions & 45 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,6 @@ Make sure you have Gradle 3.2 (or later) installed.

### Download and Build ROS 2 Java for Android

> TODO: This section needs updated instructions for ROS 2 Dashing and newer

The Android setup is slightly more complex, you'll need the SDK and NDK installed, and an Android device where you can run the examples.

Make sure to download at least the SDK for Android Lollipop (or greater), the examples require the API level 21 at least and NDK 14.
Expand All @@ -121,48 +119,43 @@ We'll also need to have the [Android SDK](https://developer.android.com/studio/#

Although the `ros2_java_android.repos` file contains all the repositories for the Android bindings to compile, we'll have to disable certain packages (`python_cmake_module`, `rosidl_generator_py`, `test_msgs`) that are included the repositories and that we either don't need or can't cross-compile properly (e.g. the Python generator)

```
# define paths
ROOT_DIR = ${HOME}
AMENT_WORKSPACE=${ROOT_DIR}/ament_ws
ROS2_ANDROID_WORKSPACE=${ROOT_DIR}/ros2_android_ws

# pull and build ament
mkdir -p ${AMENT_WORKSPACE}/src
cd ${AMENT_WORKSPACE}
curl https://raw.githubusercontent.com/ros2-java/ament_java/master/ament_java.repos
vcs import ${AMENT_WORKSPACE}/src < ament_java.repos
src/ament/ament_tools/scripts/ament.py build --symlink-install --isolated

# android build configuration
export PYTHON3_EXEC="$( which python3 )"
export ANDROID_ABI=armeabi-v7a
export ANDROID_NATIVE_API_LEVEL=android-21
export ANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-clang

# pull and build ros2 for android
mkdir -p ${ROS2_ANDROID_WORKSPACE}/src
cd ${ROS2_ANDROID_WORKSPACE}
curl https://raw.githubusercontent.com/ros2-java/ros2_java/dashing/ros2_java_android.repos
vcs import ${ROS2_ANDROID_WORKSPACE}/src < ros2_java_android.repos
source ${AMENT_WORKSPACE}/install_isolated/local_setup.sh
ament build --isolated --skip-packages test_msgs \
--cmake-args \
-DPYTHON_EXECUTABLE=${PYTHON3_EXEC} \
-DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
-DANDROID_FUNCTION_LEVEL_LINKING=OFF \
-DANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL} \
-DANDROID_TOOLCHAIN_NAME=${ANDROID_TOOLCHAIN_NAME} \
-DANDROID_STL=gnustl_shared \
-DANDROID_ABI=${ANDROID_ABI} \
-DANDROID_NDK=${ANDROID_NDK} \
-DTHIRDPARTY=ON \
-DCOMPILE_EXAMPLES=OFF \
-DCMAKE_FIND_ROOT_PATH="$AMENT_WORKSPACE/install_isolated;$ROS2_ANDROID_WORKSPACE/install_isolated" \
-- \
--parallel \
--ament-gradle-args \
-Pament.android_stl=gnustl_shared -Pament.android_abi=$ANDROID_ABI -Pament.android_ndk=$ANDROID_NDK --
```
1. Download the [Android NDK](https://developer.android.com/ndk/downloads/index.html) and set the environment variable `ANDROID_NDK` to the path where it is extracted.

1. Download the [Android SDK](https://developer.android.com/studio/#downloads) and set the environment variable `ANDROID_HOME` to the path where it is extracted.

1. Clone ROS 2 and ROS 2 Java source code:

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

1. Set Android build configuration:

export PYTHON3_EXEC="$( which python3 )"
export PYTHON3_LIBRARY="$( ${PYTHON3_EXEC} -c 'import os.path; from distutils import sysconfig; print(os.path.realpath(os.path.join(sysconfig.get_config_var("LIBPL"), sysconfig.get_config_var("LDLIBRARY"))))' )"
export PYTHON3_INCLUDE_DIR="$( ${PYTHON3_EXEC} -c 'from distutils import sysconfig; print(sysconfig.get_config_var("INCLUDEPY"))' )"
export ANDROID_ABI=armeabi-v7a
export ANDROID_NATIVE_API_LEVEL=android-21
export ANDROID_TOOLCHAIN_NAME=arm-linux-androideabi-clang

1. Build (skipping packages that we don't need or can't cross-compile):

colcon build \
--packages-ignore cyclonedds rcl_logging_log4cxx rosidl_generator_py \
--packages-up-to rcljava \
--cmake-args \
-DPYTHON_EXECUTABLE=${PYTHON3_EXEC} \
-DPYTHON_LIBRARY=${PYTHON3_LIBRARY} \
-DPYTHON_INCLUDE_DIR=${PYTHON3_INCLUDE_DIR} \
-DCMAKE_TOOLCHAIN_FILE=${ANDROID_NDK}/build/cmake/android.toolchain.cmake \
-DANDROID_FUNCTION_LEVEL_LINKING=OFF \
-DANDROID_NATIVE_API_LEVEL=${ANDROID_NATIVE_API_LEVEL} \
-DANDROID_TOOLCHAIN_NAME=${ANDROID_TOOLCHAIN_NAME} \
-DANDROID_STL=c++_shared \
-DANDROID_ABI=${ANDROID_ABI} \
-DANDROID_NDK=${ANDROID_NDK} \
-DTHIRDPARTY=ON \
-DCOMPILE_EXAMPLES=OFF \
-DCMAKE_FIND_ROOT_PATH="${PWD}/install"

You can find more information about the Android examples at https://github.com/ros2-java/ros2_android_examples
2 changes: 0 additions & 2 deletions rcljava/src/main/java/org/ros2/rcljava/node/NodeImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@

import java.lang.ref.WeakReference;

import java.lang.reflect.Method;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
Expand Down
14 changes: 13 additions & 1 deletion rcljava/src/test/java/org/ros2/rcljava/client/ClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.junit.Test;

import java.lang.ref.WeakReference;
import java.lang.reflect.Method;
import java.time.Duration;

import java.util.Arrays;
Expand All @@ -46,7 +47,18 @@ public class ClientTest {
@BeforeClass
public static void setupOnce() throws Exception {
RCLJava.rclJavaInit();
org.apache.log4j.BasicConfigurator.configure();
try
{
// Configure log4j. Doing this dynamically so that Android does not complain about missing
// the log4j JARs, SLF4J uses Android's native logging mechanism instead.
Class c = Class.forName("org.apache.log4j.BasicConfigurator");
Method m = c.getDeclaredMethod("configure", (Class<?>[]) null);
Object o = m.invoke(null, (Object[]) null);
}
catch (Exception e)
{
e.printStackTrace();
}
}

public class TestClientConsumer implements TriConsumer<RMWRequestId,
Expand Down
14 changes: 13 additions & 1 deletion rcljava/src/test/java/org/ros2/rcljava/node/NodeTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.junit.Test;

import java.lang.ref.WeakReference;
import java.lang.reflect.Method;

import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -86,7 +87,18 @@ boolean checkPrimitives(rcljava.msg.Primitives primitives, boolean booleanValue,
@BeforeClass
public static void setupOnce() throws Exception {
RCLJava.rclJavaInit();
org.apache.log4j.BasicConfigurator.configure();
try
{
// Configure log4j. Doing this dynamically so that Android does not complain about missing
// the log4j JARs, SLF4J uses Android's native logging mechanism instead.
Class c = Class.forName("org.apache.log4j.BasicConfigurator");
Method m = c.getDeclaredMethod("configure", (Class<?>[]) null);
Object o = m.invoke(null, (Object[]) null);
}
catch (Exception e)
{
e.printStackTrace();
}
}

public class TestConsumer<T> implements Consumer<T> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.junit.Test;

import java.lang.ref.WeakReference;
import java.lang.reflect.Method;

import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -69,7 +70,18 @@ public TestConsumer(RCLFuture<T> resultFuture) {
@BeforeClass
public static void setupOnce() throws Exception {
RCLJava.rclJavaInit();
org.apache.log4j.BasicConfigurator.configure();
try
{
// Configure log4j. Doing this dynamically so that Android does not complain about missing
// the log4j JARs, SLF4J uses Android's native logging mechanism instead.
Class c = Class.forName("org.apache.log4j.BasicConfigurator");
Method m = c.getDeclaredMethod("configure", (Class<?>[]) null);
Object o = m.invoke(null, (Object[]) null);
}
catch (Exception e)
{
e.printStackTrace();
}
}

@Before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import org.junit.Test;

import java.lang.ref.WeakReference;
import java.lang.reflect.Method;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -52,7 +53,18 @@ public class SyncParametersClientTest {
@BeforeClass
public static void setupOnce() throws Exception {
RCLJava.rclJavaInit();
org.apache.log4j.BasicConfigurator.configure();
try
{
// Configure log4j. Doing this dynamically so that Android does not complain about missing
// the log4j JARs, SLF4J uses Android's native logging mechanism instead.
Class c = Class.forName("org.apache.log4j.BasicConfigurator");
Method m = c.getDeclaredMethod("configure", (Class<?>[]) null);
Object o = m.invoke(null, (Object[]) null);
}
catch (Exception e)
{
e.printStackTrace();
}
}

@Before
Expand Down
Loading