rtabmap icon indicating copy to clipboard operation
rtabmap copied to clipboard

Integrate RTAB-Map iOS Functionality into Existing iOS Project

Open gulam-luxolis opened this issue 6 months ago • 1 comments

Hello,

I’m trying to integrate the RTAB-Map iOS logic into my existing iOS application but I'm running into persistent compilation errors, even after installing the required C/C++ libraries.

I suspect I may be missing a step or misconfiguring the integration process. It would be extremely helpful if someone could guide me through the proper way to integrate RTAB-Map into an existing project

What I’ve Done So Far:

  • Moved my existing iOS project into the rtabmap/app/ directory under the name MyProject.
  • Added the necessary RTAB-Map source files and logic into my project’s workspace, including the install_deps.sh script and related dependencies.
  • Configured the Build Settings > Search Paths (e.g., Header Search Paths, Library Search Paths) to match those of the RTAB-Map iOS project.
  • Set the C Language Dialect to match the RTAB-Map iOS project for compatibility.

I’d appreciate any help, documentation, or example projects that demonstrate a successful integration of RTAB-Map into an existing iOS app.

gulam-luxolis avatar Jun 03 '25 11:06 gulam-luxolis

We integrated RTAB-Map iOS to another iOS app (closed-source) by basically re-using the whole cpp back-end from RTAB-Map iOS and re-doing the whole front-end Swift code from scratch.

The script "install_deps.sh" is slightly modified to clone/build rtabmap like this:

diff --git a/app/ios/RTABMapApp/install_deps.sh b/app/ios/RTABMapApp/install_deps.sh
index 0c575097..7a9c6c65 100755
--- a/app/ios/RTABMapApp/install_deps.sh
+++ b/app/ios/RTABMapApp/install_deps.sh
@@ -282,12 +282,15 @@ cmake --build . --config Release --target install -- CODE_SIGN_IDENTITY="" CODE_
 cd $pwd
 fi
 
-mkdir -p rtabmap
-cd rtabmap
-cmake -DANDROID_PREBUILD=ON ../../../../..
+if [ ! -e rtabmap ]
+then
+git clone https://github.com/introlab/rtabmap.git
+fi
+cd rtabmap/build
+cmake -DANDROID_PREBUILD=ON ..
 cmake --build . --config Release
 mkdir -p ios
 cd ios
-cmake -G Xcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_SYSROOT=$sysroot -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 -DCMAKE_INSTALL_PREFIX=$prefix -DCMAKE_FIND_ROOT_PATH=$prefix -DWITH_QT=OFF -DBUILD_APP=OFF -DBUILD_TOOLS=OFF -DWITH_TORO=OFF -DWITH_VERTIGO=OFF -DWITH_MADGWICK=OFF -DWITH_ORB_OCTREE=ON  -DBUILD_EXAMPLES=OFF -DWITH_LIBLAS=ON ../../../../../..
+cmake -G Xcode -DCMAKE_SYSTEM_NAME=iOS -DCMAKE_OSX_ARCHITECTURES=arm64 -DCMAKE_OSX_SYSROOT=$sysroot -DBUILD_SHARED_LIBS=OFF -DCMAKE_BUILD_TYPE=Release -DCMAKE_OSX_DEPLOYMENT_TARGET=12.0 -DCMAKE_INSTALL_PREFIX=$prefix -DCMAKE_FIND_ROOT_PATH=$prefix -DWITH_QT=OFF -DBUILD_APP=OFF -DBUILD_TOOLS=OFF -DWITH_TORO=OFF -DWITH_VERTIGO=OFF -DWITH_MADGWICK=OFF -DWITH_ORB_OCTREE=OFF  -DBUILD_EXAMPLES=OFF -DWITH_LIBLAS=ON ../..
 cmake --build . --config Release
 cmake --build . --config Release --target install

So that script should take care of all cpp dependencies. Afterwards, you would need to integrate these files in your XCode project directly. This wraps the RTAB-Map library, you may remove all OpenGL ES stuff from RTABMapApp.cpp if you don't care about rendering (which is 90% of that file!).

The swift <-> cpp bridge is done by RTABMap.swift class and NativeWrapper.h (calling RTABMapApp.h functions).

matlabbe avatar Jun 07 '25 20:06 matlabbe