Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
249 changes: 89 additions & 160 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
cmake_minimum_required(VERSION 3.10.0)
project(fast_gicp)

option(BUILD_VGICP_CUDA "Build GPU-powered VGICP" OFF)
if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
set(CMAKE_CUDA_ARCHITECTURES 61)
endif()

project(fast_gicp LANGUAGES CXX CUDA)

option(BUILD_VGICP_CUDA "Build GPU-powered VGICP" ON)
option(BUILD_apps "Build application programs" ON)
option(BUILD_test "Build test programs" OFF)
option(BUILD_PYTHON_BINDINGS "Build python bindings" OFF)
Expand All @@ -12,179 +17,103 @@ find_package(PCL REQUIRED)
find_package(Eigen3 REQUIRED)
add_definitions(${PCL_DEFINITIONS})

if(DEFINED ENV{ROS_VERSION})
set(ROS_VERSION $ENV{ROS_VERSION})
endif()

if(NOT BUILD_PYTHON_BINDINGS)
if(${ROS_VERSION})
if(${ROS_VERSION} EQUAL 1)
find_package(catkin)
elseif (${ROS_VERSION} EQUAL 2)
find_package(ament_cmake)
endif()
endif()
endif()

find_package(OpenMP)
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif()

if(BUILD_VGICP_CUDA)
find_package(CUDA REQUIRED)
include_directories(${CUDA_INCLUDE_DIRS})
link_directories(${CUDA_LIBRARY_DIRS})
endif()

###################################
## catkin specific configuration ##
###################################
if(catkin_FOUND)
catkin_package(
INCLUDE_DIRS include
LIBRARIES fast_gicp
)
endif()

###########
## Build ##
###########

add_library(fast_gicp SHARED
src/fast_gicp/gicp/lsq_registration.cpp
src/fast_gicp/gicp/fast_gicp.cpp
src/fast_gicp/gicp/fast_gicp_st.cpp
src/fast_gicp/gicp/fast_vgicp.cpp
)
target_link_libraries(fast_gicp
${PCL_LIBRARIES}
glyd_add_library(fast_gicp SHARED
SOURCES
src/fast_gicp/gicp/lsq_registration.cpp
src/fast_gicp/gicp/fast_gicp.cpp
src/fast_gicp/gicp/fast_gicp_st.cpp
src/fast_gicp/gicp/fast_vgicp.cpp
src/fast_gicp/gicp/fast_vgicp_cuda.cpp
src/fast_gicp/ndt/ndt_cuda.cpp
LIBRARIES
pcl::pcl_common
pcl::pcl_features
pcl::pcl_filters
pcl::pcl_io
pcl::pcl_kdtree
pcl::pcl_octree
pcl::pcl_registration
pcl::pcl_sample_consensus
pcl::pcl_search
fast_vgicp_cuda
COMPILE_OPTIONS
${OpenMP_CXX_FLAGS}
)
if (OPENMP_FOUND)
if (TARGET OpenMP::OpenMP_CXX)
target_link_libraries(fast_gicp OpenMP::OpenMP_CXX)
endif ()
endif ()

target_include_directories(fast_gicp PUBLIC
include
${PCL_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
)

### APPS ###
if(BUILD_apps)
add_executable(gicp_align src/align.cpp)
add_dependencies(gicp_align fast_gicp)
target_link_libraries(gicp_align
${PCL_LIBRARIES}
fast_gicp
)

add_executable(gicp_kitti src/kitti.cpp)
add_dependencies(gicp_kitti fast_gicp)
target_link_libraries(gicp_kitti
${PCL_LIBRARIES}
fast_gicp
)
endif()

### Python bindings ###
if(BUILD_PYTHON_BINDINGS)
add_subdirectory(thirdparty/pybind11)
pybind11_add_module(pygicp
src/python/main.cpp
)
target_include_directories(pygicp PUBLIC
include
${PCL_INCLUDE_DIRS}
${EIGEN3_INCLUDE_DIR}
)
target_link_libraries(pygicp PRIVATE
fast_gicp
)
endif()

### CUDA ###
if(BUILD_VGICP_CUDA)
set(CUDA_NVCC_FLAGS "--expt-relaxed-constexpr")
add_definitions(-DUSE_VGICP_CUDA)

cuda_add_library(fast_vgicp_cuda SHARED
src/fast_gicp/cuda/fast_vgicp_cuda.cu
src/fast_gicp/cuda/brute_force_knn.cu
src/fast_gicp/cuda/covariance_estimation.cu
src/fast_gicp/cuda/covariance_estimation_rbf.cu
src/fast_gicp/cuda/covariance_regularization.cu
src/fast_gicp/cuda/gaussian_voxelmap.cu
src/fast_gicp/cuda/find_voxel_correspondences.cu
src/fast_gicp/cuda/compute_derivatives.cu
src/fast_gicp/cuda/compute_mahalanobis.cu
src/fast_gicp/cuda/ndt_cuda.cu
src/fast_gicp/cuda/ndt_compute_derivatives.cu
)
target_include_directories(fast_vgicp_cuda PRIVATE
include
thirdparty/Eigen
thirdparty/nvbio
${catkin_INCLUDE_DIRS}
)
target_link_libraries(fast_vgicp_cuda
${catkin_LIBRARIES}
)
cuda_add_cublas_to_target(fast_vgicp_cuda)

# add vgicp_cuda to libfast_gicp
target_sources(fast_gicp PRIVATE
src/fast_gicp/gicp/fast_vgicp_cuda.cpp
src/fast_gicp/ndt/ndt_cuda.cpp
)
target_link_libraries(fast_gicp
fast_vgicp_cuda
)
add_dependencies(fast_gicp fast_vgicp_cuda)
if(catkin_FOUND)
install(TARGETS fast_vgicp_cuda
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})
elseif (ament_cmake_FOUND)
install(TARGETS fast_vgicp_cuda
LIBRARY DESTINATION lib)
endif()
endif()

### TEST ###
if(BUILD_test)
find_package(GTest REQUIRED)
set(CUDA_NVCC_FLAGS "--expt-relaxed-constexpr")
add_definitions(-DUSE_VGICP_CUDA)
glyd_add_library(fast_vgicp_cuda SHARED
SOURCES
src/fast_gicp/cuda/fast_vgicp_cuda.cu
src/fast_gicp/cuda/brute_force_knn.cu
src/fast_gicp/cuda/covariance_estimation.cu
src/fast_gicp/cuda/covariance_estimation_rbf.cu
src/fast_gicp/cuda/covariance_regularization.cu
src/fast_gicp/cuda/gaussian_voxelmap.cu
src/fast_gicp/cuda/find_voxel_correspondences.cu
src/fast_gicp/cuda/compute_derivatives.cu
src/fast_gicp/cuda/compute_mahalanobis.cu
src/fast_gicp/cuda/ndt_cuda.cu
src/fast_gicp/cuda/ndt_compute_derivatives.cu
LIBRARIES
pcl::pcl_common
pcl::pcl_features
pcl::pcl_filters
pcl::pcl_io
pcl::pcl_kdtree
pcl::pcl_octree
pcl::pcl_registration
pcl::pcl_sample_consensus
pcl::pcl_search
Eigen3::Eigen
CUDA::cublas
CUDA::curand
)
set_property(
TARGET
fast_vgicp_cuda
PROPERTY
CUDA_STANDARD
14
)
set_target_properties(fast_vgicp_cuda PROPERTIES CUDA_ARCHITECTURES "61;72;86")

add_executable(gicp_test src/test/gicp_test.cpp)
add_dependencies(gicp_test fast_gicp)
target_link_libraries(gicp_test ${GTEST_LIBRARIES} ${PCL_LIBRARIES} fast_gicp)
gtest_add_tests(TARGET gicp_test WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} EXTRA_ARGS "${CMAKE_SOURCE_DIR}/data")
target_include_directories(fast_vgicp_cuda PRIVATE
include
thirdparty/nvbio
${OpenMP_CXX_FLAGS}
)
endif()

