alecive / yarpdroid

Let's make yarp more droid-friendly!
http://alecive.github.io/research/2015/08/01/yarpdroid/
GNU General Public License v2.0
2 stars 0 forks source link

Compilation with Android Studio #1

Open GuillaumeGibert opened 8 years ago

GuillaumeGibert commented 8 years ago

Hi @alecive, I cross-compiled the yarp_os, yarp_sig and yarp_init following the suggested changes from these webpages: https://github.com/alecive/alecive.github.io/issues/4 and http://alecive.github.io/blog/2015/08/31/YARP-Cross-Compilation/. I cloned the yarpdroid repo and installed android sdk, ndk and studio. Could you please tell me where I should copy the libYARP_OS.a libYarp_sig.a and libYARP_init.a files? Could you please tell me how to compile the yarpdroid app?

alecive commented 8 years ago

Some random questions before we start:

GuillaumeGibert commented 8 years ago

I installed Android Studio (2.1.2) with jre 1.70_80 on ubuntu 16.04. I also installed NDK (1.0). I imported the yarpdroid project on Android studio but I got a gradle error. I have no experience with android studio yet.

GuillaumeGibert commented 8 years ago

Hi @alecive, I was able to compile and run the yarpdroid app by downgrading the Android Studio version to 1.5.1. (the gradle errors disappeared). I had to copy several yarp include files to the app/src/main/jni/ directory to successfully compile the app. Is there a better way to provide these include files than copying them? I run the app and was able to view the image from icubSim's left eye. I tried to stream a video from a webcam using the command "yarpdev --device opencv_grabber" but the received video stream was noisy (horizontal lines) and not very fluid whereas it was good on a yarpview. Do you have any idea how it could be improved? Thanks in advance

alecive commented 8 years ago

Hey @GuillaumeGibert , sorry for the delay ( I was at the RSS conference last week). Great that you managed to fix it! Can you please list me every single thing you did to make it work so that I can add it to some how-to? It's been a while since I did everything from scratch and this would be beneficial.

Regarding the web camera, is it possible that the issue is related to the resolution? iCub cameras are 320x240 pixels, and probably your webcam is at least 480p (if not higher), so at least 4 times bigger. Can you try to downsize it to a lower resolution?

GuillaumeGibert commented 8 years ago

Hi @alecive, here is the list of steps I followed to make it work:

  1. mkdir yarp-android
  2. cd yarp-android
  3. git clone https://github.com/robotology/yarp.git
  4. modify yarp-android/yarp/src/libYARP_OS/src/BottleImpl.cpp following http://alecive.github.io/blog/2015/08/31/YARP-Cross-Compilation/
  5. modify yarp-android/yarp/src/libYARP_OS/src/NameConfig.cpp following http://alecive.github.io/blog/2015/08/31/YARP-Cross-Compilation/
  6. modify yarp-android/yarp/src/libYARP_OS/src/PortCore.cpp following https://github.com/alecive/alecive.github.io/issues/4
  7. modify yarp-android/yarp/src/libYARP_OS/src/SharedLibrary.cpp following https://github.com/alecive/alecive.github.io/issues/4
  8. modify yarp-android/yarp/src/libYARP_OS/src/SystemInfo.cpp following http://alecive.github.io/blog/2015/08/31/YARP-Cross-Compilation/ and https://github.com/alecive/alecive.github.io/issues/4
  9. modify yarp-android/yarp/src/libYARP_OS/src/ThreadImpl.cpp following https://github.com/alecive/alecive.github.io/issues/4
  10. modify yarp-android/yarp/src/libYARP_OS/CMakeLists.txt following http://alecive.github.io/blog/2015/08/31/YARP-Cross-Compilation/
  11. create yarp-android/yarp/src/libYARP_OS/src/ifaddrs.c following http://alecive.github.io/blog/2015/08/31/YARP-Cross-Compilation/
  12. create yarp-android/yarp/src/libYARP_OS/include/yarp/os/impl/ifaddrs.h following http://alecive.github.io/blog/2015/08/31/YARP-Cross-Compilation/

Then,

  1. cd yarp-android/yarp/
  2. mkdir build
  3. ccmake -DCMAKE_TOOLCHAIN_FILE=../../../android.toolchain.cmake -DANDROID_NDK=$ANDROID_NDK -DCMAKE_BUILD_TYPE=Release -DANDROID_ABI="armeabi-v7a with NEON" -DSKIP_ACE=ON -DCMAKE_DISABLE_FIND_PACKAGE_OpenCV=TRUE ../

Put every flag to OFF. Press c and then t. Put gnustl_static under the ANDROID_STL item that just appeared. Type c, then c, then g. Now compile just YARP_OS:

  1. make YARP_OS
  2. make YARP_sig
  3. make YARP_init
  4. cd robotology/yarp-android
  5. git clone https://github.com/alecive/yarpdroid.git
  6. cp libYARP_init.a yarpdroid/app/src/main/jni/libs/armeabi-v7a/
  7. cp libYARP_OS.a yarpdroid/app/src/main/jni/libs/armeabi-v7a/
  8. cp libYARP_sig.a yarpdroid/app/src/main/jni/libs/armeabi-v7a/
  9. cd yarp-android/yarpdroid/app/src/main/jni
  10. mkdir yarp
  11. cp -r yarp/src/libYARP_OS/include/yarp/os/ yarp-android/yarpdroid/app/src/main/jni/yarp/
  12. cp ./build/generated_include/yarp/conf/api.h ../yarpdroid/app/src/main/jni/yarp/conf/
  13. cp ./build/generated_include/yarp/conf/system.h ../yarpdroid/app/src/main/jni/yarp/conf/
  14. cp ./build/generated_include/yarp/conf/numeric.h ../yarpdroid/app/src/main/jni/yarp/conf/
  15. cp -r yarp/src/libYARP_sig/include/yarp/sig/ ../../../../../yarpdroid/app/src/main/jni/yarp/

Finally, start Android Studio 1.5.1 and Build->Make project

I will try to reduce the image resolution and let you know if it is better. Cheers