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

examples for how to use Open3D with PCL library and ROS #414

Closed
manhha1402 opened this issue Jun 26, 2018 · 14 comments
Closed

examples for how to use Open3D with PCL library and ROS #414

manhha1402 opened this issue Jun 26, 2018 · 14 comments
Labels

Comments

@manhha1402
Copy link

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

@qianyizh
Copy link
Collaborator

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.

@manhha1402
Copy link
Author

Thanks

@airfield20
Copy link

airfield20 commented Feb 28, 2020

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

@finger563
Copy link

@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?

@airfield20
Copy link

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

@finger563
Copy link

@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.

@finger563
Copy 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.

@airfield20
Copy link

@finger563 how are you rendering ros messages using it?

@finger563
Copy link

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.

@manhha1402
Copy link
Author

manhha1402 commented May 5, 2020

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

@finger563
Copy link

finger563 commented May 5, 2020

@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

@nkhedekar
Copy link

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

@liudaqikk
Copy link

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?

@elvircrn
Copy link

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

Same issue here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants