atenpas / gpd

Detect 6-DOF grasp poses in point clouds
BSD 2-Clause "Simplified" License
606 stars 233 forks source link

tutorial not reproducing promised result #88

Open jediofgever opened 4 years ago

jediofgever commented 4 years ago

HI, I appreciate the code and efforts. when I try to reproduce tutorial result i don't get same result.

./detect_grasps ../cfg/eigen_params.cfg ../tutorials/krylon.pcd

only gives a PCL viewer with point cloud normals, Screenshot from 2020-03-11 09-07-55

is anyone have same problem ?

runeg96 commented 4 years ago

Im having the same problem. I went a bit into the code but cant figure out why this happens. The program shutdowns after you close down that plot.

naokiuchida commented 4 years ago

Have you tried to press Q after this window poped up?

jediofgever commented 4 years ago

Yes I tried, program halts after I presss Q , nothing happens after

atenpas commented 4 years ago

Do you have the same problem as https://github.com/atenpas/gpd/issues/87?

jediofgever commented 4 years ago

yes I think this is likely same issue , I am also using 18.04 ubuntu, it does not give any error or warning, just silently ends without giving detection results

atenpas commented 4 years ago

I'm planning to investigate this further, but I don't have access to a Ubuntu 18.04 system at the moment. It's unclear what's causing this, but I suspect an Eigen related memory leak. Sorry about the delay.

jediofgever commented 4 years ago

That would be really great , many Linux users are shifting to 18 04 now(including myself)

edwardchaos commented 4 years ago

Just tried it, I get this exact result as well on Ubuntu 18

Built source and tried debugging, step over using debugger jumps around in a strange way, probably from multiprocess with omp? I narrowed the bug to somewhere in the for loop(link to code below).

seg fault triggerd by destructor of an Eigen matrix in PointList. Here is an image of the stack trace

image

https://github.com/atenpas/gpd/blob/96fc9bcf17ee6669cabf9cd0e66f8e62ba617e08/src/gpd/candidate/hand_search.cpp#L172

edwardchaos commented 4 years ago

Problem is resolved after I remove compiler optimisation -O3 from cmakelists here.

and also openmp directives here.

I tried O1 and O2 as well but they also caused seg fault. I also tried without O3 and with omp but it also seg faulted.

The only permutation that worked is when optimisation is completely off.

@atenpas

schaikunsaeng commented 4 years ago

I got it working if I compile gpd with PCL 1.8.1, but I got the segfault when I do PCL 1.9 or higher. It seems like the compiler optimized some variable off when you try to slice the point cloud.

Nurgak commented 4 years ago

Tried with Ubuntu 18.04, PCL 1.11.0, got segfaults. Removed the -O3 as per @edwardchaos findings, the tutorial reached a later point, but still segfaulted. Downgraded PCL to 1.8.1 (built from source) as per @schaikunsaeng finidings, then it worked.

PCL tutorial

I wonder why it fails with PCL 1.9 as this is requested in the requirements, so somebody got it working with PCL 1.9+?

JasonLiu324 commented 4 years ago

@Nurgak Hi there, did you manage to run the GPD 2 with PCL 1.8.1? Because after I installed PCL 1.8 and cmake the GPD, the segmentation fault still came out. Thanks a lot.

Nurgak commented 4 years ago

@JasonLiu324 The only relevant modifications I made was to CMakeLists.txt file:

JasonLiu324 commented 4 years ago

@Nurgak I really appreciate for your reply, thanks a lot. I have made these changes, but I still got the segfault. I'm now using Ubuntu 16.04, kinetic, PCL 1.8, VTK 7.1, OpenCV 3.3 and Eigen3. It is really confusing. BTW, when I cmake the GPD, there shows some warning such as:

In file included from /usr/include/pcl-1.8/pcl/sample_consensus/sac_model.h:52:0, from /usr/include/pcl-1.8/pcl/sample_consensus/sac.h:45, from /usr/include/pcl-1.8/pcl/segmentation/sac_segmentation.h:49, from /home/jyliu/gpd/include/gpd/descriptor/image_generator.h:50, from /home/jyliu/gpd/include/gpd/grasp_detector.h:51, from /home/jyliu/gpd/include/gpd/sequential_importance_sampling.h:41, from /home/jyliu/gpd/src/cem_detect_grasps.cpp:3: /usr/include/pcl-1.8/pcl/sample_consensus/model_types.h: In function ‘void __static_initialization_and_destruction_0(int, int)’: /usr/include/pcl-1.8/pcl/sample_consensus/model_types.h:99:3: warning: ‘pcl::SAC_SAMPLE_SIZE’ is deprecated: This map is deprecated and is kept only to prevent breaking existing user code. Starting from PCL 1.8.0 model sample size is a protected member of the SampleConsensusModel class [-Wdeprecated-declarations] SAC_SAMPLE_SIZE (sample_size_pairs, sample_size_pairs + sizeof (sample_size_pairs) / sizeof (SampleSizeModel)); ^~~~~~~ /usr/include/pcl-1.8/pcl/sample_consensus/model_types.h:99:3: note: declared here

Does this warning have something to do with the error?

