Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Building ROS package depending on Open3D fails #4093

Open
xkaraman opened this issue Sep 24, 2021 · 10 comments
Open

Building ROS package depending on Open3D fails #4093

xkaraman opened this issue Sep 24, 2021 · 10 comments
Assignees
Labels
build/install Build or installation issue

Comments

@xkaraman
Copy link
Contributor

Describe the bug
Trying to build a ROS package depending on Open3D. Open3d is built from source and installed on non root location. (e.g. ~/user/git/Open3d/install

Being a ROS package, CMakeLists.txt contains find_package(catkin REQUIRED COMPONENTS roscpp) and also find_package(Open3D REQUIRED).

If i run, catkin build i get the error

Could not find a package configuration file provided by "Open3D" with any
  of the following names:

    Open3DConfig.cmake
    open3d-config.cmake

as expected.

If i then run catkin build -DCMAKE_PREFIX_PATH="~/git/Open3D/install/lib/cmake i get the error

Could not find a package configuration file provided by "CUDAToolkit" with
  any of the following names:

    CUDAToolkitConfig.cmake
    cudatoolkit-config.cmake

which is NOT expected.

Finally, if i catkin build -DCMAKE_PREFIX_PATH="~/git/Open3D/install/lib/cmake after a complete deletion of devel, install folders (catkin clean), i get the error

Could not find a package configuration file provided by "catkin" with any
  of the following names:

    catkinConfig.cmake
    catkin-config.cmake

which is not at all expected. Something probably messes up paths.

To Reproduce
Check abobe

Expected behavior
Projects depending on Open3D, can be built without erros and missing CMAKE config files.

Environment (please complete the following information):

  • Operating system: Ubuntu 18.04
  • Python version: Python 2.7 (ROS Melodic doesnt support 3)
  • Open3D version: master branch
  • Is this remote workstation?: no
  • How did you install Open3D?: build from source
  • Compiler version (if built from source): gcc 7.5

Additional context
Add any other context about the problem here.

@Ericgeese
Copy link

Ericgeese commented Sep 28, 2021

Have you tried to write your own FindOpen3D.cmake file?

@xkaraman
Copy link
Contributor Author

xkaraman commented Oct 1, 2021

Not quite sure, how i would i go on writing a cmake file. If you got any directions to point me to, i can try.

@theNded theNded added the build/install Build or installation issue label Nov 19, 2021
@ssheorey
Copy link
Member

@xkaraman thanks for reporting this:

  • Open3D doesn't support Python 2.7. You can still use it through the C++ interface, as long as you don't use the Python bindings.
Could not find a package configuration file provided by "Open3D" with any
  of the following names:

    Open3DConfig.cmake
    open3d-config.cmake

With plain cmake, you would ensure that Open3D is found by saying:
cmake -DOpen3D_ROOT=<Open3D_install_path> ..

You do not need to change CMAKE_PREFIX_PATH.

Please see https://github.com/isl-org/open3d-cmake-find-package for details on using Open3D installed in a location.

@xkaraman
Copy link
Contributor Author

@ssheorey I am not trying anything with python as far as i know. i want to use the C++ Open3D library to build some ROS package. Catkin tool uses cmake as config/build mechanism.

I am able to build plain c++ cmake packages with open3d as a dependency with no problems using the CMAKE_PREFIX_PATH.

The problem here is with building along with ROS. I guess that open3d cmake define paths that messes up ROS/packages paths but i have nothing to back this up. Just the second and third example i quoted above.

@ssheorey
Copy link
Member

@xkaraman does using Open3D_ROOT work for you? Please don't set CMAKE_PREFIX_PATH.

@xkaraman
Copy link
Contributor Author

Nop it doesn't! Why should't i use CMAKE_PREFIX_PATH. That's is the recommended way by CMake for installed packages.

@ssheorey
Copy link
Member

What's the cmake output with cmake -DOpen3D_ROOT=<Open3D_install_path> <source_folder>?

@xkaraman
Copy link
Contributor Author

As i already stated above i can compile fine using cmake_prefix_path and using cmake tool.

The problem arise when i use ROS catkin tool that uses internally cmake. The errors are shown as above.

@ssheorey
Copy link
Member

Can you provide a minimum example that lets us reproduce the error (ROS build scripts, sample code, commands)?

@xkaraman
Copy link
Contributor Author

xkaraman commented Feb 1, 2022

Sure here is a detailed example.

ROS

ROS is installed from apt. See Installing ROS. I use melodic due to 18.04 Ubuntu, newer Ubuntu use Noetic ROS.
I also prefer catkin_tools package and i will be using for this walk-through but you can generally skip it.

Build and install Open3D.

mkdir -p ~/git_space/Open3D && cd ~/git_space/Open3D
git clone https://github.com/isl-org/Open3D.git
cd Open3D
git checkout -b v0.14.1
mkdir build && cd build
# GLIBCXX_USE_CXX11_ABI=ON due to undefined references to ros::
cmake .. -DGLIBCXX_USE_CXX11_ABI=ON -DCMAKE_INSTALL_PREFIX=../install
make -j8
make install 

Open3D is now installed in folder ~/git_space/Open3D/install

Build Open3D_conversions ROS package that depends on Open3D

Unfortunately due to API changes in Open3D, we should modify open3d_conversions.cpp in src folder.
Change lines around 159-161

const open3d::core::Tensor& o3d_TensorList_points = pointcloud.GetPoints();
modifier.resize(pointcloud.GetPoints().GetShape()[0]);
ros_pc2.data.reserve(pointcloud.GetPoints().GetShape()[0]);

to

const open3d::core::Tensor& o3d_TensorList_points = pointcloud.GetPointAttr("positions");
modifier.resize(pointcloud.GetPointAttr("positions").GetShape()[0]);
ros_pc2.data.reserve(pointcloud.GetPointAttr("positions").GetShape()[0]);

and line 252

o3d_tpc.SetPoints(o3d_tpc_points);

to

o3d_tpc.SetPointAttr("positions",o3d_tpc_points);

Then we follow ROS methodology to build packages in a new workspace.

# Create ROS workspace
mkdir -p ~/open3d_ws && cd ~/open3d_ws
mkdir src
catkin init # Need catkin_tools

cd src
git clone https://github.com/ros-perception/perception_open3d.git

# Build as with my Original commands
catkin build --verbose # This should fail as Open3d is not installed in searched paths (EXPECTED)
catkin build --verbose -DCMAKE_PREFIX_PATH=~/git_space/Open3D/install # Second error (NOT EXPECTED. My latest run roscppConfig.cmake was not found )

# Remove any build artifacts and run again cleanly
catkin clean
catkin build --verbose -DCMAKE_PREFIX_PATH=~/git_space/Open3D/install # Third error (NOT EXPECTED. catkinConfig.cmake not found)

Note

When Open3D is installed in a standard location ie. /usr/local, catkin build runs successfully building the perception_open3d metapackage that includes open3d_conversions and open3d_conversions_examples.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build/install Build or installation issue
Projects
None yet
Development

No branches or pull requests

4 participants