diff --git a/do_everything.sh b/do_everything.sh index cee5076..2b0b746 100755 --- a/do_everything.sh +++ b/do_everything.sh @@ -297,6 +297,9 @@ if [[ $skip -ne 1 ]] ; then # Patch urdf - Fixed linking with pluginlib and dependencies in downstream packages apply_patch $my_loc/patches/urdf.patch + # Patch move_base - Solved transitive linking problems + apply_patch $my_loc/patches/move_base.patch + # Patch global_planner - Add angles dependency # TODO: PR merged: https://github.com/ros-planning/navigation/pull/359 # Wait for next release to remove (current 1.12.4) diff --git a/example_workspace/src/image_transport_sample_app/AndroidManifest.xml.in b/example_workspace/src/image_transport_sample_app/AndroidManifest.xml.in deleted file mode 100644 index e14d813..0000000 --- a/example_workspace/src/image_transport_sample_app/AndroidManifest.xml.in +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/example_workspace/src/image_transport_sample_app/CMakeLists.txt b/example_workspace/src/image_transport_sample_app/CMakeLists.txt new file mode 100644 index 0000000..eb5eb5f --- /dev/null +++ b/example_workspace/src/image_transport_sample_app/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 2.8.3) +project(image_transport_sample) + +find_package(catkin REQUIRED rosjava_build_tools) + +catkin_android_setup(assemble${CMAKE_BUILD_TYPE}) + +catkin_package() \ No newline at end of file diff --git a/example_workspace/src/image_transport_sample_app/build.gradle b/example_workspace/src/image_transport_sample_app/build.gradle new file mode 100644 index 0000000..4e99eeb --- /dev/null +++ b/example_workspace/src/image_transport_sample_app/build.gradle @@ -0,0 +1,21 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + repositories { + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.2.1' + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/example_workspace/src/image_transport_sample_app/custom_rules.xml.in b/example_workspace/src/image_transport_sample_app/custom_rules.xml.in deleted file mode 100644 index 189a837..0000000 --- a/example_workspace/src/image_transport_sample_app/custom_rules.xml.in +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/example_workspace/src/image_transport_sample_app/gradle.properties b/example_workspace/src/image_transport_sample_app/gradle.properties new file mode 100644 index 0000000..89196d1 --- /dev/null +++ b/example_workspace/src/image_transport_sample_app/gradle.properties @@ -0,0 +1,18 @@ +# Project-wide Gradle settings. + +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. + +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html + +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m + +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true + diff --git a/example_workspace/src/image_transport_sample_app/gradle/wrapper/gradle-wrapper.jar b/example_workspace/src/image_transport_sample_app/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..8c0fb64 Binary files /dev/null and b/example_workspace/src/image_transport_sample_app/gradle/wrapper/gradle-wrapper.jar differ diff --git a/example_workspace/src/image_transport_sample_app/gradle/wrapper/gradle-wrapper.properties b/example_workspace/src/image_transport_sample_app/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..d604c72 --- /dev/null +++ b/example_workspace/src/image_transport_sample_app/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sun Feb 05 19:39:12 IST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip diff --git a/example_workspace/src/image_transport_sample_app/gradlew b/example_workspace/src/image_transport_sample_app/gradlew new file mode 100755 index 0000000..91a7e26 --- /dev/null +++ b/example_workspace/src/image_transport_sample_app/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/example_workspace/src/image_transport_sample_app/gradlew.bat b/example_workspace/src/image_transport_sample_app/gradlew.bat new file mode 100644 index 0000000..aec9973 --- /dev/null +++ b/example_workspace/src/image_transport_sample_app/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/example_workspace/src/image_transport_sample_app/ic_launcher.png b/example_workspace/src/image_transport_sample_app/ic_launcher.png deleted file mode 100644 index c7956d1..0000000 Binary files a/example_workspace/src/image_transport_sample_app/ic_launcher.png and /dev/null differ diff --git a/example_workspace/src/image_transport_sample_app/jni/Android.mk.in b/example_workspace/src/image_transport_sample_app/jni/Android.mk.in deleted file mode 100644 index 9ea1ae8..0000000 --- a/example_workspace/src/image_transport_sample_app/jni/Android.mk.in +++ /dev/null @@ -1,13 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := image_transport_sample_app -#LOCAL_C_INCLUDES := include/ -LOCAL_SRC_FILES := src/image_transport_plugin_test.cpp -LOCAL_WHOLE_STATIC_LIBRARIES := libimage_transport_plugins libcompressed_image_transport -LOCAL_STATIC_LIBRARIES := roscpp_android_ndk android_native_app_glue gnustl_static -LOCAL_LDLIBS := -landroid -llog -lz -#LOCAL_CPPFLAGS += -frtti -fexceptions -include $(BUILD_SHARED_LIBRARY) -$(call import-module, android/native_app_glue) -$(call import-module, roscpp_android_ndk) diff --git a/example_workspace/src/image_transport_sample_app/jni/Application.mk b/example_workspace/src/image_transport_sample_app/jni/Application.mk deleted file mode 100644 index f105759..0000000 --- a/example_workspace/src/image_transport_sample_app/jni/Application.mk +++ /dev/null @@ -1,5 +0,0 @@ -APP_STL := gnustl_static -APP_PLATFORM := android-15 -APP_ABI := armeabi-v7a -APP_OPTIM := debug -APP_CPPFLAGS := -frtti -fexceptions diff --git a/example_workspace/src/image_transport_sample_app/jni/CMakeLists.txt b/example_workspace/src/image_transport_sample_app/jni/CMakeLists.txt new file mode 100644 index 0000000..46521ee --- /dev/null +++ b/example_workspace/src/image_transport_sample_app/jni/CMakeLists.txt @@ -0,0 +1,64 @@ +# +# Copyright (C) The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +cmake_minimum_required(VERSION 3.4.1) +project(image_transport_sample) + +find_package(catkin REQUIRED COMPONENTS roscpp std_msgs rosconsole image_transport compressed_image_transport theora_image_transport) + +include_directories(${catkin_INCLUDE_DIRS}) + +# build native_app_glue as a static lib +add_library(native_app_glue STATIC + ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +# now build app's shared lib +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -Wall -Werror") + +# Export ANativeActivity_onCreate(), +# Refer to: https://github.com/android-ndk/ndk/issues/381. +set(CMAKE_SHARED_LINKER_FLAGS + "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +add_library(${PROJECT_NAME} SHARED + src/main/cpp/image_transport_plugin_test.cpp +) + +target_include_directories(${PROJECT_NAME} PRIVATE + ${ANDROID_NDK}/sources/android/native_app_glue) + +# This is to be sure that the symbols of this libraries aren't dropped +# Also, put them in catkin find_package, in order to solve transitive dependencies without problems. +find_library(image_transport_plugins_PLUGIN NAMES image_transport_plugins) +find_library(theora_image_transport_PLUGIN NAMES theora_image_transport) +find_library(compressed_image_transport_PLUGIN NAMES compressed_image_transport) + +SET (WHOLE_ARCHIVE_LIBRARIES + -Wl,--whole-archive + ${image_transport_plugins_PLUGIN} + ${theora_image_transport_PLUGIN} + ${compressed_image_transport_PLUGIN} + -Wl,--no-whole-archive +) + +# add lib dependencies +target_link_libraries(${PROJECT_NAME} + android + native_app_glue + log + ${WHOLE_ARCHIVE_LIBRARIES} + ${catkin_LIBRARIES} +) diff --git a/example_workspace/src/image_transport_sample_app/jni/build.gradle b/example_workspace/src/image_transport_sample_app/jni/build.gradle new file mode 100644 index 0000000..734d303 --- /dev/null +++ b/example_workspace/src/image_transport_sample_app/jni/build.gradle @@ -0,0 +1,41 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 28 + + defaultConfig { + applicationId = 'com.example.image_transport_sample' + minSdkVersion 24 + targetSdkVersion 26 + externalNativeBuild { + cmake { + arguments '-DANDROID_STL=c++_shared', + '-DCMAKE_FIND_ROOT_PATH=' + System.getenv('TARGET_DIR'), + '-DCMAKE_PREFIX_PATH=' + System.getenv('TARGET_DIR'), + '-DBUILD_TESTING=OFF', + '-DCATKIN_ENABLE_TESTING=OFF' + } + } + ndk { + // Specifies the ABI configurations of your native + // libraries Gradle should build and package with your APK. + abiFilters System.getenv('ANDROID_ABI') ?: 'arm64-v8a' + } + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), + 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path 'CMakeLists.txt' + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) +} diff --git a/example_workspace/src/image_transport_sample_app/jni/src/main/AndroidManifest.xml b/example_workspace/src/image_transport_sample_app/jni/src/main/AndroidManifest.xml new file mode 100644 index 0000000..ef2ec12 --- /dev/null +++ b/example_workspace/src/image_transport_sample_app/jni/src/main/AndroidManifest.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example_workspace/src/image_transport_sample_app/jni/src/image_transport_plugin_test.cpp b/example_workspace/src/image_transport_sample_app/jni/src/main/cpp/image_transport_plugin_test.cpp similarity index 87% rename from example_workspace/src/image_transport_sample_app/jni/src/image_transport_plugin_test.cpp rename to example_workspace/src/image_transport_sample_app/jni/src/main/cpp/image_transport_plugin_test.cpp index 2ce3e87..2790c50 100644 --- a/example_workspace/src/image_transport_sample_app/jni/src/image_transport_plugin_test.cpp +++ b/example_workspace/src/image_transport_sample_app/jni/src/main/cpp/image_transport_plugin_test.cpp @@ -50,14 +50,7 @@ #define LOGI(...) __android_log_print(ANDROID_LOG_INFO, LOG_TAG, __VA_ARGS__) #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__) -int main(); - -void android_main(struct android_app* state) { - app_dummy(); // needed so the Android glue does not get stripped off - main(); -} - -int main() +void android_main(struct android_app* state) { LOGD("Starting app."); @@ -91,5 +84,24 @@ int main() LOGD("Failed to create compressed image transport publisher. Error: %s", ex.what()); } - return 0; + while(1) { + int events; + struct android_poll_source* source; + + // Poll android events locking + while (ALooper_pollAll(-1, NULL, &events, (void**)&source) >= 0) { + // Process this event + if (source != NULL) { + source->process(state, source); + } + + // Check if we are exiting. + if (state->destroyRequested != 0) { + LOGD("APP DESTROYED BYE BYE"); + return; + } + } + } + + return; } diff --git a/example_workspace/src/image_transport_sample_app/jni/src/main/res/mipmap-hdpi/ic_launcher.png b/example_workspace/src/image_transport_sample_app/jni/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..cde69bc Binary files /dev/null and b/example_workspace/src/image_transport_sample_app/jni/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/example_workspace/src/image_transport_sample_app/jni/src/main/res/mipmap-mdpi/ic_launcher.png b/example_workspace/src/image_transport_sample_app/jni/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c133a0c Binary files /dev/null and b/example_workspace/src/image_transport_sample_app/jni/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/example_workspace/src/image_transport_sample_app/jni/src/main/res/mipmap-xhdpi/ic_launcher.png b/example_workspace/src/image_transport_sample_app/jni/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..bfa42f0 Binary files /dev/null and b/example_workspace/src/image_transport_sample_app/jni/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/example_workspace/src/image_transport_sample_app/jni/src/main/res/mipmap-xxhdpi/ic_launcher.png b/example_workspace/src/image_transport_sample_app/jni/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..324e72c Binary files /dev/null and b/example_workspace/src/image_transport_sample_app/jni/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/example_workspace/src/image_transport_sample_app/jni/src/main/res/values/strings.xml b/example_workspace/src/image_transport_sample_app/jni/src/main/res/values/strings.xml new file mode 100644 index 0000000..e84ed4a --- /dev/null +++ b/example_workspace/src/image_transport_sample_app/jni/src/main/res/values/strings.xml @@ -0,0 +1,4 @@ + + + ImageTransport + diff --git a/example_workspace/src/image_transport_sample_app/package.xml b/example_workspace/src/image_transport_sample_app/package.xml new file mode 100644 index 0000000..d082b26 --- /dev/null +++ b/example_workspace/src/image_transport_sample_app/package.xml @@ -0,0 +1,21 @@ + + + image_transport_sample + 0.0.1 + Image transport example app with ros on android + + Ivan Paunovic + + Apache 2.0 License + + catkin + roscpp + std_msgs + rosconsole + pluginlib + image_transport + compressed_image_transport + theora_image_transport + compressed_depth_image_transport + + diff --git a/example_workspace/src/image_transport_sample_app/settings.gradle b/example_workspace/src/image_transport_sample_app/settings.gradle new file mode 100644 index 0000000..f62608c --- /dev/null +++ b/example_workspace/src/image_transport_sample_app/settings.gradle @@ -0,0 +1,2 @@ +include ':jni' + diff --git a/example_workspace/src/move_base_app/AndroidManifest.xml.in b/example_workspace/src/move_base_app/AndroidManifest.xml.in deleted file mode 100644 index 197b735..0000000 --- a/example_workspace/src/move_base_app/AndroidManifest.xml.in +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/example_workspace/src/move_base_app/CMakeLists.txt b/example_workspace/src/move_base_app/CMakeLists.txt new file mode 100644 index 0000000..691ac2f --- /dev/null +++ b/example_workspace/src/move_base_app/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 2.8.3) +project(move_base_app) + +find_package(catkin REQUIRED rosjava_build_tools) + +catkin_android_setup(assemble${CMAKE_BUILD_TYPE}) + +catkin_package() \ No newline at end of file diff --git a/example_workspace/src/move_base_app/build.gradle b/example_workspace/src/move_base_app/build.gradle new file mode 100644 index 0000000..4e99eeb --- /dev/null +++ b/example_workspace/src/move_base_app/build.gradle @@ -0,0 +1,21 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + repositories { + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.2.1' + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/example_workspace/src/move_base_app/custom_rules.xml.in b/example_workspace/src/move_base_app/custom_rules.xml.in deleted file mode 100644 index 189a837..0000000 --- a/example_workspace/src/move_base_app/custom_rules.xml.in +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/example_workspace/src/move_base_app/gradle/wrapper/gradle-wrapper.jar b/example_workspace/src/move_base_app/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..8c0fb64 Binary files /dev/null and b/example_workspace/src/move_base_app/gradle/wrapper/gradle-wrapper.jar differ diff --git a/example_workspace/src/move_base_app/gradle/wrapper/gradle-wrapper.properties b/example_workspace/src/move_base_app/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..d604c72 --- /dev/null +++ b/example_workspace/src/move_base_app/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sun Feb 05 19:39:12 IST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip diff --git a/example_workspace/src/move_base_app/gradlew b/example_workspace/src/move_base_app/gradlew new file mode 100755 index 0000000..91a7e26 --- /dev/null +++ b/example_workspace/src/move_base_app/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/example_workspace/src/move_base_app/gradlew.bat b/example_workspace/src/move_base_app/gradlew.bat new file mode 100644 index 0000000..aec9973 --- /dev/null +++ b/example_workspace/src/move_base_app/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/example_workspace/src/move_base_app/ic_launcher.png b/example_workspace/src/move_base_app/ic_launcher.png deleted file mode 100644 index c7956d1..0000000 Binary files a/example_workspace/src/move_base_app/ic_launcher.png and /dev/null differ diff --git a/example_workspace/src/move_base_app/jni/Android.mk.in b/example_workspace/src/move_base_app/jni/Android.mk.in deleted file mode 100644 index 30ac85c..0000000 --- a/example_workspace/src/move_base_app/jni/Android.mk.in +++ /dev/null @@ -1,15 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) - -LOCAL_MODULE := move_base_app -LOCAL_SRC_FILES := src/test_move_base.cpp -LOCAL_C_INCLUDES := $(LOCAL_PATH)/include -LOCAL_LDLIBS := -landroid -LOCAL_STATIC_LIBRARIES := android_native_app_glue roscpp_android_ndk -LOCAL_WHOLE_STATIC_LIBRARIES := liblayers libdwa_local_planner libclear_costmap_recovery librotate_recovery libglobal_planner libnavfn libtrajectory_planner_ros libcarrot_planner libmove_slow_and_clear - -include $(BUILD_SHARED_LIBRARY) - -$(call import-module,android/native_app_glue) -$(call import-module,roscpp_android_ndk) diff --git a/example_workspace/src/move_base_app/jni/Application.mk b/example_workspace/src/move_base_app/jni/Application.mk deleted file mode 100644 index 2a5d55c..0000000 --- a/example_workspace/src/move_base_app/jni/Application.mk +++ /dev/null @@ -1,4 +0,0 @@ -#NDK_TOOLCHAIN_VERSION=4.4.3 -APP_STL := gnustl_static -APP_PLATFORM := android-14 -APP_ABI := armeabi-v7a \ No newline at end of file diff --git a/example_workspace/src/move_base_app/jni/CMakeLists.txt b/example_workspace/src/move_base_app/jni/CMakeLists.txt new file mode 100644 index 0000000..4006c0d --- /dev/null +++ b/example_workspace/src/move_base_app/jni/CMakeLists.txt @@ -0,0 +1,75 @@ +# +# Copyright (C) The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +cmake_minimum_required(VERSION 3.4.1) +project(move_base_app) + +find_package(catkin REQUIRED COMPONENTS roscpp move_base) + +include_directories(${catkin_INCLUDE_DIRS}) + +# build native_app_glue as a static lib +add_library(native_app_glue STATIC + ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +# now build app's shared lib +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -Wall") + +# Export ANativeActivity_onCreate(), +# Refer to: https://github.com/android-ndk/ndk/issues/381. +set(CMAKE_SHARED_LINKER_FLAGS + "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +add_library(${PROJECT_NAME} SHARED + src/main/cpp/test_move_base.cpp +) + +target_include_directories(${PROJECT_NAME} PRIVATE + ${ANDROID_NDK}/sources/android/native_app_glue) + +# This is to be sure that the symbols of this libraries aren't dropped +# Also, put them in catkin find_package, in order to solve transitive dependencies without problems. +find_library(layers_PLUGIN NAMES layers) +find_library(dwa_local_planner_PLUGIN NAMES dwa_local_planner) +find_library(clear_costmap_recovery_PLUGIN NAMES clear_costmap_recovery) +find_library(rotate_recovery_PLUGIN NAMES rotate_recovery) +find_library(global_planner_PLUGIN NAMES global_planner) +find_library(navfn_PLUGIN NAMES navfn) +find_library(trajectory_planner_ros_PLUGIN NAMES trajectory_planner_ros) +find_library(carrot_planner_PLUGIN NAMES carrot_planner) +find_library(move_slow_and_clear_PLUGIN NAMES move_slow_and_clear) + +SET (WHOLE_ARCHIVE_LIBRARIES + -Wl,--whole-archive + ${layers_PLUGIN} + ${dwa_local_planner_PLUGIN} + ${clear_costmap_recovery_PLUGIN} + ${rotate_recovery_PLUGIN} + ${navfn_PLUGIN} + ${trajectory_planner_ros_PLUGIN} + ${carrot_planner_PLUGIN} + ${move_slow_and_clear_PLUGIN} + -Wl,--no-whole-archive +) + +# add lib dependencies +target_link_libraries(${PROJECT_NAME} + android + native_app_glue + log + ${WHOLE_ARCHIVE_LIBRARIES} + ${catkin_LIBRARIES} +) diff --git a/example_workspace/src/move_base_app/jni/build.gradle b/example_workspace/src/move_base_app/jni/build.gradle new file mode 100644 index 0000000..9c18ec3 --- /dev/null +++ b/example_workspace/src/move_base_app/jni/build.gradle @@ -0,0 +1,41 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 28 + + defaultConfig { + applicationId = 'com.example.move_base_app' + minSdkVersion 24 + targetSdkVersion 26 + externalNativeBuild { + cmake { + arguments '-DANDROID_STL=c++_shared', + '-DCMAKE_FIND_ROOT_PATH=' + System.getenv('TARGET_DIR'), + '-DCMAKE_PREFIX_PATH=' + System.getenv('TARGET_DIR'), + '-DBUILD_TESTING=OFF', + '-DCATKIN_ENABLE_TESTING=OFF' + } + } + ndk { + // Specifies the ABI configurations of your native + // libraries Gradle should build and package with your APK. + abiFilters System.getenv('ANDROID_ABI') ?: 'arm64-v8a' + } + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), + 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path 'CMakeLists.txt' + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) +} diff --git a/example_workspace/src/move_base_app/jni/src/main/AndroidManifest.xml b/example_workspace/src/move_base_app/jni/src/main/AndroidManifest.xml new file mode 100644 index 0000000..c8556f7 --- /dev/null +++ b/example_workspace/src/move_base_app/jni/src/main/AndroidManifest.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example_workspace/src/move_base_app/jni/src/main/cpp/test_move_base.cpp b/example_workspace/src/move_base_app/jni/src/main/cpp/test_move_base.cpp new file mode 100644 index 0000000..2e45bbd --- /dev/null +++ b/example_workspace/src/move_base_app/jni/src/main/cpp/test_move_base.cpp @@ -0,0 +1,65 @@ +#include "ros/ros.h" +#include + +#include +#include + +void log(const char *msg, ...) { + va_list args; + va_start(args, msg); + __android_log_vprint(ANDROID_LOG_INFO, "MOVE_BASE_NDK_EXAMPLE", msg, args); + va_end(args); +} + +void android_main(android_app *state) { + int argc = 4; + // TODO: don't hardcode ip addresses + const char *argv[] = {"nothing_important" , "__master:=http://10.34.0.120:11311", + "__ip:=10.34.0.121", "cmd_vel:=navigation_velocity_smoother/raw_cmd_vel"}; + + for(int i = 0; i < argc; i++){ + log(argv[i]); + } + + ros::init(argc, const_cast(&argv[0]), "move_base"); + + std::string master_uri = ros::master::getURI(); + + if(ros::master::check()){ + log("ROS MASTER IS UP!"); + } else { + log("NO ROS MASTER."); + ANativeActivity_finish(state->activity); + } + log(master_uri.c_str()); + + ros::NodeHandle n; + + tf::TransformListener tf(ros::Duration(10)); + move_base::MoveBase move_base(tf); + + ros::AsyncSpinner spinner(4); + spinner.start(); + + while(1) { + int events; + struct android_poll_source* source; + + // Poll android events. Check whatever ros died every five seconds. + while (ALooper_pollAll(5000, NULL, &events, (void**)&source) >= 0) { + // Process this event + if (source != NULL) { + source->process(state, source); + } + + // Check if we are exiting. + if (state->destroyRequested != 0) { + log("APP DESTROYED BYE BYE"); + return; + } + } + if (!ros::ok() || !ros::master::check()) { + ANativeActivity_finish(state->activity); + } + } +} diff --git a/example_workspace/src/move_base_app/jni/src/main/res/mipmap-hdpi/ic_launcher.png b/example_workspace/src/move_base_app/jni/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..cde69bc Binary files /dev/null and b/example_workspace/src/move_base_app/jni/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/example_workspace/src/move_base_app/jni/src/main/res/mipmap-mdpi/ic_launcher.png b/example_workspace/src/move_base_app/jni/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c133a0c Binary files /dev/null and b/example_workspace/src/move_base_app/jni/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/example_workspace/src/move_base_app/jni/src/main/res/mipmap-xhdpi/ic_launcher.png b/example_workspace/src/move_base_app/jni/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..bfa42f0 Binary files /dev/null and b/example_workspace/src/move_base_app/jni/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/example_workspace/src/move_base_app/jni/src/main/res/mipmap-xxhdpi/ic_launcher.png b/example_workspace/src/move_base_app/jni/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..324e72c Binary files /dev/null and b/example_workspace/src/move_base_app/jni/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/example_workspace/src/move_base_app/jni/src/main/res/values/strings.xml b/example_workspace/src/move_base_app/jni/src/main/res/values/strings.xml new file mode 100644 index 0000000..3726d0b --- /dev/null +++ b/example_workspace/src/move_base_app/jni/src/main/res/values/strings.xml @@ -0,0 +1,4 @@ + + + MoveBase + diff --git a/example_workspace/src/move_base_app/jni/src/test_move_base.cpp b/example_workspace/src/move_base_app/jni/src/test_move_base.cpp deleted file mode 100644 index 4ff67ac..0000000 --- a/example_workspace/src/move_base_app/jni/src/test_move_base.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#include "ros/ros.h" -#include - -#include -#include - -void log(const char *msg, ...) { - va_list args; - va_start(args, msg); - __android_log_vprint(ANDROID_LOG_INFO, "MOVE_BASE_NDK_EXAMPLE", msg, args); - va_end(args); -} - -void android_main(android_app *papp) { - // Make sure glue isn't stripped - app_dummy(); - - int argc = 4; - // TODO: don't hardcode ip addresses - char *argv[] = {"nothing_important" , "__master:=http://192.168.1.100:11311", - "__ip:=192.168.1.101", "cmd_vel:=navigation_velocity_smoother/raw_cmd_vel"}; - - for(int i = 0; i < argc; i++){ - log(argv[i]); - } - - ros::init(argc, &argv[0], "move_base"); - - std::string master_uri = ros::master::getURI(); - - if(ros::master::check()){ - log("ROS MASTER IS UP!"); - } else { - log("NO ROS MASTER."); - } - log(master_uri.c_str()); - - ros::NodeHandle n; - - tf::TransformListener tf(ros::Duration(10)); - move_base::MoveBase move_base(tf); - - ros::WallRate loop_rate(100); - while(ros::ok() && !papp->destroyRequested){ - ros::spinOnce(); - loop_rate.sleep(); - } -} diff --git a/example_workspace/src/move_base_app/package.xml b/example_workspace/src/move_base_app/package.xml new file mode 100644 index 0000000..b4dbd37 --- /dev/null +++ b/example_workspace/src/move_base_app/package.xml @@ -0,0 +1,15 @@ + + + move_base_app + 0.0.1 + Move base app with ros android + + Ivan Paunovic + + Apache 2.0 License + + catkin + roscpp + move_base + + diff --git a/example_workspace/src/move_base_app/settings.gradle b/example_workspace/src/move_base_app/settings.gradle new file mode 100644 index 0000000..f62608c --- /dev/null +++ b/example_workspace/src/move_base_app/settings.gradle @@ -0,0 +1,2 @@ +include ':jni' + diff --git a/example_workspace/src/nodelet_sample_app/CMakeLists.txt b/example_workspace/src/nodelet_sample_app/CMakeLists.txt new file mode 100644 index 0000000..88a4310 --- /dev/null +++ b/example_workspace/src/nodelet_sample_app/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 2.8.3) +project(nodelet_example) + +find_package(catkin REQUIRED rosjava_build_tools) + +catkin_android_setup(assemble${CMAKE_BUILD_TYPE}) + +catkin_package() \ No newline at end of file diff --git a/example_workspace/src/nodelet_sample_app/jni/CMakeLists.txt b/example_workspace/src/nodelet_sample_app/jni/CMakeLists.txt index d4ecfef..38e417c 100644 --- a/example_workspace/src/nodelet_sample_app/jni/CMakeLists.txt +++ b/example_workspace/src/nodelet_sample_app/jni/CMakeLists.txt @@ -15,13 +15,13 @@ # cmake_minimum_required(VERSION 3.4.1) +project(nodelet_example) -find_package(catkin REQUIRED COMPONENTS roscpp std_msgs rosconsole) +find_package(catkin REQUIRED COMPONENTS roscpp std_msgs rosconsole nodelet_tutorial_math) include_directories(${catkin_INCLUDE_DIRS}) # build native_app_glue as a static lib -set(${CMAKE_C_FLAGS}, "${CMAKE_C_FLAGS}") add_library(native_app_glue STATIC ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) @@ -33,15 +33,29 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -Wall -Werror") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") -add_library(native-activity SHARED main.cpp) +add_library(native-activity SHARED + src/main/cpp/ifaddrs.c + src/main/cpp/test_nodelet.cpp +) target_include_directories(native-activity PRIVATE ${ANDROID_NDK}/sources/android/native_app_glue) +# This is to be sure that the symbols of this libraries aren't dropped +# Also, put them in catkin find_package, in order to solve transitive dependencies without problems. +find_library(nodelet_math_PLUGIN NAMES nodelet_math) + +SET (WHOLE_ARCHIVE_LIBRARIES + -Wl,--whole-archive + ${nodelet_math_PLUGIN} + -Wl,--no-whole-archive +) + # add lib dependencies target_link_libraries(native-activity android native_app_glue - ${catkin_LIBRARIES} log + ${WHOLE_ARCHIVE_LIBRARIES} + ${catkin_LIBRARIES} ) diff --git a/example_workspace/src/nodelet_sample_app/jni/build.gradle b/example_workspace/src/nodelet_sample_app/jni/build.gradle index 9741d70..5600e37 100644 --- a/example_workspace/src/nodelet_sample_app/jni/build.gradle +++ b/example_workspace/src/nodelet_sample_app/jni/build.gradle @@ -4,13 +4,12 @@ android { compileSdkVersion 28 defaultConfig { - applicationId = 'com.example.hello_ros' + applicationId = 'com.example.nodelet_example' minSdkVersion 24 - targetSdkVersion 24 + targetSdkVersion 26 externalNativeBuild { cmake { arguments '-DANDROID_STL=c++_shared', - '-DCMAKE_INSTALL_PREFIX=' + System.getenv('TARGET_DIR'), '-DCMAKE_FIND_ROOT_PATH=' + System.getenv('TARGET_DIR'), '-DCMAKE_PREFIX_PATH=' + System.getenv('TARGET_DIR'), '-DBUILD_TESTING=OFF', @@ -20,7 +19,7 @@ android { ndk { // Specifies the ABI configurations of your native // libraries Gradle should build and package with your APK. - abiFilters 'arm64-v8a' + abiFilters System.getenv('ANDROID_ABI') ?: 'arm64-v8a' } } buildTypes { @@ -32,13 +31,11 @@ android { } externalNativeBuild { cmake { - path 'src/main/cpp/CMakeLists.txt' + path 'CMakeLists.txt' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) - implementation 'com.android.support:appcompat-v7:28.0.0' - implementation 'com.android.support.constraint:constraint-layout:1.1.3' } diff --git a/example_workspace/src/nodelet_sample_app/jni/AndroidManifest.xml b/example_workspace/src/nodelet_sample_app/jni/src/main/AndroidManifest.xml similarity index 96% rename from example_workspace/src/nodelet_sample_app/jni/AndroidManifest.xml rename to example_workspace/src/nodelet_sample_app/jni/src/main/AndroidManifest.xml index d36cdb8..7dd2097 100644 --- a/example_workspace/src/nodelet_sample_app/jni/AndroidManifest.xml +++ b/example_workspace/src/nodelet_sample_app/jni/src/main/AndroidManifest.xml @@ -1,7 +1,7 @@ diff --git a/example_workspace/src/nodelet_sample_app/jni/src/ifaddrs.c b/example_workspace/src/nodelet_sample_app/jni/src/main/cpp/ifaddrs.c similarity index 100% rename from example_workspace/src/nodelet_sample_app/jni/src/ifaddrs.c rename to example_workspace/src/nodelet_sample_app/jni/src/main/cpp/ifaddrs.c diff --git a/example_workspace/src/nodelet_sample_app/jni/src/test_nodelet.cpp b/example_workspace/src/nodelet_sample_app/jni/src/main/cpp/test_nodelet.cpp similarity index 66% rename from example_workspace/src/nodelet_sample_app/jni/src/test_nodelet.cpp rename to example_workspace/src/nodelet_sample_app/jni/src/main/cpp/test_nodelet.cpp index 93aaeff..2d7b657 100644 --- a/example_workspace/src/nodelet_sample_app/jni/src/test_nodelet.cpp +++ b/example_workspace/src/nodelet_sample_app/jni/src/main/cpp/test_nodelet.cpp @@ -9,10 +9,10 @@ **/ #ifndef ROS_MASTER_URI -#error ROS_MASTER_URI MUST be set in files/nodelet_sample_app/jni/Android.mk.in +#define ROS_MASTER_URI "__master:=http://10.34.0.120:11311" #endif #ifndef ROS_ANDROID_IP -#error ROS_ANDROID_IP MUST be set in files/nodelet_sample_app/jni/Android.mk.in +#define ROS_ANDROID_IP "__ip:=10.34.0.121" #endif #include "ros/ros.h" @@ -28,44 +28,44 @@ #define LOG_TAG "NODELET_TEST" -#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) -#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__) +#define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, ##__VA_ARGS__) +#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, ##__VA_ARGS__) bool getHostIp(const char *interface, char *ipaddr); -int main() +void android_main(android_app *state) { bool res; std::map remappings; std::vector nodelet_argv; char strbuf[128]; char ipAddr[20]; - char *argv[] = {"cmd", ROS_MASTER_URI, ROS_ANDROID_IP}; + const char *argv[] = {"cmd", ROS_MASTER_URI, ROS_ANDROID_IP}; int argc = 3; // Dynamically obtain the IP of the host we are running in. if (!getHostIp("wlan0", ipAddr)) { LOGD("Failed to get IP address for this interface!"); - return 1; + return; } sprintf(strbuf, "__ip:=%s", ipAddr); argv[2] = strbuf; LOGD("Starting program..."); - ros::init(argc, argv, "simple_nodelet_loader"); + ros::init(argc, const_cast(&argv[0]), "simple_nodelet_loader"); std::string master_uri = ros::master::getURI(); if (ros::master::check()) { LOGD("ROS master is up at %s", master_uri.c_str()); - LOGD("Local address is %s", ipAddr, ipAddr); + LOGD("Local address is %s", ipAddr); } else { LOGD("Failed to find ROS master!"); - return 1; + ANativeActivity_finish(state->activity); } ros::NodeHandle nh; @@ -80,27 +80,42 @@ int main() if (!res) { LOGD("Problem loading nodelet!"); - return 1; + return; } - ros::Rate loop_rate(10); - + ros::AsyncSpinner spinner(4); + spinner.start(); + LOGD("Starting ROS main loop..."); - while (ros::ok()) - { - ros::spinOnce(); - loop_rate.sleep(); + while(1) { + int events; + struct android_poll_source* source; + + // Poll android events. Check whatever ros died every five seconds. + while (ALooper_pollAll(5000, NULL, &events, (void**)&source) >= 0) { + // Process this event + if (source != NULL) { + source->process(state, source); + } + + // Check if we are exiting. + if (state->destroyRequested != 0) { + LOGD("APP DESTROYED BYE BYE"); + return; + } + LOGD("Polling"); + } + LOGD("Timeout"); + if (!ros::ok() || !ros::master::check()) { + LOGD("ROS ISN'T OK, BYE BYE"); + ANativeActivity_finish(state->activity); + } } LOGD("Program ending..."); - return 0; -} - -void android_main(struct android_app* state) { - app_dummy(); // needed so the Android glue does not get stripped off - main(); + return; } // Get the current host IP address on the specified interface. diff --git a/example_workspace/src/nodelet_sample_app/jni/src/main/res/mipmap-hdpi/ic_launcher.png b/example_workspace/src/nodelet_sample_app/jni/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..cde69bc Binary files /dev/null and b/example_workspace/src/nodelet_sample_app/jni/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/example_workspace/src/nodelet_sample_app/jni/src/main/res/mipmap-mdpi/ic_launcher.png b/example_workspace/src/nodelet_sample_app/jni/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c133a0c Binary files /dev/null and b/example_workspace/src/nodelet_sample_app/jni/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/example_workspace/src/nodelet_sample_app/jni/src/main/res/mipmap-xhdpi/ic_launcher.png b/example_workspace/src/nodelet_sample_app/jni/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..bfa42f0 Binary files /dev/null and b/example_workspace/src/nodelet_sample_app/jni/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/example_workspace/src/nodelet_sample_app/jni/src/main/res/mipmap-xxhdpi/ic_launcher.png b/example_workspace/src/nodelet_sample_app/jni/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..324e72c Binary files /dev/null and b/example_workspace/src/nodelet_sample_app/jni/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/example_workspace/src/nodelet_sample_app/jni/src/main/res/values/strings.xml b/example_workspace/src/nodelet_sample_app/jni/src/main/res/values/strings.xml new file mode 100644 index 0000000..b9a1ea5 --- /dev/null +++ b/example_workspace/src/nodelet_sample_app/jni/src/main/res/values/strings.xml @@ -0,0 +1,4 @@ + + + NodeletMath + diff --git a/example_workspace/src/nodelet_sample_app/package.xml b/example_workspace/src/nodelet_sample_app/package.xml new file mode 100644 index 0000000..ae6649e --- /dev/null +++ b/example_workspace/src/nodelet_sample_app/package.xml @@ -0,0 +1,17 @@ + + + nodelet_example + 0.0.1 + Nodelet example app with ros on android + + Ivan Paunovic + + Apache 2.0 License + + catkin + roscpp + std_msgs + rosconsole + nodelet + + diff --git a/example_workspace/src/pluginlib_sample_app/AndroidManifest.xml.in b/example_workspace/src/pluginlib_sample_app/AndroidManifest.xml.in deleted file mode 100644 index dfeab35..0000000 --- a/example_workspace/src/pluginlib_sample_app/AndroidManifest.xml.in +++ /dev/null @@ -1,22 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/example_workspace/src/pluginlib_sample_app/CMakeLists.txt b/example_workspace/src/pluginlib_sample_app/CMakeLists.txt new file mode 100644 index 0000000..400b5a8 --- /dev/null +++ b/example_workspace/src/pluginlib_sample_app/CMakeLists.txt @@ -0,0 +1,8 @@ +cmake_minimum_required(VERSION 2.8.3) +project(pluginlib_sample) + +find_package(catkin REQUIRED rosjava_build_tools) + +catkin_android_setup(assemble${CMAKE_BUILD_TYPE}) + +catkin_package() \ No newline at end of file diff --git a/example_workspace/src/pluginlib_sample_app/build.gradle b/example_workspace/src/pluginlib_sample_app/build.gradle new file mode 100644 index 0000000..4e99eeb --- /dev/null +++ b/example_workspace/src/pluginlib_sample_app/build.gradle @@ -0,0 +1,21 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. +buildscript { + repositories { + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.2.1' + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/example_workspace/src/pluginlib_sample_app/custom_rules.xml.in b/example_workspace/src/pluginlib_sample_app/custom_rules.xml.in deleted file mode 100644 index 189a837..0000000 --- a/example_workspace/src/pluginlib_sample_app/custom_rules.xml.in +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - diff --git a/example_workspace/src/pluginlib_sample_app/gradle/wrapper/gradle-wrapper.jar b/example_workspace/src/pluginlib_sample_app/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000..8c0fb64 Binary files /dev/null and b/example_workspace/src/pluginlib_sample_app/gradle/wrapper/gradle-wrapper.jar differ diff --git a/example_workspace/src/pluginlib_sample_app/gradle/wrapper/gradle-wrapper.properties b/example_workspace/src/pluginlib_sample_app/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..d604c72 --- /dev/null +++ b/example_workspace/src/pluginlib_sample_app/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Sun Feb 05 19:39:12 IST 2017 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-4.6-all.zip diff --git a/example_workspace/src/pluginlib_sample_app/gradlew b/example_workspace/src/pluginlib_sample_app/gradlew new file mode 100755 index 0000000..91a7e26 --- /dev/null +++ b/example_workspace/src/pluginlib_sample_app/gradlew @@ -0,0 +1,164 @@ +#!/usr/bin/env bash + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn ( ) { + echo "$*" +} + +die ( ) { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; +esac + +# For Cygwin, ensure paths are in UNIX format before anything is touched. +if $cygwin ; then + [ -n "$JAVA_HOME" ] && JAVA_HOME=`cygpath --unix "$JAVA_HOME"` +fi + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >&- +APP_HOME="`pwd -P`" +cd "$SAVED" >&- + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules +function splitJvmOpts() { + JVM_OPTS=("$@") +} +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME" + +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@" diff --git a/example_workspace/src/pluginlib_sample_app/gradlew.bat b/example_workspace/src/pluginlib_sample_app/gradlew.bat new file mode 100644 index 0000000..aec9973 --- /dev/null +++ b/example_workspace/src/pluginlib_sample_app/gradlew.bat @@ -0,0 +1,90 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windowz variants + +if not "%OS%" == "Windows_NT" goto win9xME_args +if "%@eval[2+2]" == "4" goto 4NT_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* +goto execute + +:4NT_args +@rem Get arguments from the 4NT Shell from JP Software +set CMD_LINE_ARGS=%$ + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/example_workspace/src/pluginlib_sample_app/ic_launcher.png b/example_workspace/src/pluginlib_sample_app/ic_launcher.png deleted file mode 100644 index c7956d1..0000000 Binary files a/example_workspace/src/pluginlib_sample_app/ic_launcher.png and /dev/null differ diff --git a/example_workspace/src/pluginlib_sample_app/jni/Android.mk.in b/example_workspace/src/pluginlib_sample_app/jni/Android.mk.in deleted file mode 100644 index 47a1259..0000000 --- a/example_workspace/src/pluginlib_sample_app/jni/Android.mk.in +++ /dev/null @@ -1,13 +0,0 @@ -LOCAL_PATH := $(call my-dir) - -include $(CLEAR_VARS) -LOCAL_MODULE := pluginlib_sample_app -#LOCAL_C_INCLUDES := include/ -LOCAL_SRC_FILES := src/polygon_loader.cpp -LOCAL_WHOLE_STATIC_LIBRARIES := libpluginlib_tutorials -LOCAL_STATIC_LIBRARIES := roscpp_android_ndk android_native_app_glue gnustl_static -LOCAL_LDLIBS := -landroid -llog -#LOCAL_CPPFLAGS += -frtti -fexceptions -include $(BUILD_SHARED_LIBRARY) -$(call import-module, android/native_app_glue) -$(call import-module, roscpp_android_ndk) diff --git a/example_workspace/src/pluginlib_sample_app/jni/Application.mk b/example_workspace/src/pluginlib_sample_app/jni/Application.mk deleted file mode 100644 index f105759..0000000 --- a/example_workspace/src/pluginlib_sample_app/jni/Application.mk +++ /dev/null @@ -1,5 +0,0 @@ -APP_STL := gnustl_static -APP_PLATFORM := android-15 -APP_ABI := armeabi-v7a -APP_OPTIM := debug -APP_CPPFLAGS := -frtti -fexceptions diff --git a/example_workspace/src/pluginlib_sample_app/jni/CMakeLists.txt b/example_workspace/src/pluginlib_sample_app/jni/CMakeLists.txt new file mode 100644 index 0000000..fc5f454 --- /dev/null +++ b/example_workspace/src/pluginlib_sample_app/jni/CMakeLists.txt @@ -0,0 +1,60 @@ +# +# Copyright (C) The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +cmake_minimum_required(VERSION 3.4.1) +project(pluginlib_sample) + +find_package(catkin REQUIRED COMPONENTS roscpp std_msgs rosconsole pluginlib_tutorials) + +include_directories(${catkin_INCLUDE_DIRS}) + +# build native_app_glue as a static lib +add_library(native_app_glue STATIC + ${ANDROID_NDK}/sources/android/native_app_glue/android_native_app_glue.c) + +# now build app's shared lib +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -Wall -Werror") + +# Export ANativeActivity_onCreate(), +# Refer to: https://github.com/android-ndk/ndk/issues/381. +set(CMAKE_SHARED_LINKER_FLAGS + "${CMAKE_SHARED_LINKER_FLAGS} -u ANativeActivity_onCreate") + +add_library(${PROJECT_NAME} SHARED + src/main/cpp/polygon_loader.cpp +) + +target_include_directories(${PROJECT_NAME} PRIVATE + ${ANDROID_NDK}/sources/android/native_app_glue) + +# This is to be sure that the symbols of this libraries aren't dropped +# Also, put them in catkin find_package, in order to solve transitive dependencies without problems. +find_library(pluginlib_tutorials_PLUGIN NAMES pluginlib_tutorials) + +SET (WHOLE_ARCHIVE_LIBRARIES + -Wl,--whole-archive + ${pluginlib_tutorials_PLUGIN} + -Wl,--no-whole-archive +) + +# add lib dependencies +target_link_libraries(${PROJECT_NAME} + android + native_app_glue + ${catkin_LIBRARIES} + log + ${WHOLE_ARCHIVE_LIBRARIES} +) diff --git a/example_workspace/src/pluginlib_sample_app/jni/build.gradle b/example_workspace/src/pluginlib_sample_app/jni/build.gradle new file mode 100644 index 0000000..830adb4 --- /dev/null +++ b/example_workspace/src/pluginlib_sample_app/jni/build.gradle @@ -0,0 +1,41 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 28 + + defaultConfig { + applicationId = 'com.example.pluginlib_sample' + minSdkVersion 24 + targetSdkVersion 26 + externalNativeBuild { + cmake { + arguments '-DANDROID_STL=c++_shared', + '-DCMAKE_FIND_ROOT_PATH=' + System.getenv('TARGET_DIR'), + '-DCMAKE_PREFIX_PATH=' + System.getenv('TARGET_DIR'), + '-DBUILD_TESTING=OFF', + '-DCATKIN_ENABLE_TESTING=OFF' + } + } + ndk { + // Specifies the ABI configurations of your native + // libraries Gradle should build and package with your APK. + abiFilters System.getenv('ANDROID_ABI') ?: 'arm64-v8a' + } + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), + 'proguard-rules.pro' + } + } + externalNativeBuild { + cmake { + path 'CMakeLists.txt' + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) +} diff --git a/example_workspace/src/pluginlib_sample_app/jni/src/main/AndroidManifest.xml b/example_workspace/src/pluginlib_sample_app/jni/src/main/AndroidManifest.xml new file mode 100644 index 0000000..a52898e --- /dev/null +++ b/example_workspace/src/pluginlib_sample_app/jni/src/main/AndroidManifest.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/example_workspace/src/pluginlib_sample_app/jni/src/polygon_loader.cpp b/example_workspace/src/pluginlib_sample_app/jni/src/main/cpp/polygon_loader.cpp similarity index 87% rename from example_workspace/src/pluginlib_sample_app/jni/src/polygon_loader.cpp rename to example_workspace/src/pluginlib_sample_app/jni/src/main/cpp/polygon_loader.cpp index ea7efbe..fbba8b9 100644 --- a/example_workspace/src/pluginlib_sample_app/jni/src/polygon_loader.cpp +++ b/example_workspace/src/pluginlib_sample_app/jni/src/main/cpp/polygon_loader.cpp @@ -49,15 +49,7 @@ #define LOGD(...) __android_log_print(ANDROID_LOG_DEBUG, LOG_TAG, __VA_ARGS__) #define LOGE(...) __android_log_print(ANDROID_LOG_ERROR, LOG_TAG, __VA_ARGS__) -int main(); - void android_main(struct android_app* state) { - app_dummy(); // needed so the Android glue does not get stripped off - main(); -} - -int main() -{ LOGD("Starting app."); pluginlib::ClassLoader poly_loader("pluginlib_tutorials", "polygon_base::RegularPolygon"); @@ -89,5 +81,24 @@ int main() LOGD("The plugin failed to load for some reason. Error: %s", ex.what()); } - return 0; + while(1) { + int events; + struct android_poll_source* source; + + // Poll android events, locking + while (ALooper_pollAll(-1, NULL, &events, (void**)&source) >= 0) { + // Process this event + if (source != NULL) { + source->process(state, source); + } + + // Check if we are exiting. + if (state->destroyRequested != 0) { + LOGD("APP DESTROYED BYE BYE"); + return; + } + } + } + + return; } diff --git a/example_workspace/src/pluginlib_sample_app/jni/src/main/res/mipmap-hdpi/ic_launcher.png b/example_workspace/src/pluginlib_sample_app/jni/src/main/res/mipmap-hdpi/ic_launcher.png new file mode 100644 index 0000000..cde69bc Binary files /dev/null and b/example_workspace/src/pluginlib_sample_app/jni/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/example_workspace/src/pluginlib_sample_app/jni/src/main/res/mipmap-mdpi/ic_launcher.png b/example_workspace/src/pluginlib_sample_app/jni/src/main/res/mipmap-mdpi/ic_launcher.png new file mode 100644 index 0000000..c133a0c Binary files /dev/null and b/example_workspace/src/pluginlib_sample_app/jni/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/example_workspace/src/pluginlib_sample_app/jni/src/main/res/mipmap-xhdpi/ic_launcher.png b/example_workspace/src/pluginlib_sample_app/jni/src/main/res/mipmap-xhdpi/ic_launcher.png new file mode 100644 index 0000000..bfa42f0 Binary files /dev/null and b/example_workspace/src/pluginlib_sample_app/jni/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/example_workspace/src/pluginlib_sample_app/jni/src/main/res/mipmap-xxhdpi/ic_launcher.png b/example_workspace/src/pluginlib_sample_app/jni/src/main/res/mipmap-xxhdpi/ic_launcher.png new file mode 100644 index 0000000..324e72c Binary files /dev/null and b/example_workspace/src/pluginlib_sample_app/jni/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/example_workspace/src/pluginlib_sample_app/jni/src/main/res/values/strings.xml b/example_workspace/src/pluginlib_sample_app/jni/src/main/res/values/strings.xml new file mode 100644 index 0000000..5391f48 --- /dev/null +++ b/example_workspace/src/pluginlib_sample_app/jni/src/main/res/values/strings.xml @@ -0,0 +1,4 @@ + + + PluginlibSample + diff --git a/example_workspace/src/pluginlib_sample_app/package.xml b/example_workspace/src/pluginlib_sample_app/package.xml new file mode 100644 index 0000000..aba6b3e --- /dev/null +++ b/example_workspace/src/pluginlib_sample_app/package.xml @@ -0,0 +1,17 @@ + + + pluginlib_sample + 0.0.1 + Pluginlib example app with ros on android + + Ivan Paunovic + + Apache 2.0 License + + catkin + roscpp + std_msgs + rosconsole + pluginlib_tutorials + + diff --git a/example_workspace/src/pluginlib_sample_app/settings.gradle b/example_workspace/src/pluginlib_sample_app/settings.gradle new file mode 100644 index 0000000..f62608c --- /dev/null +++ b/example_workspace/src/pluginlib_sample_app/settings.gradle @@ -0,0 +1,2 @@ +include ':jni' + diff --git a/ndk.rosinstall b/ndk.rosinstall index 03a8225..611d349 100644 --- a/ndk.rosinstall +++ b/ndk.rosinstall @@ -733,3 +733,11 @@ local-name: rosjava/rosjava_build_tools uri: https://github.com/rosjava/rosjava_build_tools version: kinetic +- tar: + local-name: common_tutorials/nodelet_tutorial_math + uri: https://github.com/ros-gbp/common_tutorials-release/archive/release/indigo/nodelet_tutorial_math/0.1.8-0.tar.gz + version: common_tutorials-release-release-indigo-nodelet_tutorial_math-0.1.8-0 +- tar: + local-name: common_tutorials/pluginlib_tutorials + uri: https://github.com/ros-gbp/common_tutorials-release/archive/release/indigo/pluginlib_tutorials/0.1.8-0.tar.gz + version: common_tutorials-release-release-indigo-pluginlib_tutorials-0.1.8-0 diff --git a/patches/move_base.patch b/patches/move_base.patch new file mode 100644 index 0000000..0bd1b41 --- /dev/null +++ b/patches/move_base.patch @@ -0,0 +1,27 @@ +--- catkin_ws/src/navigation/move_base/CMakeLists.txt ++++ catkin_ws/src/navigation/move_base/CMakeLists.txt +@@ -31,12 +31,24 @@ generate_dynamic_reconfigure_options( + ) + + catkin_package( ++ INCLUDE_DIRS include ++ LIBRARIES ${PROJECT_NAME} + CATKIN_DEPENDS + dynamic_reconfigure ++ actionlib ++ base_local_planner ++ clear_costmap_recovery ++ costmap_2d + geometry_msgs + move_base_msgs ++ nav_core + nav_msgs ++ navfn ++ pluginlib + roscpp ++ rotate_recovery ++ std_srvs ++ tf + ) + + include_directories(