Nurgak commented 4 years ago

@JasonLiu324 I tried it in June and forgot what warnings came up. Try with OpenCV 3.4 as mentioned in the required dependancies.

I was using Ubuntu 18.04, Melodic, PCL 1.8.1 and running GPD in a Docker container if that makes any difference.

Ctiger96 commented 3 years ago

96 can make it work.

atenpas commented 3 years ago

Could you try the following flags?

set(CMAKE_CXX_FLAGS "-O3 -march=native -mtune=intel -msse4.2 -mavx2 -mfma -flto -fopenmp -fPIC -Wno-d eprecated -Wenum-compare -Wno-ignored-attributes -std=c++17")

This works for me in Ubuntu 18.04 where with the previous set of flags, I'd encountered a segfault. The compilation takes some time, but GPD runs fast.

Avdbergnmf commented 3 years ago

@atenpas I tried this, but it wouldn't compile. Perhaps I'm doing something wrong:

cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_CXX_FLAGS="-O3 -march=native -mtune=intel -msse4.2 -mavx2 -mfma -flto -fopenmp -fPIC -Wno-d eprecated -Wenum-compare -Wno-ignored-attributes -std=c++17" .. 
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- broken
CMake Error at /usr/local/share/cmake-3.10/Modules/CMakeTestCXXCompiler.cmake:45 (message):
  The C++ compiler

    "/usr/bin/c++"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: /home/pcl/docker_dir/gpd/gpd/build/CMakeFiles/CMakeTmp

    Run Build Command:"/usr/bin/make" "cmTC_792a3/fast"
    /usr/bin/make -f CMakeFiles/cmTC_792a3.dir/build.make CMakeFiles/cmTC_792a3.dir/build
    make[1]: Entering directory '/home/pcl/docker_dir/gpd/gpd/build/CMakeFiles/CMakeTmp'
    Building CXX object CMakeFiles/cmTC_792a3.dir/testCXXCompiler.cxx.o
    /usr/bin/c++    -O3 -march=native -mtune=intel -msse4.2 -mavx2 -mfma -flto -fopenmp -fPIC -Wno-d eprecated -Wenum-compare -Wno-ignored-attributes -std=c++17    -o CMakeFiles/cmTC_792a3.dir/testCXXCompiler.cxx.o -c /home/pcl/docker_dir/gpd/gpd/build/CMakeFiles/CMakeTmp/testCXXCompiler.cxx
    c++: error: eprecated: No such file or directory
    CMakeFiles/cmTC_792a3.dir/build.make:65: recipe for target 'CMakeFiles/cmTC_792a3.dir/testCXXCompiler.cxx.o' failed
    make[1]: *** [CMakeFiles/cmTC_792a3.dir/testCXXCompiler.cxx.o] Error 1
    make[1]: Leaving directory '/home/pcl/docker_dir/gpd/gpd/build/CMakeFiles/CMakeTmp'
    Makefile:126: recipe for target 'cmTC_792a3/fast' failed
    make: *** [cmTC_792a3/fast] Error 2

  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:2 (project)

-- Configuring incomplete, errors occurred!
See also "/home/pcl/docker_dir/gpd/gpd/build/CMakeFiles/CMakeOutput.log".
See also "/home/pcl/docker_dir/gpd/gpd/build/CMakeFiles/CMakeError.log".

edit: Oof I saw the mistake as I posted this comment. There is a space in the word deprecated in one of the flags! without this, it'll compile. Now going to test if it'll indeed run fast.

edit 2: Big oof, running into the same segmentation fault again.

edit 3: Alright wtf, setting the build type to debug mode fixes this error. No idea why but if the above command doesn't work. Try

cmake -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_CXX_FLAGS_DEBUG="-O3 -march=native -mtune=intel -msse4.2 -mavx2 -mfma -flto -fopenmp -fPIC -Wno-deprecated -Wenum-compare -Wno-ignored-attributes -std=c++17" .. 

Ofcourse you can also set this in the CMakeList, but I'm running this through a Dockerfile, so this is a lot easier.

Indeed takes a while to compile, but runs quickly again! Thanks!

friolero commented 2 years ago

Could you try the following flags?

set(CMAKE_CXX_FLAGS "-O3 -march=native -mtune=intel -msse4.2 -mavx2 -mfma -flto -fopenmp -fPIC -Wno-d eprecated -Wenum-compare -Wno-ignored-attributes -std=c++17")

This works for me in Ubuntu 18.04 where with the previous set of flags, I'd encountered a segfault. The compilation takes some time, but GPD runs fast.

This builds gpd fine for me on both ubuntu 18.04 and ubuntu 20.04. However I found with gpd_ros, it triggers 'double free or corruption (out)' for deleting cloudcamera whenever it tries to delete an existing cloudcamera (therefore it only deletes fine for the first cloud_callback when cloudcamera is initalized as NULL).

If I remove those flags ' -march=native -msse4.2 -mavx2 -mfma -flto' and rebuild gpd and gpd_ros the issue disppears and runs fine over time. I'm not very familar with those optimization flags, do you have any insight why the 'double free or corruption' issue happens and why removing those flags solve the problem? thanks!