Open3d: examples for how to use Open3D with PCL library and ROS

Created on 26 Jun 2018  ·  14Comments  ·  Source: intel-isl/Open3D

Hi,
I would like to know how to use Open3D with PCL library and ROS. Can anyone has an example how to convert to point cloud pcl or mesh pcl from data structure of Open3D ?
Thank you

question

Most helpful comment

@ipa-mah yea to get around those undefined references during linking, you need to ensure when you compile Open3D from source that you set the cmake build flag

-DGLIBCXX_USE_CXX11_ABI=ON

e.g.

cmake -DBUILD_EIGEN3=ON -DBUILD_GLEW=ON -DBUILD_GLFW=ON -DBUILD_JSONCPP=ON -DBUILD_PNG=ON -DGLIBCXX_USE_CXX11_ABI=ON -DPYTHON_EXECUTABLE=/usr/bin/python ..

This will allow everything to compile and link properly in a catkin workspace with ROS

All 14 comments

The current I/O supports .pcd format which is the primary format used by PCL.
For mesh, both PCL and Open3D support .ply, which is rather standard.

See this: http://www.open3d.org/docs/tutorial/Basic/file_io.html

I don't have much experience with ROS though. This is a known issue that Open3D does not have interface with ROS. We are planning to address it. It is on our roadmap.

Thanks

I've managed to convert the point cloud by writing and reading from /dev/shm which is a file stored in RAM. Its probably not the best way, but it works.

void point_cloud_callback(const sensor_msgs::PointCloud2::ConstPtr& msg)
{
    auto start = std::chrono::steady_clock::now();
    pcl::PCLPointCloud2 pcl_cloud;
    pcl_conversions::toPCL(*msg, pcl_cloud);
    pcl::PLYWriter pclWrite;
    pclWrite.writeBinary("/dev/shm/point_cloud.ply", pcl_cloud);
    open3d::geometry::PointCloud pc;
    pc = *open3d::io::CreatePointCloudFromFile("/dev/shm/point_cloud.ply","ply").get();
    auto end = std::chrono::steady_clock::now();
    std::cout << "Elapsed time in nanoseconds : "
         << std::chrono::duration_cast<std::chrono::nanoseconds>(end - start).count()
         << " ns" << std::endl;
}

This conversion takes about 244 ms on my i7-8700 at 4.3Ghz

@airfield20 did you successfully build ROS + open3d together? Without the -D_GLIBCXX_USE_CXX11_ABI=0 CXX flag our code using Open3D won't compile, but with it our code using ROS won't compile - did you not run into this issue?

@finger563 I did not build them together, I installed Open3D separately before building my catkin workspace

@airfield20 that's what we've done as well. However, if we add open3d as a dependency to one of our ROS packages, then we get incomplete linking - certain functions like CreateVisualizerWindow( ... ) reference are undefined symbols (I believe due to the lack of string compatibility enforced by the flag I mentioned above). The docs say to use ${Open3D_CXX_FLAGS} which contain that flag, but using that flag causes the ros code to fail to link.

Nevermind - we just had to rebuild Open3D and explicitly set that flag when generating build files with cmake - the default turned that flag to 0, but open3d works fine and integrates with ROS just fine if we set that flag to 1.

@finger563 how are you rendering ros messages using it?

We've got some code which projects a depth + rgb image (sensor_msgs/Image)into a pointcloud and then creates a voxel grid using open3d. because it's a single node and we wanted animation & key callbacks we have to explicitly create the window and manage the event loop. Similar is true in the C++ side of things which is what we've been working on and ran into this earlier.

I also tried to install Open3D with ROS few weeks ago but was not successful. I remember that there are conflicts of Open3D and ROS dependencies, that lead to undefined reference of visualization functions. So I decided to remove Open3D out of ROS, write my own functions similar to Open3D funcs

@ipa-mah yea to get around those undefined references during linking, you need to ensure when you compile Open3D from source that you set the cmake build flag

-DGLIBCXX_USE_CXX11_ABI=ON

e.g.

cmake -DBUILD_EIGEN3=ON -DBUILD_GLEW=ON -DBUILD_GLFW=ON -DBUILD_JSONCPP=ON -DBUILD_PNG=ON -DGLIBCXX_USE_CXX11_ABI=ON -DPYTHON_EXECUTABLE=/usr/bin/python ..

This will allow everything to compile and link properly in a catkin workspace with ROS

We just released open3d_ros to provide the functionality of converting pointclouds from ROS to Open3D and vice versa

I also tried to install Open3D with ROS few weeks ago but was not successful. I remember that there are conflicts of Open3D and ROS dependencies, that lead to undefined reference of visualization functions. So I decided to remove Open3D out of ROS, write my own functions similar to Open3D funcs

I’ve got the same issue, have you resolved it?

I’ve got the same issue, have you resolved it?

Same issue here.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

hzxie picture hzxie  ·  4Comments

mutp picture mutp  ·  4Comments

blackccpie picture blackccpie  ·  3Comments

masonsun picture masonsun  ·  3Comments

DKandrew picture DKandrew  ·  3Comments