RTABMap for Android

classic Classic list List threaded Threaded
26 messages Options
12
Reply | Threaded
Open this post in threaded view
|

Re: RTABMap for Android

matlabbe
Administrator
This post was updated on .
Hi,

Build VTK from source for android. Then in PCL (I used 1.7.2), build with VTK and you have to remove the "NOT ANDROID" in the surface module CMakeLists.txt here and here.

EDIT
There is also another NOT ANDROID to remove here. I removed also QVTK line:
# Find VTK
option(WITH_VTK "Build VTK-Visualizations" TRUE)
if(WITH_VTK)
  find_package(VTK)
  if(VTK_FOUND)
    message(STATUS "VTK_MAJOR_VERSION ${VTK_MAJOR_VERSION}")
    if (PCL_SHARED_LIBS OR
        (NOT (PCL_SHARED_LIBS) AND NOT (VTK_BUILD_SHARED_LIBS)))
      set(VTK_FOUND TRUE)
    #  find_package (QVTK)
    #  if (${VTK_MAJOR_VERSION} VERSION_LESS "6.0")
    #     message(STATUS "VTK found (include: ${VTK_INCLUDE_DIRS}, lib: ${VTK_LIBRARY_DIRS})")
         link_directories(${VTK_LIBRARY_DIRS})
    #  else(${VTK_MAJOR_VERSION} VERSION_LESS "6.0")
         include (${VTK_USE_FILE})
    #     message(STATUS "VTK found (include: ${VTK_INCLUDE_DIRS}, lib: ${VTK_LIBRARIES}")
    #  endif (${VTK_MAJOR_VERSION} VERSION_LESS "6.0")
    #  if (APPLE)
    #      option (VTK_USE_COCOA "Use Cocoa for VTK render windows" ON)
    #      MARK_AS_ADVANCED (VTK_USE_COCOA)
    #  endif (APPLE)
      set(HAVE_VTK ON)
    else ()
      set(VTK_FOUND OFF)
      set(HAVE_VTK OFF)
      message ("Warning: You are to build PCL in STATIC but VTK is SHARED!")
      message ("Warning: VTK disabled!")
    endif ()
  endif(VTK_FOUND)
else(WITH_VTK)
  set(VTK_FOUND OFF)
  set(HAVE_VTK OFF)
endif(WITH_VTK)

In the installed PCLConfig.cmake, other modifications:
macro(find_VTK)

# if(NOT ANDROID)
    find_package(VTK ${QUIET_})
    if (VTK_FOUND)
      set(VTK_LIBRARIES "vtkCommonColor;vtkCommonCore;vtksys;vtkCommonDataModel;vtkCommonMath;vtkCommonMisc;vtkCommonSystem;vtkCommonTransforms;vtkCommonComputationalGeometry;vtkCommonExecutionModel;vtkDICOMParser;vtkFiltersCore;vtkFiltersExtraction;vtkFiltersGeneral;vtkFiltersStatistics;vtkImagingFourier;vtkImagingCore;vtkalglib;vtkFiltersGeometry;vtkFiltersModeling;vtkFiltersSources;vtkIOCore;vtklz4;vtkzlib;vtkIOGeometry;vtkIOLegacy;vtkIOImage;vtkmetaio;vtkjpeg;vtkpng;vtktiff;vtkIOInfovis;vtkIOXML;vtkIOXMLParser;vtkexpat;vtkInfovisCore;vtklibxml2;vtkIOPLY;vtkImagingMath;vtkInteractionStyle;vtkRenderingCore;vtkParallelCore;vtkRenderingFreeType;vtkfreetype;vtkRenderingOpenGL2;vtkglew;vtkRenderingVolume;vtkRenderingVolumeOpenGL2;vtkTestingRendering")
    endif(VTK_FOUND)
# endif()

- set(pcl_surface_opt_dep qhull )
+ set(pcl_surface_opt_dep qhull vtk)


cheers,
Mathieu
Reply | Threaded
Open this post in threaded view
|

Re: RTABMap for Android

vito-c
I'm able to compile rtabmap and load it up on my tango device but I get this error.

I/InputReader(  904): Reconfiguring input devices.  changes=0x00000004
I/TangoInitializationHelper(29956): basePath: /data/data/com.google.tango/libfiles/
E/art     (29956): dlopen("/data/data/com.google.tango/libfiles/arm64-v8a/libtango_client_api.so", RTLD_LAZY) failed: dlopen failed: library "/data/data/com.google.tango/libfiles/arm64-v8a/libtango_client_api.so" not found
I/TangoInitializationHelper(29956): Success! Using armeabi-v7a/libtango_client_api.
E/art     (29956): dlopen("/data/app-lib/com.introlab.rtabmap-1/libNativeRTABMap.so", RTLD_LAZY) failed: dlopen failed: cannot locate symbol "rand" referenced by "libNativeRTABMap.so"...
D/AndroidRuntime(29956): Shutting down VM
E/AndroidRuntime(29956): FATAL EXCEPTION: main
E/AndroidRuntime(29956): Process: com.introlab.rtabmap, PID: 29956
E/AndroidRuntime(29956): java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "rand" referenced by "libNativeRTABMap.so"...
E/AndroidRuntime(29956): at java.lang.Runtime.loadLibrary(Runtime.java:364)
E/AndroidRuntime(29956): at java.lang.System.loadLibrary(System.java:526)
E/AndroidRuntime(29956): at com.introlab.rtabmap.RTABMapLib.<clinit>(RTABMapLib.java:20)
E/AndroidRuntime(29956): at com.introlab.rtabmap.RTABMapActivity.onCreate(RTABMapActivity.java:203)
E/AndroidRuntime(29956): at android.app.Activity.performCreate(Activity.java:5231)
E/AndroidRuntime(29956): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
E/AndroidRuntime(29956): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2160)
E/AndroidRuntime(29956): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2246)
E/AndroidRuntime(29956): at android.app.ActivityThread.access$800(ActivityThread.java:136)
E/AndroidRuntime(29956): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1197)
E/AndroidRuntime(29956): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime(29956): at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime(29956): at android.app.ActivityThread.main(ActivityThread.java:5030)
E/AndroidRuntime(29956): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(29956): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime(29956): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
I/WindowManager(  904): Screen frozen for +350ms due to AppWindowToken{658b9ed0 token=Token{659366c8 ActivityRecord{65ccd8f0 u0 com.introlab.rtabmap/.RTABMapActivity t22}}}
W/ActivityManager(  904):   Force finishing activity com.introlab.rtabmap/.RTABMapActivity
Reply | Threaded
Open this post in threaded view
|

Re: RTABMap for Android

matlabbe
Administrator
It seems that libtango_client_api.so library is not found. Either copy libtango_support_api.so in rtabmap/app/android/jni/third-party/lib, or copy it in the build directory rtabmap/build/app/android/libs/armeabi-v7a so it will be packaged with the app.

cheers,
Mathieu
Reply | Threaded
Open this post in threaded view
|

Re: RTABMap for Android

vito-c
Hi, Mathieu

I am pretty sure the library is included now but I think I might be using the wrong sdk or ndk version. What version of the ndk/sdk should I be using? It looks like it tries to open the v8a libtango_client_api.so then fails and opens the v7a version successfully.

Once it has located the v7a lib it appears to fail on finding the rand symbol in libNativeRTABMap.so I found some posts discussing issues with rand, for example: https://github.com/cocos2d/cocos2d-x/issues/14034

Thank you for the help.

I/ActivityManager(  904): Start proc com.introlab.rtabmap for activity com.introlab.rtabmap/.RTABMapActivity: pid=2470 uid=10097 gids={50097, 1028, 1015}
I/TangoInitializationHelper( 2470): basePath: /data/data/com.google.tango/libfiles/
E/art     ( 2470): dlopen("/data/data/com.google.tango/libfiles/arm64-v8a/libtango_client_api.so", RTLD_LAZY) failed: dlopen failed: library "/data/data/com.google.tango/libfiles/arm64-v8a/libtango_client_api.so" not found
I/TangoInitializationHelper( 2470): Success! Using armeabi-v7a/libtango_client_api.
E/art     ( 2470): dlopen("/data/app-lib/com.introlab.rtabmap-1/libNativeRTABMap.so", RTLD_LAZY) failed: dlopen failed: cannot locate symbol "rand" referenced by "libNativeRTABMap.so"...
D/AndroidRuntime( 2470): Shutting down VM
E/AndroidRuntime( 2470): FATAL EXCEPTION: main
E/AndroidRuntime( 2470): Process: com.introlab.rtabmap, PID: 2470
E/AndroidRuntime( 2470): java.lang.UnsatisfiedLinkError: dlopen failed: cannot locate symbol "rand" referenced by "libNativeRTABMap.so"...
E/AndroidRuntime( 2470): at java.lang.Runtime.loadLibrary(Runtime.java:364)
E/AndroidRuntime( 2470): at java.lang.System.loadLibrary(System.java:526)
E/AndroidRuntime( 2470): at com.introlab.rtabmap.RTABMapLib.<clinit>(RTABMapLib.java:20)
E/AndroidRuntime( 2470): at com.introlab.rtabmap.RTABMapActivity.onCreate(RTABMapActivity.java:203)
E/AndroidRuntime( 2470): at android.app.Activity.performCreate(Activity.java:5231)
E/AndroidRuntime( 2470): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
E/AndroidRuntime( 2470): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2160)
E/AndroidRuntime( 2470): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2246)
E/AndroidRuntime( 2470): at android.app.ActivityThread.access$800(ActivityThread.java:136)
E/AndroidRuntime( 2470): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1197)
E/AndroidRuntime( 2470): at android.os.Handler.dispatchMessage(Handler.java:102)
E/AndroidRuntime( 2470): at android.os.Looper.loop(Looper.java:136)
E/AndroidRuntime( 2470): at android.app.ActivityThread.main(ActivityThread.java:5030)
E/AndroidRuntime( 2470): at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime( 2470): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
E/AndroidRuntime( 2470): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:609)
W/ActivityManager(  904):   Force finishing activity com.introlab.rtabmap/.RTABMapActivity
I/art     (  904): Heap trim of managed (duration=15.453834ms, advised=2MB) and native (duration=3.960416ms, advised=1052KB) heaps. Managed heap utilization of 60%.
Reply | Threaded
Open this post in threaded view
|

Re: RTABMap for Android

matlabbe
Administrator
Hi,

I wrote "rtabmap/build/app/android/libs/armeabi-v7a", but in reality you should put the *.so in the same directory than libNativeRTABMap.so (if output is another directory than armeabi-v7a), it should be packaged in the app. Make sure to copy the same version used to build rtabmap library.

cheers,
Mathieu
Reply | Threaded
Open this post in threaded view
|

Re: RTABMap for Android

vito-c
pwd: rtabmap/build
# find . -name \*.so
./app/android/libs/armeabi-v7a/libNativeRTABMap.so
./app/android/libs/armeabi-v7a/libtango_client_api.so
./app/android/jni/third-party/lib/libtango_client_api.so

apk:
AndroidManifest.xml
res/drawable-hdpi-v4/ic_launcher.png
res/drawable-mdpi-v4/ic_launcher.png
res/drawable-xhdpi-v4/ic_launcher.png
res/drawable-xxhdpi-v4/ic_launcher.png
res/layout/about.xml
res/layout/activity_rtabmap.xml
res/menu/optionmenu.xml
res/raw/info.txt
resources.arsc
classes.dex
lib/armeabi-v7a/libNativeRTABMap.so
lib/armeabi-v7a/libtango_client_api.so
META-INF/MANIFEST.MF
META-INF/CERT.SF
META-INF/CERT.RSA
12