本文主要是介绍使用fcl库做碰撞检测,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
fcl库是真难用,导入自己的项目的时候遇到各种坑。
第一个坑就是git clone并build fcl库后生成的fcl-config.cmake里面有问题,需要在这里进行相应修改
set_and_check(FCL_INCLUDE_DIRS "/home/xxxx/fcl/build/include")
set(FCL_LIBRARIES fcl)
set_and_check(FCL_LIBRARY_DIRS "/home/xxxx/fcl/build/lib")
第二个坑就是当你想在自己的项目中也跑通官方的test的时候,需要googletest库,把test文件夹中的一些文件也要copy进自己的项目,以及在自己的项目中也要引用ccd库,还有一个Threads库,改写自己项目的CMakeLists.txt贼麻烦。
cmake_minimum_required(VERSION 2.8)project(test_fcl)set( CMAKE_BUILD_TYPE "Debug" )find_package(Eigen3 REQUIRED)set(CMAKE_PREFIX_PATH /home/robotics/fcl/build)
find_package(fcl REQUIRED)find_package(ccd QUIET)set(CMAKE_PREFIX_PATH /home/robotics/googletest/build/googletest/generated)
find_package(GTest REQUIRED)find_package(Threads REQUIRED)# If ccd-config.cmake is not found, use pkg-config and/or find_path() and
# find_library()
if(NOT ccd_FOUND)if(PKG_CONFIG_FOUND)pkg_search_module(PC_CCD ccd libccd)endif()# The include directory returned by pkg_config is very unreliable:# 1. PC_CCD_INCLUDE_DIRS cannot locate ccd.h definitively, it could be:# a) PC_CCD_INCLUDE_DIRS/ccd/ccd.h# b) PC_CCD_INCLUDE_DIRS/ccd.h# 2. It may be empty due to pkg-config's de-duplication, if the path is# provided by:# a) $PKG_CONFIG_SYSTEM_INCLUDE_PATH# b) $C_INCLUDE_PATH# c) $CPLUS_INCLUDE_PATHfind_path(CCD_INCLUDE_DIR ccd/ccd.hHINTS "${PC_CCD_INCLUDE_DIRS}""${PC_CCD_INCLUDE_DIRS}/.."ENV PKG_CONFIG_SYSTEM_INCLUDE_PATHENV C_INCLUDE_PATHENV CPLUS_INCLUDE_PATH)# Using find_library() even if pkg-config is available ensures that the full# path to the ccd library is available in CCD_LIBRARIESfind_library(CCD_LIBRARY ccdHINTS "${PC_CCD_LIBRARY_DIRS}")# libccd links to LibM on UNIX.if(CYGWIN OR NOT WIN32)find_library(M_LIBRARY m)endif()if(CCD_INCLUDE_DIR AND CCD_LIBRARY)set(CCD_INCLUDE_DIRS "${CCD_INCLUDE_DIR}")set(CCD_LIBRARIES "${CCD_LIBRARY}" "${M_LIBRARY}")set(ccd_FOUND ON)mark_as_advanced(CCD_INCLUDE_DIR CCD_LIBRARY)endif()
endif()if(NOT ccd_FOUND)message(FATAL_ERROR "CCD is required by FCL")
endif()set(PKG_EXTERNAL_DEPS "ccd eigen3")include_directories(
${EIGEN3_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}/include
${CMAKE_CURRENT_SOURCE_DIR}/test
${ccd_INCLUDE_DIRS}
${GTEST_INCLUDE_DIRS}
/home/robotics/fcl/build/include
/home/robotics/fcl/include
)set(SRC_LIST
./test/test_fcl_utility.cpp
./src/main.cpp)add_executable(main ${SRC_LIST})target_link_libraries(main
ccd
fcl
gtest
Threads::Threads
)
这篇关于使用fcl库做碰撞检测的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!