if(catkin_FOUND)
###################################
## catkin specific configuration ##
###################################
install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})

install(DIRECTORY include/
DESTINATION ${CATKIN_GLOBAL_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.hpp")
elseif (ament_cmake_FOUND)
##################################
## ament specific configuration ##
##################################
ament_export_include_directories(include)
ament_export_libraries(fast_gicp)
ament_package()

install(TARGETS ${PROJECT_NAME}
LIBRARY DESTINATION lib)

install(
DIRECTORY "include/"
DESTINATION include
### APPS ###
if(BUILD_apps)
glyd_add_executable(
gicp_align
SOURCES
src/align.cpp
LIBRARIES
fast_gicp
pcl::pcl_common
pcl::pcl_features
pcl::pcl_filters
pcl::pcl_io
pcl::pcl_kdtree
pcl::pcl_octree
pcl::pcl_registration
pcl::pcl_sample_consensus
COMPILE_OPTIONS
${OpenMP_CXX_FLAGS}
)
endif()
2 changes: 1 addition & 1 deletion include/fast_gicp/gicp/impl/lsq_registration_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,4 +167,4 @@ bool LsqRegistration<PointTarget, PointSource>::step_lm(Eigen::Isometry3d& x0, E
return false;
}

} // namespace fast_gicp
} // namespace fast_gicp
4 changes: 3 additions & 1 deletion include/fast_gicp/gicp/lsq_registration.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ class LsqRegistration : public pcl::Registration<PointSource, PointTarget, float
void setInitialLambdaFactor(double init_lambda_factor);
void setDebugPrint(bool lm_debug_print);

int getFinalNumIterations() { return nr_iterations_; }

const Eigen::Matrix<double, 6, 6>& getFinalHessian() const;

double evaluateCost(const Eigen::Matrix4f& relative_pose, Eigen::Matrix<double, 6, 6>* H = nullptr, Eigen::Matrix<double, 6, 1>* b = nullptr);
Expand Down Expand Up @@ -85,4 +87,4 @@ class LsqRegistration : public pcl::Registration<PointSource, PointTarget, float
};
} // namespace fast_gicp

#endif
#endif
2 changes: 1 addition & 1 deletion include/fast_gicp/ndt/impl/ndt_cuda_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,4 +91,4 @@ double NDTCuda<PointSource, PointTarget>::compute_error(const Eigen::Isometry3d&

} // namespace fast_gicp

#endif
#endif
2 changes: 1 addition & 1 deletion include/fast_gicp/ndt/ndt_cuda.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,4 +71,4 @@ class NDTCuda : public LsqRegistration<PointSource, PointTarget> {
};
} // namespace fast_gicp

#endif
#endif
Loading