introlab / rtabmap

RTAB-Map library and standalone application
https://introlab.github.io/rtabmap
Other
2.84k stars 786 forks source link

Python3 Option with RTABMAP Issue #1241

Closed anath93 closed 8 months ago

anath93 commented 8 months ago

I have been trying to build Rtabmap with Python3 and torch support but Python3 seems not be coming true, cleared workspace multiple times and re-build with (For now I have hardcoded torch directory IF(WITH_TORCH) set(Torch_DIR /home/amr/.local/lib/python3.8/site-packages/torch/share/cmake/Torch) FIND_PACKAGE(Torch QUIET) IF(TORCH_FOUND) MESSAGE(STATUS "Found Torch: ${TORCH_INCLUDE_DIRS}") ENDIF(TORCH_FOUND) ENDIF(WITH_TORCH) colcon build --cmake-args -DCMAKE_BUILD_TYPE=Release -DWITH_TORCH=ON -DWITH_PYTHON=ON

The result is : image

image image

Also have been trying to set 'Vis/RoiRatios','"0.0" "0.0" "0.2" "0.3"', and 'Kp/RoiRatios','"0.0" "0.0" "0.2" "0.3"', but keep getting parse error for Feature_2d.cpp line 473. Passing this as an argument in Python file. Any thoughts on this too ?

anath93 commented 8 months ago

I tried using command, colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release -DWITH_TORCH=ON -DWITH_PYTHON=ON -DCMAKE_CXX_FLAGS="-I/usr/include/python3.8/" Still cannot build rtabmap with Python3 support.

Torch builds only after passing path to shared library like below otherwise Rtabmap still builds then after checking rtabmap --version, it complains about libc10.so which is torch shared library object not in path. export LD_LIBRARY_PATH=/home/amr/.local/lib/python3.8/site-packages/torch/lib:"$LD_LIBRARY_PATH"

Until here standard KNN + superpoint could be used but not superglue + superpoint.

Any help would be appreciated, platform is Ubuntu 20.04 + Jetpack 5.1.2 + ROS2 Galactic + 2.1.0 Torch

matlabbe commented 8 months ago

This is how cmake searches for python: https://github.com/introlab/rtabmap/blob/264c560a2c43d7abbc0563a05d96adf77841ba9c/CMakeLists.txt#L401

You can add a REQUIRED so that cmake shows more info when python is not found:

FIND_PACKAGE(Python3 COMPONENTS Interpreter Development NumPy REQUIRED) 

If cmake cannot find it, you may search on google to get more help.

Vis/RoiRatios value should be a string: '0.0 0.0 0.2 0.3'

anath93 commented 8 months ago

@matlabbe thank you for the reply, I will close this case. For now appending this line made Python3 compile with RTABMAP but still not the right solution but I will look into it, FIND_PACKAGE(Python3 3.8.10 EXACT REQUIRED COMPONENTS Interpreter Development) image

anath93 commented 8 months ago

if anyone has this issue, the problem is with symlink of python libraries, Nvidia uses 3.9 for there side and ROS uses 3.8, so removing the symlink for 3.9 on ubuntu 20.04 made it build with Rtabmap or use exact python version as stated above. ls -l /usr/bin | grep python then remove sudo rm /usr/bin/pythonX.X (desired one)