polylidar icon indicating copy to clipboard operation
polylidar copied to clipboard

Try to use polylidar with ROS

Open bxc237 opened this issue 3 years ago • 8 comments

Hi @JeremyBYU, thank you for sharing your awesome work. I would like to achieve what you did in polylidar-realsense using ROS and C++. However, the C++ tutorials are empty and the c++ example (simple.cpp) might be too simple to let me figure out how to deal with the streaming 3D point cloud. Therefore, could you give me some advice on how to do it?

bxc237 avatar Jun 04 '21 11:06 bxc237

Hi @bxc237 , Thanks for checking out Polylidar3D. I do not really have a full example of using all of the Polylidar3D framework in C++. This repo is nearly all written in C++ but the other repos I wrote, FastGaussianAccumulator(FastGA) and OrganizedPointFilters(OPF) still have a some python code that is required. From my memory this is what is remaining to have finished:

Polylidar3D

  1. The polygon filtering and simplification is calling python code (shapely)

FastGA

  1. Using python Scipy for peak detection
  2. Using python Scipy for agglomerative hierarchical clustering

OPF

  1. All the GPU kernels are actually written in C++. But I use python cupy to simplify launching the device kernels and getting memory in and out of the GPU. I would have to redo the build system to optionally build the kernels with nvcc and manage memory manually.

I have been wanting to convert these last code sections to pure C++ for a while. This issue has encouraged me to at least work on getting FastGA completely as CPP code. I think that should be done soon.

Once FastGA is completely finished I should be able to add a better C++ example that has most of the Polylidar3D framework working.

However, as it currently stands. I would not recommend using this project with ROS with C++.

JeremyBYU avatar Jun 05 '21 21:06 JeremyBYU

@JeremyBYU thank you for the reply. It sounds like that once you get the C++ interface in FastGA done, I can at least try it without GPU acceleration. According to your experience, do you think this framework will run well on NUC with the mobile i7 CPU? Does the GPU really help a lot? Thank you.

bxc237 avatar Jun 06 '21 09:06 bxc237

It depends on the sensor stream, how noisy it is, and the resolution of the data.

I think it should run okay on an i7 though for 440*240 streams that aren't to crazy noisy.

I'm pretty busy right now and won't be able to get back to this till the end of July. I did finish the fastga work this weekend on the branch s2beta. Should be fully cpp now. But it will take more time to make a full working example of using polylidar3d with realsense in just cpp.

JeremyBYU avatar Jun 06 '21 14:06 JeremyBYU

Hi @JeremyBYU , perhaps you could tell me which C++ class functions I should call, let's say after I got the downsampled/filtered point cloud data from D435? I will be happy to share my experience as the working ROS/C++ example if I can get it run. Or those interfaces are just not that straightforward as I assumed? Thank you again.

bxc237 avatar Jun 07 '21 05:06 bxc237

The API calls will be very similar to the python api calls in the python examples. I think it's just a difference in snake_case versus CamelCase. I added a new API call in the fastga to find dominant plane normals: https://github.com/JeremyBYU/FastGaussianAccumulator/blob/682d862748fb20dd450c6f4893af028a2f0d1f22/include/FastGA/FastGA.hpp#L350

That's the only new API call. Sorry I can't be of more help now. Pretty tight on time right now!

JeremyBYU avatar Jun 08 '21 21:06 JeremyBYU

@JeremyBYU Thank you for your time. I will give it a try. Right now, I will leave this issue open.

bxc237 avatar Jun 10 '21 05:06 bxc237

I made some updates on the dev branch. I made an almost full example here: https://github.com/JeremyBYU/polylidar/blob/dev/examples/cpp/polylidar-full-example.cpp

Be sure to read this README.md if you are going to build: https://github.com/JeremyBYU/polylidar/blob/dev/examples/cpp/README.md

Also wrote some documentation for it in that same branch in the src_docs folder: https://github.com/JeremyBYU/polylidar/blob/dev/src_docs/tutorial/C%2B%2B/basic.rst

Will push to master after I do some more testing and finish my thesis .

JeremyBYU avatar Jun 11 '21 23:06 JeremyBYU

This is awesome! Good luck with your thesis.

bxc237 avatar Jun 12 '21 11:06 bxc237