Skip to content

Commit

Permalink
Merge pull request #72 from Intermodalics/ros-hello
Browse files Browse the repository at this point in the history
Ros hello world example app
  • Loading branch information
Juan Ignacio Ubeira authored Jan 2, 2019
2 parents ea24d89 + e1f8226 commit d181662
Show file tree
Hide file tree
Showing 32 changed files with 605 additions and 447 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
output
*.pyc
**/.gradle/*
**/build/*
**/.externalNativeBuild/*
files/pluginlib_helper/pluginlib_helper.cpp

39 changes: 12 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,43 +1,28 @@
These scripts will (hopefully) help you build static libraries
for tf2 for android and setup a sample application.
These scripts will help you build static libraries
for ROS kinetic for android and setup a sample application.

You will need android SDK installed and the 'android' program
location in the $PATH.

INSTALL
-------

Source ROS (for python tools):

source /opt/ros/kinetic/setup.bash
Build docker image and run it:

docker/build.sh
docker/run.sh

The `do_everything.sh` script will call all the other scripts
sequentially, you just have to give it a prefix path:

./do_everything.sh /path/to/workspace

YOU WILL PROBABLY HAVE TO RUN THIS MULTIPLE TIMES DUE TO PTHREAD LINKING.

You can also run each script individually, most of them have
a minimalistic help string to give you an idea of their parameters.

When finished, the script will give you a few lines of what it did.
If everything went fine, you will be able to do the following:

cd /path/to/workspace/sample_app
ant debug

This will build the app. If you want to install it, run the following:

ant debug install

This will install the app onto a virtual android device running in the
emulator.
BUILD SAMPLES
-------

To follow what the app does, you will need to read the log. The sdk has
a tool called `adb` located in `$SDK/platform-tools/`, you can follow the
log by running:
If you also want to build the samples, use:

$SDK/platform-tools/adb logcat
./do_everything.sh /path/to/workspace --samples

Good luck!
You can find the resulting apks inside `/path/to/workspace/target/apks/name_of_the_sample_app/apk_file`.
Specific instructions about how to use the samples are located inside: `files/name_of_the_sample_app/README.md`
22 changes: 0 additions & 22 deletions build_eigen.sh

This file was deleted.

2 changes: 1 addition & 1 deletion build_library_with_toolchain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ elif [ "arm64-v8a" = $ANDROID_ABI ]; then
fi

if [ ! -d toolchain/ ]; then
$ANDROID_NDK/build/tools/make-standalone-toolchain.sh --install-dir=./toolchain --arch=$arch --platform=${ANDROID_PLATFORM} --stl=${ANDROID_STL}
$ANDROID_NDK_HOME/build/tools/make-standalone-toolchain.sh --install-dir=./toolchain --arch=$arch --platform=${ANDROID_PLATFORM} --stl=${ANDROID_STL}
fi
export PATH=$PATH:$2/toolchain/bin

Expand Down
52 changes: 0 additions & 52 deletions create_android_mk.sh

This file was deleted.

119 changes: 24 additions & 95 deletions do_everything.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ debugging=0
skip=0
portable=0
help=0
samples=0
user_workspace=""

# verbose is a bool flag indicating if we want more verbose output in
Expand Down Expand Up @@ -44,12 +45,15 @@ do
help=1
fi
shift
elif [[ ${var} == "--samples" ]] ; then
samples=1
elif [[ ! -z prefix ]]; then
if [ ! -d $1 ]; then
mkdir -p $1
fi
prefix=$(cd $1 && pwd)
fi

shift
done

Expand Down Expand Up @@ -82,8 +86,8 @@ run_cmd() {
$my_loc/$cmd $@ || die "$cmd $@ died with error code $?"
}

if [ -z $ANDROID_NDK ] ; then
die "ANDROID_NDK ENVIRONMENT NOT FOUND!"
if [ -z $ANDROID_NDK_HOME ] ; then
die "ANDROID_NDK_HOME ENVIRONMENT NOT FOUND!"
fi

[ -d $standalone_toolchain_path ] || run_cmd setup_standalone_toolchain
Expand All @@ -106,8 +110,8 @@ export TARGET_DIR=$prefix/target
# cat $my_loc/files/android.toolchain.cmake.addendum >> $prefix/android.toolchain.cmake
#fi

export RBA_TOOLCHAIN=$ANDROID_NDK/build/cmake/android.toolchain.cmake
apply_patch $my_loc/patches/android.toolchain.cmake.patch -d $ANDROID_NDK/build/cmake
export RBA_TOOLCHAIN=$ANDROID_NDK_HOME/build/cmake/android.toolchain.cmake
apply_patch $my_loc/patches/android.toolchain.cmake.patch -d $ANDROID_NDK_HOME/build/cmake

# Now get boost with a specialized build
[ -d $prefix/libs/boost ] || run_cmd get_library boost $prefix/libs
Expand Down Expand Up @@ -380,100 +384,25 @@ else
run_cmd build_cpp -p $prefix -b Release -v $verbose
fi

echo
echo -e '\e[34mSetting up ndk project.\e[39m'
echo

run_cmd setup_ndk_project $prefix/roscpp_android_ndk $portable

echo
echo -e '\e[34mCreating Android.mk.\e[39m'
echo

run_cmd create_android_mk $prefix/catkin_ws/src $prefix/roscpp_android_ndk

if [[ $debugging -eq 1 ]];then
sed -i "s/#LOCAL_EXPORT_CFLAGS/LOCAL_EXPORT_CFLAGS/g" $prefix/roscpp_android_ndk/Android.mk
fi

# copy Android makfile to use in building the apps with roscpp_android_ndk
cp $my_loc/files/Android.mk.move_base $prefix/roscpp_android_ndk/Android.mk

echo
echo -e '\e[34mCreating sample app.\e[39m'
echo

( cd $prefix && run_cmd sample_app sample_app $prefix/roscpp_android_ndk )

echo
echo -e '\e[34mBuilding apk.\e[39m'
echo

(cd $prefix/sample_app && ant debug)

echo
echo -e '\e[34mCreating move_base sample app.\e[39m'
echo

( cd $prefix && run_cmd sample_app move_base_app $prefix/roscpp_android_ndk )

echo
echo -e '\e[34mBuilding move_base apk.\e[39m'
echo

(cd $prefix/move_base_app && ant debug)

echo
echo -e '\e[34mCreating pluginlib sample app.\e[39m'
echo

( cd $prefix && run_cmd sample_app pluginlib_sample_app $prefix/roscpp_android_ndk )

echo
echo -e '\e[34mBuilding apk.\e[39m'
echo

(cd $prefix/pluginlib_sample_app && ant debug)

echo
echo -e '\e[34mCreating nodelet sample app.\e[39m'
echo

( cd $prefix && run_cmd sample_app nodelet_sample_app $prefix/roscpp_android_ndk )

echo
echo -e '\e[34mBuilding apk.\e[39m'
echo

(cd $prefix/nodelet_sample_app && ant debug)

echo
echo -e '\e[34mCreating image transport sample app.\e[39m'
echo
if [[ $samples -eq 1 ]];then
echo
echo -e '\e[34mBuilding sample apps.\e[39m'
echo

# Copy specific Android makefile to build the image_transport_sample_app
# This makefile includes the missing opencv 3rd party libraries.
( cp $my_loc/files/Android.mk.image_transport $prefix/roscpp_android_ndk/Android.mk)
build_sample() {
cd $2

( cd $prefix && run_cmd sample_app image_transport_sample_app $prefix/roscpp_android_ndk )
echo "Building $1"

echo
echo -e '\e[34mBuilding apk.\e[39m'
echo
# TODO(ivanpauno): Add release apk option
./gradlew assembleDebug

(cd $prefix/image_transport_sample_app && ant debug)
mkdir -p $prefix/target/apks/$1

echo "Copying generated apks inside $prefix/target/apks/$1"
find . -type f -name "*.apk" -exec cp {} $prefix/target/apks/$1 \;
cd $my_loc
}

echo
echo 'done.'
echo 'summary of what just happened:'
echo ' target/ was used to build static libraries for ros software'
echo ' include/ contains headers'
echo ' lib/ contains static libraries'
echo ' roscpp_android_ndk/ is a NDK sub-project that can be imported into an NDK app'
echo ' sample_app/ is an example of such an app, a native activity'
echo ' sample_app/bin/sample_app-debug.apk is the built apk, it implements a subscriber and a publisher'
echo ' move_base_sample_app/ is an example app that implements the move_base node'
echo ' move_base_app/bin/move_base_app-debug.apk is the built apk for the move_base example'
echo ' pluginlib_sample_app/ is an example of an application using pluginlib'
echo ' pluginlib_sample_app/bin/pluginlib_sample_app-debug.apk is the built apk'
[ -d $prefix/target/apks/hello_world ] || build_sample hello_world $my_loc/files/hello_world_example_app
fi
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ RUN wget https://dl.google.com/android/repository/android-ndk-r18b-linux-x86_64.
RUN unzip android-ndk-r18b-linux-x86_64.zip -d /opt/android/sdk

# Set-up environment
ENV ANDROID_NDK /opt/android/sdk/android-ndk-r18b
ENV ANDROID_NDK_HOME /opt/android/sdk/android-ndk-r18b

# Install g++ to avoid "CMAKE_CXX_COMPILER-NOTFOUND was not found." error
RUN apt-get update && apt-get install -y g++ cmake make clang
Expand Down
36 changes: 0 additions & 36 deletions files/Android.mk.image_transport

This file was deleted.

36 changes: 0 additions & 36 deletions files/Android.mk.move_base

This file was deleted.

Loading

0 comments on commit d181662

Please sign in to comment.